
On Sat, Jun 7, 2008 at 1:08 PM, Luke Palmer
2008/6/7 Dmitri O.Kondratiev
: class Store s where put :: Eq k => (k, v) -> s -> s get :: k s -> Maybe v
I suspect you want this to be a constructor class. That is, you want to make explicit the fact that the type s depends on k and v.
class Store s where put :: Eq k => (k,v) -> s k v -> s k v get :: s k v -> Maybe v
Oops. Should be: get :: k -> s k v -> Maybe v And correspondingly for the later examples. After actually using my brain thinking about your problem, and reading the word "Newbie", I would absolutely stay away from the fundeps/associated types business. :-) Try to get this working with Cell and CellList first :-) Luke
If instead you have cell types which are restricted in what they can store in different ways, you might explore fundeps or associated types:
-- fundeps class Store s k v | s -> k v where put :: (k,v) -> s -> s get :: s -> Maybe v
-- associated types class Store s where type Key s :: * type Value s :: * put :: (Key s, Value s) -> s -> s get :: s -> Maybe (Value s)
But if you can get away with the former, I would recommend that before looking into these advanced extensions.
Luke