[Haskell-cafe] Default query for AcidState?
Kyle Hanson
hanooter at gmail.com
Mon Aug 12 20:38:41 CEST 2013
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130812/d5d4cd51/attachment.htm>
More information about the Haskell-Cafe
mailing list