* [Caml-list] type synonym for polymorphic variant
@ 2015-10-01 21:41 Ashish Agarwal
2015-10-01 21:47 ` Haoyang Wang
0 siblings, 1 reply; 8+ messages in thread
From: Ashish Agarwal @ 2015-10-01 21:41 UTC (permalink / raw)
To: Caml List
[-- Attachment #1: Type: text/plain, Size: 364 bytes --]
I've been doing this in some code for years:
type s = [`A | `B]
type t = [s]
but just discovered it works only because the code was passing through
camlp4. Without camlp4, it fails. You can try in utop with and without
doing #camlp4o.
Is there some way to get the above to work without camlp4? AFAICT, the
grammar allows it, so the normal parser is wrong here.
[-- Attachment #2: Type: text/html, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] type synonym for polymorphic variant
2015-10-01 21:41 [Caml-list] type synonym for polymorphic variant Ashish Agarwal
@ 2015-10-01 21:47 ` Haoyang Wang
2015-10-01 22:06 ` Ashish Agarwal
0 siblings, 1 reply; 8+ messages in thread
From: Haoyang Wang @ 2015-10-01 21:47 UTC (permalink / raw)
To: Caml List
> On Oct 1, 2015, at 2:41 PM, Ashish Agarwal <agarwal1975@gmail.com> wrote:
>
> type s = [`A | `B]
> type t = [s]
type t = s
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] type synonym for polymorphic variant
2015-10-01 21:47 ` Haoyang Wang
@ 2015-10-01 22:06 ` Ashish Agarwal
2015-10-01 22:23 ` Daniel Bünzli
[not found] ` <CAJ_epFM9s64QY88MxPW2apF9wgnXTQiJgns9w_dTtVKyvxsGeA@mail.gmail.com>
0 siblings, 2 replies; 8+ messages in thread
From: Ashish Agarwal @ 2015-10-01 22:06 UTC (permalink / raw)
To: Haoyang Wang; +Cc: Caml List
[-- Attachment #1: Type: text/plain, Size: 520 bytes --]
Embarrassing. I don't know why I thought I had to put brackets... Thanks!
On Thu, Oct 1, 2015 at 5:47 PM, Haoyang Wang <hywang@pobox.com> wrote:
> > On Oct 1, 2015, at 2:41 PM, Ashish Agarwal <agarwal1975@gmail.com>
> wrote:
> >
> > type s = [`A | `B]
> > type t = [s]
>
> type t = s
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
[-- Attachment #2: Type: text/html, Size: 1259 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] type synonym for polymorphic variant
2015-10-01 22:06 ` Ashish Agarwal
@ 2015-10-01 22:23 ` Daniel Bünzli
2015-10-01 22:26 ` Ashish Agarwal
[not found] ` <CAJ_epFM9s64QY88MxPW2apF9wgnXTQiJgns9w_dTtVKyvxsGeA@mail.gmail.com>
1 sibling, 1 reply; 8+ messages in thread
From: Daniel Bünzli @ 2015-10-01 22:23 UTC (permalink / raw)
To: Ashish Agarwal; +Cc: Haoyang Wang, Caml List
Le jeudi, 1 octobre 2015 à 23:06, Ashish Agarwal a écrit :
> Embarrassing.
Not really, since you are allowed to write
type t = [ s | `C ]
Daniel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] type synonym for polymorphic variant
2015-10-01 22:23 ` Daniel Bünzli
@ 2015-10-01 22:26 ` Ashish Agarwal
0 siblings, 0 replies; 8+ messages in thread
From: Ashish Agarwal @ 2015-10-01 22:26 UTC (permalink / raw)
To: Daniel Bünzli; +Cc: Haoyang Wang, Caml List
[-- Attachment #1: Type: text/plain, Size: 456 bytes --]
On Thu, Oct 1, 2015 at 6:23 PM, Daniel Bünzli <daniel.buenzli@erratique.ch>
wrote:
> Le jeudi, 1 octobre 2015 à 23:06, Ashish Agarwal a écrit :
> > Embarrassing.
>
> Not really, since you are allowed to write
>
> type t = [ s | `C ]
>
Right, that's the whole reason my brain got stuck thinking the brackets
need to be there. This is some auto-generated code, and sometimes I do
extend the type, so the brackets were always being put in.
[-- Attachment #2: Type: text/html, Size: 785 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <CAJ_epFM9s64QY88MxPW2apF9wgnXTQiJgns9w_dTtVKyvxsGeA@mail.gmail.com>]
* Re: [Caml-list] type synonym for polymorphic variant
[not found] ` <CAJ_epFM9s64QY88MxPW2apF9wgnXTQiJgns9w_dTtVKyvxsGeA@mail.gmail.com>
@ 2015-10-01 22:28 ` Ashish Agarwal
2015-10-01 22:35 ` Daniel Bünzli
0 siblings, 1 reply; 8+ messages in thread
From: Ashish Agarwal @ 2015-10-01 22:28 UTC (permalink / raw)
To: Thomas Refis; +Cc: Haoyang Wang, Caml List
[-- Attachment #1: Type: text/plain, Size: 835 bytes --]
On Thu, Oct 1, 2015 at 6:20 PM, Thomas Refis <thomas.refis@gmail.com> wrote:
> Note the you could also do "type t = [ | s ]"
>
Actually I had tried that, but it doesn't work.
>
> 2015-10-01 18:06 GMT-04:00 Ashish Agarwal <agarwal1975@gmail.com>:
> > Embarrassing. I don't know why I thought I had to put brackets... Thanks!
> >
> > On Thu, Oct 1, 2015 at 5:47 PM, Haoyang Wang <hywang@pobox.com> wrote:
> >>
> >> > On Oct 1, 2015, at 2:41 PM, Ashish Agarwal <agarwal1975@gmail.com>
> >> > wrote:
> >> >
> >> > type s = [`A | `B]
> >> > type t = [s]
> >>
> >> type t = s
> >>
> >> --
> >> Caml-list mailing list. Subscription management and archives:
> >> https://sympa.inria.fr/sympa/arc/caml-list
> >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> >> Bug reports: http://caml.inria.fr/bin/caml-bugs
> >
> >
>
[-- Attachment #2: Type: text/html, Size: 1949 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] type synonym for polymorphic variant
2015-10-01 22:28 ` Ashish Agarwal
@ 2015-10-01 22:35 ` Daniel Bünzli
2015-10-01 22:41 ` Ashish Agarwal
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Bünzli @ 2015-10-01 22:35 UTC (permalink / raw)
To: Ashish Agarwal; +Cc: Thomas Refis, Haoyang Wang, Caml List
Le jeudi, 1 octobre 2015 à 23:28, Ashish Agarwal a écrit :
> On Thu, Oct 1, 2015 at 6:20 PM, Thomas Refis <thomas.refis@gmail.com (mailto:thomas.refis@gmail.com)> wrote:
> > Note the you could also do "type t = [ | s ]"
>
> Actually I had tried that, but it doesn't work.
It does here (4.02.3).
Daniel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] type synonym for polymorphic variant
2015-10-01 22:35 ` Daniel Bünzli
@ 2015-10-01 22:41 ` Ashish Agarwal
0 siblings, 0 replies; 8+ messages in thread
From: Ashish Agarwal @ 2015-10-01 22:41 UTC (permalink / raw)
To: Daniel Bünzli; +Cc: Thomas Refis, Haoyang Wang, Caml List
[-- Attachment #1: Type: text/plain, Size: 522 bytes --]
Oh I see it is whitespace sensitive:
"type t = [|s]" fails
"type t = [ |s]" works
On Thu, Oct 1, 2015 at 6:35 PM, Daniel Bünzli <daniel.buenzli@erratique.ch>
wrote:
> Le jeudi, 1 octobre 2015 à 23:28, Ashish Agarwal a écrit :
> > On Thu, Oct 1, 2015 at 6:20 PM, Thomas Refis <thomas.refis@gmail.com
> (mailto:thomas.refis@gmail.com)> wrote:
> > > Note the you could also do "type t = [ | s ]"
> >
> > Actually I had tried that, but it doesn't work.
>
> It does here (4.02.3).
>
> Daniel
>
>
>
[-- Attachment #2: Type: text/html, Size: 1105 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-10-01 22:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-01 21:41 [Caml-list] type synonym for polymorphic variant Ashish Agarwal
2015-10-01 21:47 ` Haoyang Wang
2015-10-01 22:06 ` Ashish Agarwal
2015-10-01 22:23 ` Daniel Bünzli
2015-10-01 22:26 ` Ashish Agarwal
[not found] ` <CAJ_epFM9s64QY88MxPW2apF9wgnXTQiJgns9w_dTtVKyvxsGeA@mail.gmail.com>
2015-10-01 22:28 ` Ashish Agarwal
2015-10-01 22:35 ` Daniel Bünzli
2015-10-01 22:41 ` Ashish Agarwal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox