I'm getting a <<loop>> Exception for my State Monad instance and I suppose this refers to an infinite loop, however I don't see how my code could lead to one upon use:
instance Monad (State' s) where
-- return :: a -> State' s a
return x = State' (\(s,c) -> (x, s, (c <> oneReturn) ))
-- (>>=) :: State' s a -> (a -> State' s b) -> State' s b
st >>= k = State' $ \(s,c) -> let (a, s', c) = runState' st (s,c)
in runState' (k a) (s',(c <> oneBind) )
instance MonadState (State' s) s where
-- get :: State' s s
get = State' $ \(s,c) -> (s,s, (c <> oneGet))
-- put :: s -> State' s ()
put s = State' $ \(_,c) -> ((),s, (c <> onePut))
If anyone has a clue and could help me out it's much appreciated!
Best regards, Skyfe.
EDIT: For reference the one<SomeMonadicFunc> are for increasing the counter properly when bound with a current Counts value -
oneBind = Counts 1 0 0 0
oneReturn = Counts 0 1 0 0
oneGet = Counts 0 0 1 0
onePut = Counts 0 0 0 1