Browse thread
[Caml-list] First order compile time functorial polymorphism in Ocaml
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Markus Mottl <markus@o...> |
| Subject: | Re: [Caml-list] First order compile time functorial polymorphism in Ocaml |
On Mon, 23 Jun 2003, John Max Skaller wrote: > >For example consider: > > > >type 'a t = Foo 'a -> unit > > > >To map : 'a t -> 'b t here, you need f : 'b -> 'a. > > Ah, ok, exponential is contravariant. This problem (generalizing fold/unfold to exponentials that use the type constructor also in contravariant positions) is solved by applying a solution for modelling recursive datatypes as fixed points of difunctors. See the following very nice paper for details: Title: Bananas in space: extending fold and unfold to exponential types Authors: Erik Meijer and Graham Hutton What you need in your example is a cofunctor "f" together with a function "comap", which takes the functional (a -> b) to (f b -> f a). In the mixed case (co- and contravariant occurrences in the same type definition) you need difunctors (see paper for details). Regards, Markus Mottl -- Markus Mottl http://www.oefai.at/~markus markus@oefai.at ------------------- 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