do-notation-0.1.0.2: Generalize do-notation to work on monads and indexed monads simultaneously.
Safe HaskellNone
LanguageHaskell2010

Language.Haskell.DoNotation

Description

This module provides new implementations for (>>=), (>>), pure and return so that they will work simultaneously with both regular and indexed monads.

Intended usage:

@@ {-# LANGUAGE RebindableSyntax #-}

import Language.Haskell.DoNotation import Prelude hiding (Monad (..), pure) @@

Synopsis

Documentation

class BindSyntax (x :: Type -> Type) (y :: Type -> Type) (z :: Type -> Type) | x y -> z, x z -> y, y z -> x where Source #

Typeclass that provides (>>=) and (>>).

Minimal complete definition

(>>=)

Methods

(>>=) :: x a -> (a -> y b) -> z b Source #

(>>) :: x a -> y b -> z b Source #

Instances

Instances details
(Monad m, x ~ m) => BindSyntax m x m Source # 
Instance details

Defined in Language.Haskell.DoNotation

Methods

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

(>>) :: m a -> x b -> m b Source #

(IxMonad m, x ~ m i j, y ~ m j k2, z ~ m i k2) => BindSyntax x y z Source # 
Instance details

Defined in Language.Haskell.DoNotation

Methods

(>>=) :: x a -> (a -> y b) -> z b Source #

(>>) :: x a -> y b -> z b Source #

class PureSyntax (x :: Type -> Type) where Source #

Typeclass that provides pure and return.

Minimal complete definition

Nothing

Methods

pure :: a -> x a Source #

return :: a -> x a Source #

Instances

Instances details
Applicative m => PureSyntax m Source # 
Instance details

Defined in Language.Haskell.DoNotation

Methods

pure :: a -> m a Source #

return :: a -> m a Source #

(IxMonad m, j ~ i) => PureSyntax (m i j) Source # 
Instance details

Defined in Language.Haskell.DoNotation

Methods

pure :: a -> m i j a Source #

return :: a -> m i j a Source #

class Applicative m => Monad (m :: Type -> Type) #

The Monad class defines the basic operations over a monad, a concept from a branch of mathematics known as category theory. From the perspective of a Haskell programmer, however, it is best to think of a monad as an abstract datatype of actions. Haskell's do expressions provide a convenient syntax for writing monadic expressions.

Instances of Monad should satisfy the following:

Left identity
return a >>= k = k a
Right identity
m >>= return = m
Associativity
m >>= (\x -> k x >>= h) = (m >>= k) >>= h

Furthermore, the Monad and Applicative operations should relate as follows:

The above laws imply:

and that pure and (<*>) satisfy the applicative functor laws.

The instances of Monad for List, Maybe and IO defined in the Prelude satisfy these laws.

Minimal complete definition

(>>=)

Instances

Instances details
Monad Complex

Since: base-4.9.0.0

Instance details

Defined in Data.Complex

Methods

(>>=) :: Complex a -> (a -> Complex b) -> Complex b #

(>>) :: Complex a -> Complex b -> Complex b #

return :: a -> Complex a #

Monad First

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

(>>=) :: First a -> (a -> First b) -> First b #

(>>) :: First a -> First b -> First b #

return :: a -> First a #

Monad Last

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

(>>=) :: Last a -> (a -> Last b) -> Last b #

(>>) :: Last a -> Last b -> Last b #

return :: a -> Last a #

Monad Max

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

(>>=) :: Max a -> (a -> Max b) -> Max b #

(>>) :: Max a -> Max b -> Max b #

return :: a -> Max a #

Monad Min

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Methods

(>>=) :: Min a -> (a -> Min b) -> Min b #

(>>) :: Min a -> Min b -> Min b #

return :: a -> Min a #

Monad NonEmpty

Since: base-4.9.0.0

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: NonEmpty a -> (a -> NonEmpty b) -> NonEmpty b #

(>>) :: NonEmpty a -> NonEmpty b -> NonEmpty b #

return :: a -> NonEmpty a #

Monad IO

Since: base-2.1

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: IO a -> (a -> IO b) -> IO b #

(>>) :: IO a -> IO b -> IO b #

return :: a -> IO a #

Monad Maybe

Since: base-2.1

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: Maybe a -> (a -> Maybe b) -> Maybe b #

(>>) :: Maybe a -> Maybe b -> Maybe b #

return :: a -> Maybe a #

Monad Solo

Since: base-4.15

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: Solo a -> (a -> Solo b) -> Solo b #

(>>) :: Solo a -> Solo b -> Solo b #

return :: a -> Solo a #

Monad []

Since: base-2.1

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: [a] -> (a -> [b]) -> [b] #

(>>) :: [a] -> [b] -> [b] #

return :: a -> [a] #

Monad m => Monad (WrappedMonad m)

Since: base-4.7.0.0

Instance details

Defined in Control.Applicative

Methods

(>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b #

(>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b #

return :: a -> WrappedMonad m a #

Monoid a => Monad ((,) a)

Since: base-4.9.0.0

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: (a, a0) -> (a0 -> (a, b)) -> (a, b) #

(>>) :: (a, a0) -> (a, b) -> (a, b) #

return :: a0 -> (a, a0) #

(Monoid a, Monoid b) => Monad ((,,) a b)

Since: base-4.14.0.0

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: (a, b, a0) -> (a0 -> (a, b, b0)) -> (a, b, b0) #

(>>) :: (a, b, a0) -> (a, b, b0) -> (a, b, b0) #

return :: a0 -> (a, b, a0) #

(Monad f, Monad g) => Monad (Product f g)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

Methods

(>>=) :: Product f g a -> (a -> Product f g b) -> Product f g b #

(>>) :: Product f g a -> Product f g b -> Product f g b #

return :: a -> Product f g a #

(Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c)

Since: base-4.14.0.0

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: (a, b, c, a0) -> (a0 -> (a, b, c, b0)) -> (a, b, c, b0) #

(>>) :: (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, b0) #

return :: a0 -> (a, b, c, a0) #

Monad ((->) r)

Since: base-2.1

Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: (r -> a) -> (a -> r -> b) -> r -> b #

(>>) :: (r -> a) -> (r -> b) -> r -> b #

return :: a -> r -> a #

Monad m => Monad (Ix m i j) Source # 
Instance details

Defined in Control.Monad.Trans.Ix

Methods

(>>=) :: Ix m i j a -> (a -> Ix m i j b) -> Ix m i j b #

(>>) :: Ix m i j a -> Ix m i j b -> Ix m i j b #

return :: a -> Ix m i j a #

class IxApplicative m => IxMonad (m :: k -> k -> Type -> Type) #

Minimal complete definition

ibind

Instances

Instances details
Monad m => IxMonad (Ix m :: k -> k -> Type -> Type) Source # 
Instance details

Defined in Control.Monad.Trans.Ix

Methods

ibind :: forall a (j :: k) (k1 :: k) b (i :: k). (a -> Ix m j k1 b) -> Ix m i j a -> Ix m i k1 b #