Distributivity: (f <|> g) <*> x = (f <*> x) <|> (g <*> x)
Let r ∷ Ref Int, f = delay 1.0, g = delay 2.0, x = modify (_ + 1) r
Then
(delay 1.0 <|> delay 2.0) <*> modify (_ + 1) r
= (delay 1.0 <*> modify (_ + 1) r) <|> (delay 2.0 <*> modify (_ + 1) r)
But, by duplicating the Ref.modify (_ + 1) r effect and running both in parallel, r is incremented by 2 rather than 1.
(Yes, I fudged some types here for brevity).
Distributivity:
(f <|> g) <*> x = (f <*> x) <|> (g <*> x)Let
r ∷ Ref Int,f = delay 1.0,g = delay 2.0,x = modify (_ + 1) rThen
But, by duplicating the
Ref.modify (_ + 1) reffect and running both in parallel,ris incremented by 2 rather than 1.(Yes, I fudged some types here for brevity).