Hello all,

I have this class which gives a common interface to (UniqueIndex a k) and (MultiIndex a k) :

class (Show a, Key_ k) => Index_ i a k  | i -> k, k -> a where
   buildKey :: (a -> k)
   insertIndex :: Id -> a -> i -> Maybe i
   deleteIndex :: Id -> a -> i -> i
   updateIndex :: Id -> a -> a -> i -> Maybe i
updateIndex id oldItem newItem index = insertIndex id newItem $ deleteIndex id oldItem index


Now i need to have these indexes in a list, so i declared that type :

data DbIndex = forall a k i. (Show a, Key_ k, Index_ i a k) => DbIndex i

Up to this point everything is fine, I can create concrete Indexes and put these different index types in the same list, after wrapping them in a DbIndex.

But i don't seem to find a way to get out of this DbIndex type to actually work on the enclosed index.

for instance, this doesn't work:
liftDbIndex (DbIndex index) fun = DbIndex (fun index)

this doesn't work either :
dbIndexBuildKey (DbIndex index) value = (buildKey index) value

How can i access the enclosed concrete index, via its Index_ class ?
Maybe am I totally on the wrong track ?

Thanks in advance,
Sacha
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to