caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Sylvain Le Gall <sylvain@le-gall.net>
To: caml-list@inria.fr
Subject: Re: Generalized Algebraic Datatypes
Date: Sun, 31 Oct 2010 15:08:12 +0000 (UTC)	[thread overview]
Message-ID: <slrnicr1is.r67.sylvain@gallu.homelinux.org> (raw)
In-Reply-To: <AANLkTikfPYrkMxKEfC9H72ACb=VpDxV2WJ4YyZQwqBOe@mail.gmail.com>

On 31-10-2010, Lukasz Stafiniak <lukstafi@gmail.com> wrote:
> On Sun, Oct 31, 2010 at 3:35 PM, Sylvain Le Gall <sylvain@le-gall.net> wrote:
>> On 31-10-2010, Wojciech Daniel Meyer <wojciech.meyer@googlemail.com> wrote:
>>> bluestorm <bluestorm.dylc@gmail.com> writes:
>>>
>>>> It was actually the case in Caml Light : each datatype constructor
>>>> implicitly declared a constructor function with the same name. I
>>>> don't exactly know why this feature was dropped in Objective Caml,
>>>> but I think I remember (from a previous discussion) that people
>>>> weren't sure it was worth the additional complexity.
>>>
>>> Would that be not possible now with Camlp4 extension?
>>>
>>
>> I am pretty sure, it is possible to implement them with camlp4. Just a
>> matter of time -- and motivation.
>>
>> The only limitation I can see, is that the generated constructors won't
>> be capitalized. E.g.:
>>
>> type t = MyConstr | YourConstr of int
>>
>> =>
>>
>> type t = MyConstr | YourConstr of int
>>
>> let myConstr = MyConstr
>> let yourConstr i = YouConstr i
>>
>
> Why do you say so? HOL Light uses capitalized identifiers for values,
> for example. It's probably possible to do whatever one reasonably
> wants.
>

Function names and values are "low id" in OCaml (first letter must be
uncapitalized). If you try to define "let MyConstr = 0" in an OCaml
toplevel, you will get a syntax error... 

The code generated by camlp4 must be syntactically correct.

But maybe you are talking about a deeper integration?

E.g. whenever you encounter the constructor "YourConstr" in expr, you
transform it into "fun i -> YourConstr i". This should work but since
camlp4 is limited to a single module, you won't be able to use this
outside the module, because you won't have access to the definition of
YouConstr and won't be able to determine his arity...

But if you have an idea about how to solve this, just tell us.

Regards,
Sylvain Le Gall


  reply	other threads:[~2010-10-31 15:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-29 14:32 [Caml-list] " Dario Teixeira
2010-10-29 15:03 ` Jacques Le Normand
2010-10-29 15:19   ` Sylvain Le Gall
2010-10-29 15:53 ` [Caml-list] " Jacques Le Normand
     [not found] ` <129751088.61814.1288367649864.JavaMail.root@zmbs4.inria.fr>
2010-10-29 16:02   ` Xavier Leroy
2010-10-29 16:42     ` Dario Teixeira
2010-10-29 21:10 ` Stefan Monnier
2010-10-29 21:37   ` [Caml-list] " bluestorm
2010-10-29 23:01     ` Jacques Le Normand
2010-10-30  5:14       ` Jacques Garrigue
2010-10-30 13:04         ` Jacques Carette
2010-10-30 13:50         ` Dario Teixeira
2010-10-31 14:15     ` Wojciech Daniel Meyer
2010-10-31 14:35       ` Sylvain Le Gall
2010-10-31 14:49         ` [Caml-list] " Lukasz Stafiniak
2010-10-31 15:08           ` Sylvain Le Gall [this message]
2010-10-31 15:31             ` Lukasz Stafiniak
2010-10-29 22:05   ` Wojciech Daniel Meyer
2010-10-30 13:35   ` Dario Teixeira
  -- strict thread matches above, loose matches on Subject: below --
2010-10-25  8:39 Jacques Le Normand
2008-04-28  5:35 Generalized algebraic datatypes Jacques Le Normand

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=slrnicr1is.r67.sylvain@gallu.homelinux.org \
    --to=sylvain@le-gall.net \
    --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;
as well as URLs for NNTP newsgroup(s).