semigroupoids-do-1.0: Support for QualifiedDo with semigroupoids classes.
Copyright(C) Koz Ross 2021
LicenseApache 2.0
Maintainerkoz.ross@retro-freedom.nz
StabilityExperimental
PortabilityGHC only
Safe HaskellSafe-Inferred
LanguageHaskell2010

Semigroupoids.Do

Description

Provides definitions needed to use do-notation (by way of QualifiedDo) using the more general type classes provided by semigroupoids.

To use this module, enable QualifiedDo, import this module qualified, and then prefix do with the qualified name:

{-# LANGUAGE QualifiedDo #-}

module MyModule where

import Data.Functor.Bind (Bind)
import qualified Semigroupoids.Do as S

foo :: (Bind m) => m a
foo = S.do
 ...

This module is designed to work correctly (and similarly generally) with ApplicativeDo and RecursiveDo (inasfar as that is possible).

Synopsis

Documentation

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

Since: 1.0

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

Since: 1.0

fail :: forall (m :: Type -> Type) (a :: Type). 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: 1.0

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

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

do a <- as
   pure (f a)

with an inferred Functor constraint.

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

Since: 1.0

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

Since: 1.0

mfix :: MonadFix m => (a -> m a) -> m a #

The fixed point of a monadic computation. mfix f executes the action f only once, with the eventual output fed back as the input. Hence f should not be strict, for then mfix f would diverge.

return :: forall (f :: Type -> Type) (a :: Type). Applicative f => a -> f a Source #

Since: 1.0