
Hello, I read the type families example at http://haskell.org/haskellwiki/GHC/Indexed_types and I wanted to do something similar to the Collects example, but using a type of kind * -> *:
class StateFunctor sf where type SFMonad sf type SFValue sf sfmap :: (SFValue sf -> SFValue sf) -> sf -> SFMonad sf ()
I wrote the instance as:
instance StateFunctor (ListStore a) where type SFMonad (ListStore a) = IO type SFValue (ListStore a) = a sfmap function listStore = listStoreGetSize listStore >>= listStoreSfmap function listStore
listStoreSfmap :: (a -> a) -> ListStore a -> Int -> IO () listStoreSfmap _function _listStore 0 = [] listStoreSfmap function listStore size = listStoreGetValue listStore index >>= listStoreSetValue listStore index . function
listStoreSfmap function listStore index where index :: Int index = pred size
I'm getting: DistroCreator/GUI/List.hs:51:47: Kind error: `SFMonad' is applied to too many type arguments In the type `SFMonad sf ()' In the type `sf -> SFMonad sf ()' In the type `(SFValue sf -> SFValue sf) -> sf -> SFMonad sf ()' Failed, modules loaded: none. How can I use type families with types * -> *? Greetings. -- marcot http://marcot.iaaeee.org/