Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2003-02-04 (09:53)
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) =
    type refal_atom =
      Char of char
    | Int of int
    | Term of refal_atom A.agregat

Hope this answers your question,

- Xavier Leroy
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: