blob: 575e82d056c5781304012f16cd2e8bc7db2bd923 (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
module Mem where
newtype Mem s a =
Mem {
runMem :: s -> (a,s)
}
instance Monoid a => Monoid (Mem s a) where
mempty = Mem $ \x -> (mempty, x)
mappend (Mem f1) (Mem f2) = Mem f
where f x = ((mappend (fst $ f1 x) (fst $ f2 x)), snd $ f2 $ snd $ f1 x)
|