This may be a dumb question, but why can we not declare a Monad
instance of a type synonym? This question came to me while working
with the State monad recently and feeling that the requirement that we
wrap our functions in the State constructor is a bit... kludgy.

Why can't the State monad be defined this way?:

>    type State s a = \s -> (a , s)
>
>    instance Monad (State s) where
>        return a = \s -> (a, s)
>        m >>= k  = \s -> let
>            (a, s') = m s
>            in k a s'

It seems like Haskell's type system could understand the above, but
I'm interested in hearing the technical reason which I'm sure exists
for why we can't do this.

Thanks for any clues,
Brandon Simmons
http://coder.bsimmons.name/blog/
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to