> 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