I am trying to play with MonadState monad and especially with 'modify' function.
When I try
f :: (MonadState s m, Num s) => m ()
f = put 1
It works without any problems, but when I try to set State as String, Char or List I get this error:
• Non type-variable argument in the constraint: MonadState Char m
(Use FlexibleContexts to permit this)
• When checking the inferred type
a :: forall (m :: * -> *). MonadState Char m => m ()
The same happens for:
b = modify (1:)
• Non type-variable argument in the constraint: MonadState [a] m
(Use FlexibleContexts to permit this)
• When checking the inferred type
b :: forall a (m :: * -> *). (MonadState [a] m, Num a) => m ()
Thank you for your help.