[Haskell-cafe] [Haskell] A puzzle and an annoying feature

Keean Schupke k.schupke at imperial.ac.uk
Fri Nov 26 04:04:52 EST 2004


Martin Sulzmann wrote:

>Well, if there's only instance which is not exported, then you can
>use functional dependencies.
>
>Assume
>
>class C a
>instance ... => C t
>
>Internally, use
>
>class C a | -> a
>instance ... => C t
>  
>
The cases I was looking at had more than one instance, but thats
cool! (I didn't realise " -> a" was valid syntax without a LHS for the 
arrow.
Oleg has written quite a bit about using fundeps to close classes. Surely
you can export this as well - any attempt to add another instance will
conflict with the fundep (-> a) which effectively says there can only be
one instance as all the LHS will overlap (all being the empty set)?

> 
>
>Furthermore, there seems to be an issue that has been overlooked so far.
>
>- Providing sufficient type annotations
>
>
>  
>
Well in the toy example, yes... but quite often this occurs where the
type is derived and extreemly complex - the whole point is you don't
really want to be type annotating every assignment. Also you may
really want polymorphism, you just have only one instance at the moment.
(duing development, or in a user extensible library)

    Keean.


More information about the Haskell-Cafe mailing list