ocaml - The type constructor is not yet completely defined -
here's simplified code :
type t1 = [ `a of t2] , t2 = [ `b | t1 ]
i know in case don't need "and" because types don't need mutual definition, in real world need it. why doesn't work ? can make work doing
and t2 = [`b | `c of t1]
but lose interest of polymorphic variants , i'll switch normal variants.
is there way can ?
in definition of t2 trying "extend" type t1 not defined @ point (as requre t2 in `a branch).
if want "emulate" recursive ordinary data types (but using polymorphic variants instead) should use references mutually-recursive types under data constructor.
example in case may this:
type t1 = [ `a of t2 ] , t2 = [ `b | `c of t1 ]
note in ocaml construction [ `b | t1 ] not mean extending polymorphic row row - type synonym substitution.
Comments
Post a Comment