Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Markus Mottl <markus.mottl@gmail.com>
To: Alan Schmitt <alan.schmitt@polytechnique.org>
Cc: OCaml List <caml-list@inria.fr>
Subject: Re: [Caml-list] a question about GADTs
Date: Fri, 15 Jun 2018 11:21:10 -0400	[thread overview]
Message-ID: <CAP_800rujga7GgLMcU_5PSgz2VuMRVrM98VvKaHJTwaqy4DMPQ@mail.gmail.com> (raw)
In-Reply-To: <m2efh8rudt.fsf@charm-ecran.irisa.fr>

[-- Attachment #1: Type: text/plain, Size: 1292 bytes --]

I don't think that you can currently do this.  According to the manual
entry for GADTs: "This return type must use the same type constructor as
the type being defined, and have the same number of parameters."

But I guess it would be a supportable feature to perform type substitutions
until the above is satisfied if at all possible.  Substituting manually is
probably the only thing you can do until then.

On Fri, Jun 15, 2018 at 10:35 AM Alan Schmitt <
alan.schmitt@polytechnique.org> wrote:

> Hello,
>
> I'm trying to write the following:
>
> #+begin_src ocaml
> type state
> type value
> type literal
>
> type (_,_)  term =
>   | Skip : (state, state) term
>   | Const : literal -> (state, value) term
>   | If : expr * stat * stat -> (state,state) term
> and expr = (state,value) term
> and stat = (state,state) term
> #+end_src
>
> and it works well. However I would like to replace the right-hand side
> with their abbreviations (stat and expr), and at that point the
> typechecker complains. Is there a workaround?
>
> Thanks,
>
> Alan
>
> --
> OpenPGP Key ID : 040D0A3B4ED2E5C7
> Monthly Athmospheric CO₂, Mauna Loa Obs. 2018-05: 411.25, 2017-05: 409.65
>


-- 
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com

[-- Attachment #2: Type: text/html, Size: 1840 bytes --]

  reply	other threads:[~2018-06-15 15:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15 14:34 Alan Schmitt
2018-06-15 15:21 ` Markus Mottl [this message]
2018-06-15 16:34   ` Alan Schmitt
2018-06-17  3:43 ` Chet Murthy
2018-06-17  6:39   ` Viet Le
2018-06-17  6:41     ` Julia Lawall
2018-06-17  9:50     ` Jesper Louis Andersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAP_800rujga7GgLMcU_5PSgz2VuMRVrM98VvKaHJTwaqy4DMPQ@mail.gmail.com \
    --to=markus.mottl@gmail.com \
    --cc=alan.schmitt@polytechnique.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox