distributors-0.6.0.0: Unifying Parsers, Printers & Grammars
Copyright(C) 2026 - Eitan Chatav
LicenseBSD-style (see the file LICENSE)
MaintainerEitan Chatav <eitan.chatav@gmail.com>
Stabilityprovisional
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Profunctor.Monadic

Description

See Li-yao Xia, Monadic profunctors for bidirectional programming

This module can provide qualified do-notation for Monadic profunctors.

>>> :set -XQualifiedDo
>>> import qualified Data.Profunctor.Monadic as P

See Control.Lens.Grammar for an example of how to use qualified do-notation with pattern bonding.

Synopsis

Monadic

type Monadic (p :: Type -> Type -> Type) = (Profunctor p, forall x. Monad (p x)) Source #

A Profunctor which is also a Monad.

(>>=) :: Monadic p => p a b -> (b -> p c d) -> p (a, c) (b, d) infixl 1 Source #

The pair bonding operator P.>>= is a context-sensitive version of >*<.

x >*< y = x P.>>= (\_ -> y)

(>>) :: Monadic p => p () c -> p a b -> p a b infixl 1 Source #

P.>> sequences actions.

return :: (Monadic p, Choice p) => Prism a b () () -> p a b Source #

P.return is a Monadic-restricted version of pureP.

pureP = P.return

MonadicTry

type MonadicTry (p :: Type -> Type -> Type) = (Profunctor p, forall x. MonadTry (p x)) Source #

A Profunctor which is also a MonadTry.

try :: MonadTry m => m a -> m a Source #

A handler for failures. Used for backtracking state on failure in Parsector.

fail :: MonadFail m => String -> m a #