(>=>)
(a → m b) → (b → m c) → a → m c
Kleisli composition L-to-R
(<=<)
(b → m c) → (a → m b) → a → m c
Kleisli composition R-to-L
join
m (m a) → m a
Flatten nested monads
void
f a → f ()
Discard result
traverse
(a → f b) → t a → f (t b)
Map with applicative effects
sequenceA
t (f a) → f (t a)
Flip structure inside-out
sequenceA [Just 1, Just 2]
= Just [1,2]
mapM
(a → m b) → t a → m (t b)
traverse specialized to Monad
sequence
t (m a) → m (t a)
sequenceA specialized to Monad
forM
t a → (a → m b) → m (t b)
Flipped mapM
mapM_
(a → m b) → t a → m ()
Map action, discard results
forM_
t a → (a → m b) → m ()
Flipped mapM_
traverse_
(a → f b) → t a → f ()
Traverse for side effects
sequenceA_
t (f a) → f ()
Sequence for side effects
foldr
(a → b → b) → b → t a → b
Right-associative fold
foldr (+) 0 [1,2,3] = 6
foldl
(b → a → b) → b → t a → b
Left-associative fold
foldl’
(b → a → b) → b → t a → b
Strict left fold
foldMap
Monoid m => (a → m) → t a → m
Map to monoid then fold
null
t a → Bool
Test if structure is empty
length
t a → Int
Count elements
elem
Eq a => a → t a → Bool
Check if element present
maximum
Ord a => t a → a
Find maximum element
minimum
Ord a => t a → a
Find minimum element
sum
Num a => t a → a
Sum all elements
product
Num a => t a → a
Product of all elements
toList
t a → [a]
Convert structure to list
empty / mzero
f a / m a
Represents failure
(<|>) / mplus
f a → f a → f a
Choice/combine operation
guard
Bool → m ()
Conditional failure
mfilter
(a → Bool) → m a → m a
Filter by predicate