* [Caml-list] Generic generic types.
@ 2003-02-03 15:26 Mike Potanin
2003-02-04 9:49 ` Xavier Leroy
0 siblings, 1 reply; 3+ messages in thread
From: Mike Potanin @ 2003-02-03 15:26 UTC (permalink / raw)
To: caml-list
Haskell support types like
data Refal_atom agregat = RefalChar Char
| RefalInt Int
| RefalTerm (agregat (Refal_atom agregat))
Do OCaml support similar type?
type 'agregat refal_atom =
Char of char
| Int of int
| Term of (('agregate refal_atom) 'agregat);;
-------------------
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Generic generic types.
2003-02-03 15:26 [Caml-list] Generic generic types Mike Potanin
@ 2003-02-04 9:49 ` Xavier Leroy
2003-02-04 10:49 ` Mike Potanin
0 siblings, 1 reply; 3+ messages in thread
From: Xavier Leroy @ 2003-02-04 9:49 UTC (permalink / raw)
To: Mike Potanin; +Cc: caml-list
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Generic generic types.
2003-02-04 9:49 ` Xavier Leroy
@ 2003-02-04 10:49 ` Mike Potanin
0 siblings, 0 replies; 3+ messages in thread
From: Mike Potanin @ 2003-02-04 10:49 UTC (permalink / raw)
To: caml-list
On Tue, 4 Feb 2003, Xavier Leroy wrote:
> > 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,
Thank you! It's what I wanted.
>
> - 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-02-04 10:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-03 15:26 [Caml-list] Generic generic types Mike Potanin
2003-02-04 9:49 ` Xavier Leroy
2003-02-04 10:49 ` Mike Potanin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox