-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Labels
Hello-WorldSomething related to the Hello World folder in this repoSomething related to the Hello World folder in this repoenhancementNew feature or requestNew feature or request
Description
Bind
enables one to compose functions of the type signature a -> m b
. This is done via bind
/>>=
. The composition is >=>
:
f :: Int -> Maybe String
g :: String -> Maybe String
h :: String -> Maybe Foo
-- composition enabled despite the function "output"
-- being wrapped in a `Maybe`
f >=> g >=> h
Extend
enables a similar composition. Rather than composing functions of the type a -> m b
, it composes functions of the type m a -> b
. This is done via extend
/<<=
. The composition is =>=
:
f :: Maybe Int -> String
g :: Maybe String -> String
h :: Maybe String -> Foo
-- composition enabled despite the function "input"
-- being wrapped in a `Maybe`.
f =>= h =>= g
-- Note: I'm not sure whether the above order is correct
-- it might be `g =>= h =>= f`
Whereas Applicative
's pure
puts a value into a "box", so that one can use bind
to continue to compose functions, Comonad
's extract
takes a value out of a "box, so that one can use extend
to continue to compose functions.
Metadata
Metadata
Assignees
Labels
Hello-WorldSomething related to the Hello World folder in this repoSomething related to the Hello World folder in this repoenhancementNew feature or requestNew feature or request