Skip to content

Instantly share code, notes, and snippets.

@reite
Created January 13, 2014 12:31
Show Gist options
  • Save reite/8399494 to your computer and use it in GitHub Desktop.
Save reite/8399494 to your computer and use it in GitHub Desktop.
{-# 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])
@reite
Copy link
Author

reite commented Jan 13, 2014

Compiling gives this error:

typeclass.hs:1:1:
    Exception when trying to run compile-time code:
      Events must be functions: Main.updateContainer
      Code: makeAcidic ''Container ['updateContainer]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment