I am looking for something with a type signature like this:

grabAcidState :: AcidState as -> IO as

basically I just want to return my data from database abstractly or based
on a class.

The reason for this is because I want to have a class instance of state and
then I can implement my library like so:

data MyCoolData :: MyCoolData T.Text

class HasCoolData a where
     getCoolDataList :: a -> MyCoolData

grabStoredList :: HasCoolData as => AcidState as -> IO [MyCoolData]
grabStoredList as = do
    cs <- grabAcidState as
    return $ getCoolDataList cs

and users could implement it like so:

data AppState = AppState {
    someCoolData :: [MyCoolData]
}

instance HasCoolData AppState {
    getCoolDataList = someCoolData
}

However trying to implement this simple behavior has been proving quite
difficult. Maybe I am making this too difficult and I should just have a
seperate AcidState datatype for my library.

Any help would be appreciated.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to