semigroupoids-5.3.7: Semigroupoids: Category sans id
Safe Haskell Safe
Language Haskell2010

Semigroupoids.Do

Description

This module re-exports operators from Data.Functor.Apply and Data.Functor.Bind , but under the same names as their Applicative and Monad counterparts. This makes it convenient to use do-notation on a type that is a Bind but not a monad (or an Apply but not an Applicative with ApplicativeDo ), either using the QualifiedDo extension or the more traditional RebindableSyntax .



foo :: Apply f => f a -> f b -> f (a, b)
foo as bs = Semi.do
  a <- as
  b <- bs
  pure (a, b)


bar :: Bind m => (a -> b -> m c) -> m a -> m b -> m c
bar f as bs = Semi.do
  a <- as
  b <- bs
  f a b
Synopsis

Documentation

fmap :: Functor f => (a -> b) -> f a -> f b Source #

Using ApplicativeDo : ' fmap f as ' can be understood as the do expression

do a <- as
   pure (f a)

with an inferred Functor constraint.

(<*) :: Apply f => f a -> f b -> f a Source #

Since: 5.3.6

(*>) :: Apply f => f a -> f b -> f b Source #

Since: 5.3.6

(<*>) :: Apply f => f (a -> b) -> f a -> f b Source #

Since: 5.3.6

(>>) :: Bind m => m a -> m b -> m b Source #

Since: 5.3.6

(>>=) :: Bind m => m a -> (a -> m b) -> m b Source #

Since: 5.3.6

join :: Bind m => m (m a) -> m a Source #

pure :: Applicative f => a -> f a Source #

Lift a value.

return :: Monad m => a -> m a Source #

Inject a value into the monadic type.

fail :: Plus m => String -> m a Source #

Important note

This ignores whatever String you give it. It is a bad idea to use fail as a form of labelled error; instead, it should only be defaulted to when a pattern match fails.

Since: 5.3.6