summaryrefslogtreecommitdiff
path: root/Hero/Keep.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Hero/Keep.hs')
-rw-r--r--Hero/Keep.hs40
1 files changed, 20 insertions, 20 deletions
diff --git a/Hero/Keep.hs b/Hero/Keep.hs
index 72bd6c2..744313b 100644
--- a/Hero/Keep.hs
+++ b/Hero/Keep.hs
@@ -16,11 +16,11 @@ module Hero.Keep
where
import Alpha
-import qualified Data.Acid as Acid
import Data.Acid (Update, makeAcidic)
+import qualified Data.Acid as Acid
import Data.Data (Data, Typeable)
-import qualified Data.IxSet as IxSet
import Data.IxSet (Indexable (..), IxSet, ixFun, ixSet)
+import qualified Data.IxSet as IxSet
import Data.SafeCopy (base, deriveSafeCopy)
import qualified Data.Text as Text
import Hero.Core
@@ -28,11 +28,10 @@ import Hero.Core
-- * Keep
-- | Main database.
-data HeroKeep
- = HeroKeep
- { _comics :: (IxSet Comic),
- _users :: (IxSet User)
- }
+data HeroKeep = HeroKeep
+ { _comics :: IxSet Comic,
+ _users :: IxSet User
+ }
deriving (Data, Typeable)
$(deriveSafeCopy 0 'base ''HeroKeep)
@@ -48,25 +47,25 @@ $(deriveSafeCopy 0 'base ''ComicId)
instance Indexable Comic where
empty =
ixSet
- [ ixFun $ \c -> [comicId c],
- ixFun $ \c -> [comicPages c],
- ixFun $ \c -> [comicName c],
- ixFun $ \c -> [comicIssue c],
- ixFun $ \c -> [comicDescription c]
+ [ ixFun <| \c -> [comicId c],
+ ixFun <| \c -> [comicPages c],
+ ixFun <| \c -> [comicName c],
+ ixFun <| \c -> [comicIssue c],
+ ixFun <| \c -> [comicDescription c]
]
instance Indexable User where
empty =
ixSet
- [ ixFun $ \u -> [userEmail u],
- ixFun $ \u -> [userName u],
- ixFun $ \u -> [userLibrary u]
+ [ ixFun <| \u -> [userEmail u],
+ ixFun <| \u -> [userName u],
+ ixFun <| \u -> [userLibrary u]
]
newComic :: Comic -> Update HeroKeep Comic
newComic c = do
keep <- get
- put $ keep {_comics = IxSet.insert c (_comics keep)}
+ put <| keep {_comics = IxSet.insert c (_comics keep)}
return c
getComics :: Int -> Acid.Query HeroKeep [Comic]
@@ -80,10 +79,11 @@ initialHeroKeep :: HeroKeep
initialHeroKeep =
HeroKeep
{ _comics = IxSet.fromList [theRed],
- _users = IxSet.fromList
- [ User "a" "micheal" [],
- User "b" "ben" []
- ]
+ _users =
+ IxSet.fromList
+ [ User "a" "micheal" [],
+ User "b" "ben" []
+ ]
}
where
theRed =