Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 1.28 KB

FUNCTORS.md

File metadata and controls

40 lines (30 loc) · 1.28 KB

From fantasy-land

map :: Functor f => f a ~> (a -> b) -> f b

ap :: Apply f => f a ~> f (a -> b) -> f b

of :: Applicative f => a -> f a

  Array.of = x => [x]
  Either.of = x => Right(x)
  Function.of = x => _ => x
  Maybe.of = x => Just(x)
  Task.of = x => new Task((_, res) => res(x))

chain :: Chain m => m a ~> (a -> m b) -> m b

Comparison

Language Library Functor Apply Applicative Chain
Haskel <$> fmap <*> pure
JavaScript ramda-fantasy map ap of chain
Ruby map flat_map
Ruby dry-monads fmap pure bind
Ruby kleisli fmap * >
Ruby ramda-ruby map ap chain