foralls in class assertions
Simon Peyton-Jones
simonpj@microsoft.com
Wed, 20 Feb 2002 13:15:37 -0800
OK, so it does look as though it's the same idea as=20
that described in our paper. Good.
I have not implemented, yet. As always my implementation
priorities are strongly influenced by my perception of whether
some enhancement would be used. Maybe you can outline
why such a change would be useful to you? I only have the
example in our paper as motivation so far.
Simon
| -----Original Message-----
| From: Ashley Yakeley [mailto:ashley@semantic.org]=20
| Sent: 20 February 2002 01:08
| To: Simon Peyton-Jones; Haskell List
| Subject: RE: foralls in class assertions
|=20
|=20
| At 2002-02-19 09:21, Simon Peyton-Jones wrote:
|=20
| >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.
|=20
| Hmm... it should be straightforward...
|=20
| > instance (forall a. Eq a =3D> Eq (f a)) =3D> Eq (Rose f a) where..
|=20
| I assume that the 'a' quantified in (forall a. ...) is not=20
| the same as=20
| the 'a' in 'Rose f a'?
|=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
| This means 'if for all a, "HasIdentity (m a a)", and also for=20
| all a b c,=20
| "Composable (m b c) (m a b) (m a c)", then "Category m"'.
|=20
| "(forall a. HasIdentity (m a a))" as a class assertion declares a=20
| property of m. It says that for all types a, there's an instance=20
| "HasIdentity (m a a)".
|=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
| This means foo has type (T b c), where for every type a for=20
| which there's=20
| an instance "C a b", there's an instance "D a c".
|=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
| Personally I think the 'superclass' arrow in class=20
| declarations should=20
| point the other way, as in '<=3D'. After all, instances of the=20
| class imply=20
| instances of the superclasses, not the other way around.
|=20
| But that aside, this means '"Category" is a class on m,=20
| provided that for=20
| all types a, there's an instance "HasIdentity (m a a)", and=20
| also for all=20
| types a b c, there's an instance "Composable (m b c) (m a b)=20
| (m a c)"'.
|=20
|=20
| --=20
| Ashley Yakeley, Seattle WA
|=20
| _______________________________________________
| Haskell mailing list
| Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
|=20