* [Caml-list] difference between locally abstract types and polymorphic annotations?
@ 2016-08-14 23:22 Alexey Egorov
2016-08-15 7:26 ` Jacques Garrigue
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Egorov @ 2016-08-14 23:22 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 368 bytes --]
Hello,
I'm noticed that GADT typechecking depends on whether free variables are annotated as locally abstract types (in form of "type a b c . <typeexpr>") or just polymoprhic annotations (in form of " 'a 'b 'c . <typeexpr> ").
Code here - http://pastebin.com/36ZAjw0J
What is the difference? I was thinking that both of this are equivalent, isn't it?
Thanks.
[-- Attachment #2: Type: text/html, Size: 781 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] difference between locally abstract types and polymorphic annotations?
2016-08-14 23:22 [Caml-list] difference between locally abstract types and polymorphic annotations? Alexey Egorov
@ 2016-08-15 7:26 ` Jacques Garrigue
0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2016-08-15 7:26 UTC (permalink / raw)
To: Alexey Egorov; +Cc: OCaML List Mailing
On 2016/08/15 08:22, Alexey Egorov wrote:
>
> Hello,
>
> I'm noticed that GADT typechecking depends on whether free variables are annotated as locally abstract types (in form of "type a b c . <typeexpr>") or just polymoprhic annotations (in form of " 'a 'b 'c . <typeexpr> ").
>
> Code here - http://pastebin.com/36ZAjw0J
>
> What is the difference? I was thinking that both of this are equivalent, isn't it?
>
> Thanks.
They are not equivalent.
Polymorphic annotations are about checking, a posteriori, that some types are indeed polymorphic,
and also about allowing polymorphic recursion.
Locally abstract types are about creating an abstract type and using it locally. It will be turned into a type variable when you leave the scope. Only abstract types can be refined by GADT pattern matching, not type variables.
Using GADTs, you often want both refinement and polymorphic recursion, this is why “type a b c. <typeexp>” is actually a combination of the two.
Jacques
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-15 7:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-14 23:22 [Caml-list] difference between locally abstract types and polymorphic annotations? Alexey Egorov
2016-08-15 7:26 ` Jacques Garrigue
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox