Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Generic generic types.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] Generic generic types.
> Haskell support types like
> 
> data Refal_atom agregat = RefalChar Char
>                         | RefalInt Int
>                         | RefalTerm (agregat (Refal_atom agregat))

These are called higher-order type constructors: Refal_atom is
parameterized not by a simple type, but by a type constructor (a function
from types to types).

> Do OCaml support similar type?

Not in the core language, but you can achieve similar effect with functors:

module M(A: sig type 'a agregat end) =
  struct
    type refal_atom =
      Char of char
    | Int of int
    | Term of refal_atom A.agregat
  end

Hope this answers your question,

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners