transaction-0.1.1.4: Monadic representation of transactions.
CopyrightKadzuya Okamoto 2018
LicenseMIT
Stabilityexperimental
Portabilityunknown
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Transaction

Description

Monadic representation of transactions.

Synopsis

Constructors

action :: a -> Transaction a Source #

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

Converters

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

An alias of foldl for convenience.

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

An alias of first for convenience.

>>> :{
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 #

Deprecated: Use filter instead.

An alias of filter.

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

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

Deprecated: This will be removed in a future release.

>>> :{
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

Instances details
Bifunctor TransactionM Source # 
Instance details

Defined in Data.Transaction

Methods

bimap :: (a -> b) -> (c -> d) -> TransactionM a c -> TransactionM b d #

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

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

Applicative (TransactionM a) Source # 
Instance details

Defined in Data.Transaction

Methods

pure :: a0 -> TransactionM a a0 #

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

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

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

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

Functor (TransactionM a) Source # 
Instance details

Defined in Data.Transaction

Methods

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

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

Monad (TransactionM a) Source # 
Instance details

Defined in Data.Transaction

Methods

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

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

return :: a0 -> TransactionM a a0 #

Monoid (Transaction a) Source # 
Instance details

Defined in Data.Transaction

Semigroup (Transaction a) Source # 
Instance details

Defined in Data.Transaction

GrowingAppend (Transaction a) Source # 
Instance details

Defined in Data.Transaction

MonoFoldable (Transaction a) Source # 
Instance details

Defined in Data.Transaction

Methods

ofoldMap :: Monoid m => (Element (Transaction a) -> m) -> Transaction a -> m #

ofoldr :: (Element (Transaction a) -> b -> b) -> b -> Transaction a -> b #

ofoldl' :: (a0 -> Element (Transaction a) -> a0) -> a0 -> Transaction a -> a0 #

otoList :: Transaction a -> [Element (Transaction a)] #

oall :: (Element (Transaction a) -> Bool) -> Transaction a -> Bool #

oany :: (Element (Transaction a) -> Bool) -> Transaction a -> Bool #

onull :: Transaction a -> Bool #

olength :: Transaction a -> Int #

olength64 :: Transaction a -> Int64 #

ocompareLength :: Integral i => Transaction a -> i -> Ordering #

otraverse_ :: Applicative f => (Element (Transaction a) -> f b) -> Transaction a -> f () #

ofor_ :: Applicative f => Transaction a -> (Element (Transaction a) -> f b) -> f () #

omapM_ :: Applicative m => (Element (Transaction a) -> m ()) -> Transaction a -> m () #

oforM_ :: Applicative m => Transaction a -> (Element (Transaction a) -> m ()) -> m () #

ofoldlM :: Monad m => (a0 -> Element (Transaction a) -> m a0) -> a0 -> Transaction a -> m a0 #

ofoldMap1Ex :: Semigroup m => (Element (Transaction a) -> m) -> Transaction a -> m #

ofoldr1Ex :: (Element (Transaction a) -> Element (Transaction a) -> Element (Transaction a)) -> Transaction a -> Element (Transaction a) #

ofoldl1Ex' :: (Element (Transaction a) -> Element (Transaction a) -> Element (Transaction a)) -> Transaction a -> Element (Transaction a) #

headEx :: Transaction a -> Element (Transaction a) #

lastEx :: Transaction a -> Element (Transaction a) #

unsafeHead :: Transaction a -> Element (Transaction a) #

unsafeLast :: Transaction a -> Element (Transaction a) #

maximumByEx :: (Element (Transaction a) -> Element (Transaction a) -> Ordering) -> Transaction a -> Element (Transaction a) #

minimumByEx :: (Element (Transaction a) -> Element (Transaction a) -> Ordering) -> Transaction a -> Element (Transaction a) #

oelem :: Element (Transaction a) -> Transaction a -> Bool #

onotElem :: Element (Transaction a) -> Transaction a -> Bool #

MonoFunctor (Transaction a) Source # 
Instance details

Defined in Data.Transaction

MonoPointed (Transaction a) Source # 
Instance details

Defined in Data.Transaction

MonoTraversable (Transaction a) Source # 
Instance details

Defined in Data.Transaction

IsSequence (Transaction a) Source # 
Instance details

Defined in Data.Transaction

Methods

fromList :: [Element (Transaction a)] -> Transaction a #

lengthIndex :: Transaction a -> Index (Transaction a) #

break :: (Element (Transaction a) -> Bool) -> Transaction a -> (Transaction a, Transaction a) #

span :: (Element (Transaction a) -> Bool) -> Transaction a -> (Transaction a, Transaction a) #

dropWhile :: (Element (Transaction a) -> Bool) -> Transaction a -> Transaction a #

takeWhile :: (Element (Transaction a) -> Bool) -> Transaction a -> Transaction a #

splitAt :: Index (Transaction a) -> Transaction a -> (Transaction a, Transaction a) #

unsafeSplitAt :: Index (Transaction a) -> Transaction a -> (Transaction a, Transaction a) #

take :: Index (Transaction a) -> Transaction a -> Transaction a #

unsafeTake :: Index (Transaction a) -> Transaction a -> Transaction a #

drop :: Index (Transaction a) -> Transaction a -> Transaction a #

unsafeDrop :: Index (Transaction a) -> Transaction a -> Transaction a #

dropEnd :: Index (Transaction a) -> Transaction a -> Transaction a #

partition :: (Element (Transaction a) -> Bool) -> Transaction a -> (Transaction a, Transaction a) #

uncons :: Transaction a -> Maybe (Element (Transaction a), Transaction a) #

unsnoc :: Transaction a -> Maybe (Transaction a, Element (Transaction a)) #

filter :: (Element (Transaction a) -> Bool) -> Transaction a -> Transaction a #

filterM :: Monad m => (Element (Transaction a) -> m Bool) -> Transaction a -> m (Transaction a) #

replicate :: Index (Transaction a) -> Element (Transaction a) -> Transaction a #

replicateM :: Monad m => Index (Transaction a) -> m (Element (Transaction a)) -> m (Transaction a) #

groupBy :: (Element (Transaction a) -> Element (Transaction a) -> Bool) -> Transaction a -> [Transaction a] #

groupAllOn :: Eq b => (Element (Transaction a) -> b) -> Transaction a -> [Transaction a] #

subsequences :: Transaction a -> [Transaction a] #

permutations :: Transaction a -> [Transaction a] #

tailEx :: Transaction a -> Transaction a #

tailMay :: Transaction a -> Maybe (Transaction a) #

initEx :: Transaction a -> Transaction a #

initMay :: Transaction a -> Maybe (Transaction a) #

unsafeTail :: Transaction a -> Transaction a #

unsafeInit :: Transaction a -> Transaction a #

index :: Transaction a -> Index (Transaction a) -> Maybe (Element (Transaction a)) #

indexEx :: Transaction a -> Index (Transaction a) -> Element (Transaction a) #

unsafeIndex :: Transaction a -> Index (Transaction a) -> Element (Transaction a) #

splitWhen :: (Element (Transaction a) -> Bool) -> Transaction a -> [Transaction a] #

SemiSequence (Transaction a) Source # 
Instance details

Defined in Data.Transaction

Associated Types

type Index (Transaction a) #

type Element (Transaction a) Source # 
Instance details

Defined in Data.Transaction

type Element (Transaction a) = a
type Index (Transaction a) Source # 
Instance details

Defined in Data.Transaction

type Index (Transaction a) = Int