[Haskell-fr] Fw: Éclaircissements sur les monades
Simon Marechal
simon at banquise.net
Sat May 24 19:01:21 UTC 2014
On 05/24/2014 08:49 PM, Gautier DI FOLCO wrote:
>
> J'ai tenté ça :
> runState (pure (-) <*> pure 4 <*> pure 2) 7
State f `ap1` State g = State $ \x -> let (a, b) = g x in let (c, d) = f
b in (c a, d)
State f `ap2` State g = State $ \x -> let (c, d) = f x in let (a, b) = g
d in (c a, b)
*Xxxx> runState (pure (,) `ap2` put 4 `ap2` put 7) 0
(((),()),7)
*Xxxx> runState (pure (,) `ap1` put 4 `ap1` put 7) 0
(((),()),4)
More information about the Haskell-fr
mailing list