foralls in class assertions

Simon Peyton-Jones simonpj@microsoft.com
Tue, 19 Feb 2002 09:21:58 -0800


I don't know if it makes sense.   You've written down some syntax,
but it's not clear to me what you intend by it.

The instance decls remind me somewhat of the generalisation described
towards the end of a paper Ralf Hinze and I wrote, "Generic type
classes".
There we describe why instance decls of the form
	instance (forall a. Eq a =3D> Eq (f a)) =3D> Eq (Rose f a) where..
might be useful.

Simon

| -----Original Message-----
| From: Ashley Yakeley [mailto:ashley@semantic.org]=20
| Sent: 16 February 2002 10:48
| To: Haskell List
| Subject: foralls in class assertions
|=20
|=20
| It would be nice to be able to put foralls in class assertions. For=20
| instance:
|=20
|     class HasIdentity a where
|         {
|         identity :: a;
|         };
|    =20
|     class Composable a b ab | a b -> ab where
|         {
|         compose :: a -> b -> ab;
|         };
|    =20
|     class
|         (
|         forall a. HasIdentity (m a a),
|         forall a b c. Composable (m b c) (m a b) (m a c)
|         ) =3D>
|      Category m;
|    =20
|     instance
|         (
|         forall a. HasIdentity (m a a),
|         forall a b c. Composable (m b c) (m a b) (m a c)
|         ) =3D>
|      Category m;
|=20
| Or even allow the foralls their own context:
|=20
|     foo :: (forall a. (C a b) =3D> D a c) =3D> T b c;
|=20
| Does this make sense? Would it have unpleasant consequences?
|=20
|=20
| --=20
| Ashley Yakeley, Seattle WA
|=20
| _______________________________________________
| Haskell mailing list
| Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
|=20