Skip to content

Instantly share code, notes, and snippets.

@haitlahcen
Last active March 20, 2019 08:55
Show Gist options
  • Select an option

  • Save haitlahcen/8bc0a132c633c9f28fde9952a08a6fa9 to your computer and use it in GitHub Desktop.

Select an option

Save haitlahcen/8bc0a132c633c9f28fde9952a08a6fa9 to your computer and use it in GitHub Desktop.

App

(>>=) :: m a -> (a -> m b) -> m b
(<$>) :: (a -> b) -> f a -> f b

Very hard to understand that both functions are similar in their essence.

(=<<) :: (a -> m b) -> m a -> m b
(<$>) :: (a ->   b) -> f a -> f b
($)   :: (a ->   b) ->   a ->   b

We naturally find that the only difference between thoses functions is the extra effect. Removing the effects would obviously lead to (=<<) = (<$>) = ($)

This property mean that I could replace all (=<<) and (<$>) with ($) if I remove the extra effects from the involved functions, with my code still typechecking.

Comp

(<=<) :: (b -> m c) -> (a -> m b) -> a -> m c
.     :: (b ->   c) -> (a ->   b) -> a ->   c

The same pattern arise with kleisli composition. The only difference being again the extra effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment