Haskell nun State s amakes me maintain the same type sthroughout the do block. But since the state monad is really a function, what if I define it as State i o a = State (i -> (o, a))?. Functions returnand bindlook exactly the same as in the standard state monad, but with changed types:
return :: a -> State st st a
bind :: (State i o a) -> (a -> (State o o' b)) -> (State i o' b)
I do not consider it possible to implement Monadin Haskell using this definition because it expects a single type State i oin bind (it acan only change). But this question is not about Haskell, but about whether it will technically be a monad or not. Or, if not, will it be some kind of superset of the monad (so that all the laws of the monad are still applicable, but have some additional features)?
This is what I found would be useful in another language I'm working on, which is based on lambda calculus, so I use Haskell as a reference. I just don't want this to break other things later when I expected monad laws to apply.
source
share