Oops [Fwd: Re: Allowing duplicate instances in GHC 6.4]

Keean Schupke k.schupke at imperial.ac.uk
Thu Mar 31 10:34:49 EST 2005

Not at all... You can have Datasource s k v | s k -> v ... but I have't 
time to do it now...

By the way that wasn't the change I was talking about!

class Datasource' z l r k v | z l r k -> v
The 'z' was missing from your fundep.


Robert van Herk wrote:

>> See change above!
>> Also note type of fundep for Datasource should now be:
>> class Datasource s k v | s -> k v where ...
> I see.... But the cool thing was, that my datasources were generic, in 
> the sence that they could store multiple k's and v's. Now, they would 
> be unique for the actual storage mechanism used, meaning, for example, 
> that I could only read values from 1 table, if I'd instantiate the 
> datasource for a database coupling.
> Currently, I use the Boilerplate approach to make it possible to store 
> multiple types in one datasource, for example:
> data MyKeyVal = IntXString Int String
>             | FloatXInt  Float Int
>             deriving (Eq, Ord, Show)
> Furthermore, I generate an instance of KeyHasValue, to tell my 
> framework which keys are valid for a datasource, for example:
> instance KeyHasValue MyKeyVal Int String where
> constructor = IntXString
> instance KeyHasValue MyKeyVal Float Int where
> constructor = FloatXInt
> I have an instance
> instance (..., KeyHasValue a k v) =>
> Datasource [a] k v where ...
> This way, I can read Ints from a [MyKeyVal], and get a String, and 
> read Floats, and get an Int. If I would have a fundep
> class Datasource s k v | s -> k v where ...
> this wouldn't be possible anymore, I guess?
> Regards,
> Robert
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

More information about the Glasgow-haskell-users mailing list