[Haskell-cafe] How to spot Monads, Applicatives ...

martin martin.drautzburg at web.de
Fri Jun 17 19:04:54 UTC 2016


Am 06/15/2016 um 07:10 PM schrieb Albert Y. C. Lai:
> On 2016-06-15 11:54 AM, martin wrote:
>> Paticularly I am having difficulties with the *->* instances. E.g. why is the state "s" in the state monad the fixed
>> type and the "a" the type parameter? When I am writing state code without the State monad the two look like equal
>> candidates. Why not have "State a" monad, which threads an a-typed value and spits out states?
> 
> You mean like this?
> 
> newtype MyState a s = Mk {unMk :: a -> (s, a)}

No, I meant

newtype MyState a s = Mk {unMk :: s -> (s, a)}




More information about the Haskell-Cafe mailing list