Community
Modules 26

Semigroupoids.Do

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.

{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE QualifiedDo #-}

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

fmap :: (a -> b) -> f a -> f b

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

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

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

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

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

join :: m (m a) -> m a

fail :: (Plus m) => String -> m a

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.

Build record and source files

Community contribution. The service has not verified this documentation.

Target: Linux on x86-64. Some inferred types and resolved links are not available.

Generator: aihc-haddock-858b1951-web-1

Metadata snapshot: 4ac4693dc44e2bb370a93502d1bf29784374032a00ad7b3d02803e3d433c0b16

Open the dependency plan · Download the documentation model

Import a package

Enter a package name and an exact version from Hackage. The site contains imported versions only.