post(typoclassopedia): better formatting

This commit is contained in:
Mahdi Dibaiee 2017-09-30 23:33:54 +03:30
parent de2eaafd0c
commit c4d343b3fd

View File

@ -322,12 +322,13 @@ pure f <*> x = pure (flip ($)) <*> x <*> pure f
**Solution**: **Solution**:
```haskell ```haskell
pure (flip ($)) <*> x <*> pure f = (pure (flip ($)) <*> x) <*> pure f -- <*> is left-associative pure (flip ($)) <*> x <*> pure f
pure (flip ($)) <*> x <*> pure f = pure ($ f) <*> (pure (flip ($)) <*> x) -- interchange = (pure (flip ($)) <*> x) <*> pure f -- <*> is left-associative
pure (flip ($)) <*> x <*> pure f = pure (.) <*> pure ($ f) <*> pure (flip ($)) <*> x -- composition = pure ($ f) <*> (pure (flip ($)) <*> x) -- interchange
pure (flip ($)) <*> x <*> pure f = pure (($ f) . (flip ($))) <*> x -- homomorphism = pure (.) <*> pure ($ f) <*> pure (flip ($)) <*> x -- composition
pure (flip ($)) <*> x <*> pure f = pure ((flip ($) f) . (flip ($))) <*> x -- identical = pure (($ f) . (flip ($))) <*> x -- homomorphism
pure (flip ($)) <*> x <*> pure f = pure f <*> x = pure ((flip ($) f) . (flip ($))) <*> x -- identical
= pure f <*> x
``` ```
Explanation of the last transformation: Explanation of the last transformation:
@ -344,3 +345,5 @@ You can check the type of `(flip ($) f) . (flip ($))` is something like this (de
λ: :t (flip ($) f) . (flip ($)) λ: :t (flip ($) f) . (flip ($))
(flip ($) f) . (flip ($)) :: Floating c => c -> c (flip ($) f) . (flip ($)) :: Floating c => c -> c
``` ```
Also see [this question on Stack Overflow](https://stackoverflow.com/questions/46503793/applicative-prove-pure-f-x-pure-flip-x-pure-f/46505868#46505868) which includes alternative proofs.