caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] problem to use gadt
@ 2015-02-15 13:35 Nicolas Boulay
  2015-02-15 14:44 ` David Allsopp
  2015-02-15 14:47 ` Gabriel Scherer
  0 siblings, 2 replies; 5+ messages in thread
From: Nicolas Boulay @ 2015-02-15 13:35 UTC (permalink / raw)
  To: OCaml Mailing List

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

I try to define my own type system using gadt. But it seems that is complex
to mix both type system : mine and the ocaml one.

This tiny example did not compile:

type _ t =
 | Or: _ t * _ t -> _ t
 | Int : int t
 | Float : float t

let a = Or (Int, Float)  (*is ok*)

let (||)  a b = Or (a, b)

let aa = Int || Float (*Error: '_a t, contains type variable that cannot be
generalized*)

Using an operator make a difference. But how to exprime "don't care" if a
choice between 2 types is not possible to be define.  It could be nice if
"('a | 'b) t" worked :) Should i use normal sum type, and make all type
check by a function ?

Nicolas Boulay

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-15 20:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-15 13:35 [Caml-list] problem to use gadt Nicolas Boulay
2015-02-15 14:44 ` David Allsopp
2015-02-15 20:16   ` Nicolas Boulay
2015-02-15 14:47 ` Gabriel Scherer
2015-02-15 20:17   ` Nicolas Boulay

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).