Skip to content

Instantly share code, notes, and snippets.

@TheSeamau5
Created August 26, 2015 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheSeamau5/849a5d169dc10b662a98 to your computer and use it in GitHub Desktop.
Save TheSeamau5/849a5d169dc10b662a98 to your computer and use it in GitHub Desktop.
type alias Function a b = a -> b
const : b -> Function a b
const b _ = b
compose : Function a b -> Function b c -> Function a c
compose =
(>>)
map : (a -> b) -> Function x a -> Function x b
map =
(<<)
contramap : (b -> a) -> Function a x -> Function b x
contramap =
(>>)
map2 : (a -> b -> c) -> Function x a -> Function x b -> Function x c
map2 f xa xb x =
f (xa x) (xb x)
andMap : Function x (a -> b) -> Function x a -> Function x b
andMap =
map2 (<|)
flatten : Function x (Function x a) -> Function x a
flatten f x =
(f x) x
flatMap : (a -> Function x b) -> Function x a -> Function x b
flatMap f =
map f >> flatten
andThen : Function x a -> (a -> Function x b) -> Function x b
andThen =
flip flatMap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment