1 module ShouldSucceed where
3 data State c a = State (c -> (a,c))
5 unState :: State c a -> (c -> (a,c))
8 unitState :: a -> State c a
9 unitState a = State (\s0 -> (a,s0))
11 bindState :: State c a -> (a -> State c b) -> State c b
12 bindState m k = State (\s0 -> let (a,s1) = (unState m) s0
13 (b,s2) = (unState (k a)) s1
16 instance Eq c => Monad (State c) where
20 data TS = TS { vs::Int } deriving (Show,Eq)
22 type St a = State TS a
24 foo :: Int -> St Int -- it works if this line is not given