[Haskell-cafe] model theory for type classes

wren ng thornton wren at freegeek.org
Fri Aug 24 04:56:35 CEST 2012


On 8/23/12 1:02 PM, Patrick Browne wrote:
> I am just not sure whether there is a model expansion from the super-class model
> to the subclass model.

If by "model expansion from..." you mean that there is a 
canonical/unique/special mapping from every superclass model to some 
subclass model, then the answer is no.

Consider, for instance, applicative functors and monads. We have the 
(idealized) type classes:

     class Functor a where...
     class Functor a => Applicative a where...
     class Applicative a => Monad a where...

However, there are strictly more Applicative instances than there are 
Monad instances. E.g., lists support an Applicative instance based on 
zip and an Applicative instance based on the cartesian product; however, 
only the latter of these can be extended to a Monad.


Well, technically, that's only if we assume the appropriate laws are 
part of the theories defined by the type classes. Without this 
assumption every type class can be instantiated at every type (for every 
method f, define f = undefined).

-- 
Live well,
~wren



More information about the Haskell-Cafe mailing list