Created
January 13, 2014 12:31
-
-
Save reite/8399494 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TemplateHaskell, DeriveDataTypeable #-} | |
import Data.Acid | |
import Data.SafeCopy | |
import Data.Typeable | |
import Control.Monad.State (get, put) | |
data Foo = Foo String | |
deriving (Typeable) | |
data Bar = Bar String | |
deriving (Typeable) | |
data Container = Container { | |
foo :: Foo, | |
bar :: Bar | |
} | |
$(deriveSafeCopy 0 'base ''Foo) | |
$(deriveSafeCopy 0 'base ''Bar) | |
$(deriveSafeCopy 0 'base ''Container) | |
class InContainer a where | |
updateContainer :: a -> Update Container () | |
instance InContainer Foo where | |
updateContainer v = do | |
state <- get | |
put $ state { foo = v } | |
instance InContainer Bar where | |
updateContainer v = do | |
state <- get | |
put $ state { bar = v } | |
$(makeAcidic ''Container ['updateContainer]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiling gives this error: