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

Albert Y. C. Lai trebla at vex.net
Fri Jun 17 21:02:24 UTC 2016


On 2016-06-17 03:04 PM, martin wrote:
> 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)}

This seems to thread s and spit out a, the opposite of what you said. So 
much for natural language "intuitive" "conceptual" "meaningful" 
descriptions.

I can't write Functor, Applicative, Monad instances for it. Can you?


More information about the Haskell-Cafe mailing list