Haskell State monad with tuples as state -
my apologies if question stupid (i'm still quite new monads), couldn't find answer far.
i want store pairs state in state monad. however, if try on simple example of (int, int) (ghci):
prelude> import control.monad.state prelude control.monad.state> :t :: state int int :: state int int :: state int int prelude control.monad.state> :t :: state (int, int) int <interactive>:1:1: no instance (monadstate int (statet (int, int) data.functor.identity.identity)) arising use of ‘get’ in expression: :: state (int, int) int
my questions are:
1. why?
2. how work?
the type of get
is
get :: state s s
so if s = (int, int)
want
get :: state (int, int) (int, int)
that's all. get
returns entire tuple.
Comments
Post a Comment