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] First order compile time functorial polymorphism in Ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ 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).

Markus Mottl

Markus Mottl

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