transaction-0.1.0.0: Monadic representation of transactions.

CopyrightKadzuya Okamoto 2018
LicenseMIT
Stabilityexperimental
Portabilityunknown
Safe HaskellSafe
LanguageHaskell2010

Data.Transaction

Contents

Description

Monadic representation of transactions.

Synopsis

Constructors

action :: a -> Transaction a Source #

>>> :{
toList $ do
  action 4
  action 5
  action 6
:}
[4,5,6]

Converters

reduce :: (b -> a -> b) -> b -> Transaction a -> b Source #

tMap :: (a -> b) -> Transaction a -> Transaction b Source #

>>> :{
toList $ do
  action 4
  tMap (+1) $ do
    action 5
    action 6
  action 7
:}
[4,6,7,7]

tFilter :: (a -> Bool) -> Transaction a -> Transaction a Source #

>>> :{
toList $ do
  action 4
  tFilter even $ do
    action 5
    action 6
  action 7
:}
[4,6,7]

tFilterMap :: (a -> Maybe b) -> Transaction a -> Transaction b Source #

>>> :{
toList $ do
  action 4
  tFilterMap (\x -> if even x then Just (x + 1) else Nothing) $ do
    action 5
    action 6
  action 7
:}
[4,7,7]

Types

data TransactionM a x Source #

Instances

Monad (TransactionM a) Source # 

Methods

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

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

return :: a -> TransactionM a a #

fail :: String -> TransactionM a a #

Functor (TransactionM a) Source # 

Methods

fmap :: (a -> b) -> TransactionM a a -> TransactionM a b #

(<$) :: a -> TransactionM a b -> TransactionM a a #

Applicative (TransactionM a) Source # 

Methods

pure :: a -> TransactionM a a #

(<*>) :: TransactionM a (a -> b) -> TransactionM a a -> TransactionM a b #

liftA2 :: (a -> b -> c) -> TransactionM a a -> TransactionM a b -> TransactionM a c #

(*>) :: TransactionM a a -> TransactionM a b -> TransactionM a b #

(<*) :: TransactionM a a -> TransactionM a b -> TransactionM a a #