'Convertible' class?

Hannah Schroeter uk1o@rz.uni-karlsruhe.de
Thu, 8 Feb 2001 00:40:26 +0100


On Wed, Feb 07, 2001 at 05:43:40PM -0500, Dylan Thurston wrote:
> [...]

> > class Subtype a b where {- a is subtype of b, if following operations exist -}
> > 	inject :: a -> b
> > 	project :: b -> Maybe a

> Shouldn't this be a subclass?  'project' is not always easy or
> possible to define.

Good question.

The term subclass is, however, not according to Haskell's type system.

class Subtype a b where
	inject :: a -> b

class Subtype a b => ProjectableSubtype a b where
	project :: b -> Maybe a

(or can someone imaging a constellation where project makes sense
but inject does not? In that case, the two classes should be
completely independent instead)

Kind regards,