Copyright | (c) 2021 Tony Zorman |
---|---|
License | BSD3-style (see LICENSE) |
Maintainer | Tony Zorman <soliditsallgood@mailbox.org> |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Utility functions and re-exports for a more ergonomic developing experience. Users themselves will not find much use here.
Synopsis
- (++) :: [a] -> [a] -> [a]
- filter :: (a -> Bool) -> [a] -> [a]
- zip :: [a] -> [b] -> [(a, b)]
- otherwise :: Bool
- map :: (a -> b) -> [a] -> [b]
- ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
- guard :: Alternative f => Bool -> f ()
- join :: Monad m => m (m a) -> m a
- class Applicative m => Monad (m :: Type -> Type) where
- class Functor (f :: Type -> Type) where
- class Monad m => MonadFail (m :: Type -> Type) where
- class Functor f => Applicative (f :: Type -> Type) where
- class Foldable (t :: TYPE LiftedRep -> Type) where
- fold :: Monoid m => t m -> m
- foldMap :: Monoid m => (a -> m) -> t a -> m
- foldMap' :: Monoid m => (a -> m) -> t a -> m
- foldr :: (a -> b -> b) -> b -> t a -> b
- foldr' :: (a -> b -> b) -> b -> t a -> b
- foldl :: (b -> a -> b) -> b -> t a -> b
- foldl' :: (b -> a -> b) -> b -> t a -> b
- foldr1 :: (a -> a -> a) -> t a -> a
- foldl1 :: (a -> a -> a) -> t a -> a
- null :: t a -> Bool
- length :: t a -> Int
- elem :: Eq a => a -> t a -> Bool
- maximum :: Ord a => t a -> a
- minimum :: Ord a => t a -> a
- sum :: Num a => t a -> a
- product :: Num a => t a -> a
- class (Functor t, Foldable t) => Traversable (t :: Type -> Type) where
- traverse :: Applicative f => (a -> f b) -> t a -> f (t b)
- sequenceA :: Applicative f => t (f a) -> f (t a)
- mapM :: Monad m => (a -> m b) -> t a -> m (t b)
- sequence :: Monad m => t (m a) -> m (t a)
- (<>) :: Semigroup a => a -> a -> a
- class Semigroup a => Monoid a where
- data Bool
- data Char
- data Maybe a
- zipWithM_ :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m ()
- zipWithM :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m [c]
- unless :: Applicative f => Bool -> f () -> f ()
- replicateM_ :: Applicative m => Int -> m a -> m ()
- replicateM :: Applicative m => Int -> m a -> m [a]
- mfilter :: MonadPlus m => (a -> Bool) -> m a -> m a
- mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c])
- forever :: Applicative f => f a -> f b
- foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m ()
- foldM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
- filterM :: Applicative m => (a -> m Bool) -> [a] -> m [a]
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
- (<$!>) :: Monad m => (a -> b) -> m a -> m b
- isSubsequenceOf :: Eq a => [a] -> [a] -> Bool
- mapAccumR :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)
- mapAccumL :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)
- forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)
- for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)
- foldMapDefault :: (Traversable t, Monoid m) => (a -> m) -> t a -> m
- fmapDefault :: Traversable t => (a -> b) -> t a -> t b
- newtype ZipList a = ZipList {
- getZipList :: [a]
- newtype WrappedMonad (m :: Type -> Type) a = WrapMonad {
- unwrapMonad :: m a
- newtype WrappedArrow (a :: Type -> Type -> Type) b c = WrapArrow {
- unwrapArrow :: a b c
- optional :: Alternative f => f a -> f (Maybe a)
- newtype Const a (b :: k) = Const {
- getConst :: a
- traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
- sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()
- sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f ()
- or :: Foldable t => t Bool -> Bool
- notElem :: (Foldable t, Eq a) => a -> t a -> Bool
- msum :: (Foldable t, MonadPlus m) => t (m a) -> m a
- minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
- maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
- mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
- for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
- forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()
- foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b
- foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
- find :: Foldable t => (a -> Bool) -> t a -> Maybe a
- concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
- concat :: Foldable t => t [a] -> [a]
- asum :: (Foldable t, Alternative f) => t (f a) -> f a
- any :: Foldable t => (a -> Bool) -> t a -> Bool
- and :: Foldable t => t Bool -> Bool
- all :: Foldable t => (a -> Bool) -> t a -> Bool
- zipWith7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h]
- zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g]
- zipWith5 :: (a -> b -> c -> d -> e -> f) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f]
- zipWith4 :: (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]
- zip7 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [(a, b, c, d, e, f, g)]
- zip6 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [(a, b, c, d, e, f)]
- zip5 :: [a] -> [b] -> [c] -> [d] -> [e] -> [(a, b, c, d, e)]
- zip4 :: [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)]
- words :: String -> [String]
- unzip7 :: [(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g])
- unzip6 :: [(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f])
- unzip5 :: [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e])
- unzip4 :: [(a, b, c, d)] -> ([a], [b], [c], [d])
- unwords :: [String] -> String
- unlines :: [String] -> String
- unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
- union :: Eq a => [a] -> [a] -> [a]
- unfoldr :: (b -> Maybe (a, b)) -> b -> [a]
- transpose :: [[a]] -> [[a]]
- tails :: [a] -> [[a]]
- subsequences :: [a] -> [[a]]
- stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]
- sortOn :: Ord b => (a -> b) -> [a] -> [a]
- sortBy :: (a -> a -> Ordering) -> [a] -> [a]
- sort :: Ord a => [a] -> [a]
- singleton :: a -> [a]
- permutations :: [a] -> [[a]]
- partition :: (a -> Bool) -> [a] -> ([a], [a])
- nubBy :: (a -> a -> Bool) -> [a] -> [a]
- nub :: Eq a => [a] -> [a]
- lines :: String -> [String]
- isSuffixOf :: Eq a => [a] -> [a] -> Bool
- isPrefixOf :: Eq a => [a] -> [a] -> Bool
- isInfixOf :: Eq a => [a] -> [a] -> Bool
- intersperse :: a -> [a] -> [a]
- intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
- intersect :: Eq a => [a] -> [a] -> [a]
- intercalate :: [a] -> [[a]] -> [a]
- insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]
- insert :: Ord a => a -> [a] -> [a]
- inits :: [a] -> [[a]]
- groupBy :: (a -> a -> Bool) -> [a] -> [[a]]
- group :: Eq a => [a] -> [[a]]
- genericTake :: Integral i => i -> [a] -> [a]
- genericSplitAt :: Integral i => i -> [a] -> ([a], [a])
- genericReplicate :: Integral i => i -> a -> [a]
- genericLength :: Num i => [a] -> i
- genericIndex :: Integral i => [a] -> i -> a
- genericDrop :: Integral i => i -> [a] -> [a]
- findIndices :: (a -> Bool) -> [a] -> [Int]
- findIndex :: (a -> Bool) -> [a] -> Maybe Int
- elemIndices :: Eq a => a -> [a] -> [Int]
- elemIndex :: Eq a => a -> [a] -> Maybe Int
- dropWhileEnd :: (a -> Bool) -> [a] -> [a]
- deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
- deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]
- delete :: Eq a => a -> [a] -> [a]
- (\\) :: Eq a => [a] -> [a] -> [a]
- newtype Last a = Last {}
- newtype First a = First {}
- newtype Ap (f :: k -> Type) (a :: k) = Ap {
- getAp :: f a
- newtype Sum a = Sum {
- getSum :: a
- newtype Product a = Product {
- getProduct :: a
- newtype Endo a = Endo {
- appEndo :: a -> a
- newtype Dual a = Dual {
- getDual :: a
- newtype Any = Any {}
- newtype Alt (f :: k -> Type) (a :: k) = Alt {
- getAlt :: f a
- newtype All = All {}
- isSeparator :: Char -> Bool
- isNumber :: Char -> Bool
- isMark :: Char -> Bool
- isLetter :: Char -> Bool
- digitToInt :: Char -> Int
- readLitChar :: ReadS Char
- lexLitChar :: ReadS String
- data GeneralCategory
- = UppercaseLetter
- | LowercaseLetter
- | TitlecaseLetter
- | ModifierLetter
- | OtherLetter
- | NonSpacingMark
- | SpacingCombiningMark
- | EnclosingMark
- | DecimalNumber
- | LetterNumber
- | OtherNumber
- | ConnectorPunctuation
- | DashPunctuation
- | OpenPunctuation
- | ClosePunctuation
- | InitialQuote
- | FinalQuote
- | OtherPunctuation
- | MathSymbol
- | CurrencySymbol
- | ModifierSymbol
- | OtherSymbol
- | Space
- | LineSeparator
- | ParagraphSeparator
- | Control
- | Format
- | Surrogate
- | PrivateUse
- | NotAssigned
- toUpper :: Char -> Char
- toTitle :: Char -> Char
- toLower :: Char -> Char
- isUpper :: Char -> Bool
- isSymbol :: Char -> Bool
- isSpace :: Char -> Bool
- isPunctuation :: Char -> Bool
- isPrint :: Char -> Bool
- isOctDigit :: Char -> Bool
- isLower :: Char -> Bool
- isLatin1 :: Char -> Bool
- isHexDigit :: Char -> Bool
- isDigit :: Char -> Bool
- isControl :: Char -> Bool
- isAsciiUpper :: Char -> Bool
- isAsciiLower :: Char -> Bool
- isAscii :: Char -> Bool
- isAlphaNum :: Char -> Bool
- isAlpha :: Char -> Bool
- generalCategory :: Char -> GeneralCategory
- chr :: Int -> Char
- showLitChar :: Char -> ShowS
- intToDigit :: Int -> Char
- zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
- zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
- zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
- unzip3 :: [(a, b, c)] -> ([a], [b], [c])
- unzip :: [(a, b)] -> ([a], [b])
- uncons :: [a] -> Maybe (a, [a])
- takeWhile :: (a -> Bool) -> [a] -> [a]
- take :: Int -> [a] -> [a]
- tail :: [a] -> [a]
- splitAt :: Int -> [a] -> ([a], [a])
- span :: (a -> Bool) -> [a] -> ([a], [a])
- scanr1 :: (a -> a -> a) -> [a] -> [a]
- scanr :: (a -> b -> b) -> b -> [a] -> [b]
- scanl1 :: (a -> a -> a) -> [a] -> [a]
- scanl' :: (b -> a -> b) -> b -> [a] -> [b]
- scanl :: (b -> a -> b) -> b -> [a] -> [b]
- reverse :: [a] -> [a]
- replicate :: Int -> a -> [a]
- repeat :: a -> [a]
- lookup :: Eq a => a -> [(a, b)] -> Maybe b
- last :: [a] -> a
- iterate' :: (a -> a) -> a -> [a]
- iterate :: (a -> a) -> a -> [a]
- init :: [a] -> [a]
- head :: [a] -> a
- foldl1' :: (a -> a -> a) -> [a] -> a
- dropWhile :: (a -> Bool) -> [a] -> [a]
- drop :: Int -> [a] -> [a]
- cycle :: [a] -> [a]
- break :: (a -> Bool) -> [a] -> ([a], [a])
- (!!) :: [a] -> Int -> a
- maybeToList :: Maybe a -> [a]
- maybe :: b -> (a -> b) -> Maybe a -> b
- mapMaybe :: (a -> Maybe b) -> [a] -> [b]
- listToMaybe :: [a] -> Maybe a
- isNothing :: Maybe a -> Bool
- isJust :: Maybe a -> Bool
- fromMaybe :: a -> Maybe a -> a
- fromJust :: HasCallStack => Maybe a -> a
- catMaybes :: [Maybe a] -> [a]
- bool :: a -> a -> Bool -> a
- on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
- fix :: (a -> a) -> a
- (&) :: a -> (a -> b) -> b
- void :: Functor f => f a -> f ()
- (<&>) :: Functor f => f a -> (a -> b) -> f b
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- ($>) :: Functor f => f a -> b -> f b
- class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) where
- class Applicative f => Alternative (f :: Type -> Type) where
- when :: Applicative f => Bool -> f () -> f ()
- ord :: Char -> Int
- liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r
- liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
- liftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
- liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
- liftM :: Monad m => (a1 -> r) -> m a1 -> m r
- liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- liftA :: Applicative f => (a -> b) -> f a -> f b
- id :: a -> a
- flip :: (a -> b -> c) -> b -> a -> c
- const :: a -> b -> a
- ap :: Monad m => m (a -> b) -> m a -> m b
- (=<<) :: Monad m => (a -> m b) -> m a -> m b
- (<**>) :: Applicative f => f a -> f (a -> b) -> f b
- (.) :: (b -> c) -> (a -> b) -> a -> c
- (&&) :: Bool -> Bool -> Bool
- not :: Bool -> Bool
- (||) :: Bool -> Bool -> Bool
- fi :: (Integral a, Num b) => a -> b
- chunksOf :: Int -> [a] -> [[a]]
- (.:) :: (a -> b) -> (c -> d -> a) -> c -> d -> b
- (!?) :: [a] -> Int -> Maybe a
- data NonEmpty a = a :| [a]
- notEmpty :: HasCallStack => [a] -> NonEmpty a
- safeGetWindowAttributes :: Window -> X (Maybe WindowAttributes)
- mkAbsolutePath :: MonadIO m => FilePath -> m FilePath
- findM :: Monad m => (a -> m Bool) -> [a] -> m (Maybe a)
- keyToString :: (KeyMask, KeySym) -> String
- keymaskToString :: KeyMask -> KeyMask -> String
- cleanKeyMask :: X (KeyMask -> KeyMask)
- regularKeys :: [(String, KeySym)]
- allSpecialKeys :: [(String, KeySym)]
- specialKeys :: [(String, KeySym)]
- multimediaKeys :: [(String, KeySym)]
- functionKeys :: [(String, KeySym)]
- type WindowScreen = Screen WorkspaceId (Layout Window) Window ScreenId ScreenDetail
- data Stream a = !a :~ (Stream a)
- (+~) :: [a] -> Stream a -> Stream a
- cycleS :: NonEmpty a -> Stream a
- takeS :: Int -> Stream a -> [a]
- toList :: IsList l => l -> [Item l]
- fromList :: IsList l => [Item l] -> l
Documentation
(++) :: [a] -> [a] -> [a] infixr 5 #
Append two lists, i.e.,
[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn] [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
If the first list is not finite, the result is the first list.
filter :: (a -> Bool) -> [a] -> [a] #
\(\mathcal{O}(n)\). filter
, applied to a predicate and a list, returns
the list of those elements that satisfy the predicate; i.e.,
filter p xs = [ x | x <- xs, p x]
>>>
filter odd [1, 2, 3]
[1,3]
zip :: [a] -> [b] -> [(a, b)] #
\(\mathcal{O}(\min(m,n))\). zip
takes two lists and returns a list of
corresponding pairs.
>>>
zip [1, 2] ['a', 'b']
[(1,'a'),(2,'b')]
If one input list is shorter than the other, excess elements of the longer list are discarded, even if one of the lists is infinite:
>>>
zip [1] ['a', 'b']
[(1,'a')]>>>
zip [1, 2] ['a']
[(1,'a')]>>>
zip [] [1..]
[]>>>
zip [1..] []
[]
zip
is right-lazy:
>>>
zip [] undefined
[]>>>
zip undefined []
*** Exception: Prelude.undefined ...
zip
is capable of list fusion, but it is restricted to its
first list argument and its resulting list.
map :: (a -> b) -> [a] -> [b] #
\(\mathcal{O}(n)\). map
f xs
is the list obtained by applying f
to
each element of xs
, i.e.,
map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] map f [x1, x2, ...] == [f x1, f x2, ...]
>>>
map (+1) [1, 2, 3]
[2,3,4]
($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b infixr 0 #
Application operator. This operator is redundant, since ordinary
application (f x)
means the same as (f
. However, $
x)$
has
low, right-associative binding precedence, so it sometimes allows
parentheses to be omitted; for example:
f $ g $ h x = f (g (h x))
It is also useful in higher-order situations, such as
,
or map
($
0) xs
.zipWith
($
) fs xs
Note that (
is levity-polymorphic in its result type, so that
$
)foo
where $
Truefoo :: Bool -> Int#
is well-typed.
guard :: Alternative f => Bool -> f () #
Conditional failure of Alternative
computations. Defined by
guard True =pure
() guard False =empty
Examples
Common uses of guard
include conditionally signaling an error in
an error monad and conditionally rejecting the current choice in an
Alternative
-based parser.
As an example of signaling an error in the error monad Maybe
,
consider a safe division function safeDiv x y
that returns
Nothing
when the denominator y
is zero and
otherwise. For example:Just
(x `div`
y)
>>>
safeDiv 4 0
Nothing
>>>
safeDiv 4 2
Just 2
A definition of safeDiv
using guards, but not guard
:
safeDiv :: Int -> Int -> Maybe Int safeDiv x y | y /= 0 = Just (x `div` y) | otherwise = Nothing
A definition of safeDiv
using guard
and Monad
do
-notation:
safeDiv :: Int -> Int -> Maybe Int safeDiv x y = do guard (y /= 0) return (x `div` y)
join :: Monad m => m (m a) -> m a #
The join
function is the conventional monad join operator. It
is used to remove one level of monadic structure, projecting its
bound argument into the outer level.
'
' can be understood as the join
bssdo
expression
do bs <- bss bs
Examples
A common use of join
is to run an IO
computation returned from
an STM
transaction, since STM
transactions
can't perform IO
directly. Recall that
atomically
:: STM a -> IO a
is used to run STM
transactions atomically. So, by
specializing the types of atomically
and join
to
atomically
:: STM (IO b) -> IO (IO b)join
:: IO (IO b) -> IO b
we can compose them as
join
.atomically
:: STM (IO b) -> IO b
class Applicative m => Monad (m :: Type -> Type) where #
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 lists, Maybe
and IO
defined in the Prelude satisfy these laws.
(>>=) :: m a -> (a -> m b) -> m b infixl 1 #
Sequentially compose two actions, passing any value produced by the first as an argument to the second.
'as
' can be understood as the >>=
bsdo
expression
do a <- as bs a
(>>) :: m a -> m b -> m b infixl 1 #
Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
'as
' can be understood as the >>
bsdo
expression
do as bs
Inject a value into the monadic type.
Instances
Monad Complex | Since: base-4.9.0.0 |
Monad Identity | Since: base-4.8.0.0 |
Monad First | Since: base-4.8.0.0 |
Monad Last | Since: base-4.8.0.0 |
Monad Down | Since: base-4.11.0.0 |
Monad First | Since: base-4.9.0.0 |
Monad Last | Since: base-4.9.0.0 |
Monad Max | Since: base-4.9.0.0 |
Monad Min | Since: base-4.9.0.0 |
Monad Dual | Since: base-4.8.0.0 |
Monad Product | Since: base-4.8.0.0 |
Monad Sum | Since: base-4.8.0.0 |
Monad STM | Since: base-4.3.0.0 |
Monad Par1 | Since: base-4.9.0.0 |
Monad P | Since: base-2.1 |
Monad ReadP | Since: base-2.1 |
Monad ReadPrec | Since: base-2.1 |
Monad Seq | |
Monad Tree | |
Monad IO | Since: base-2.1 |
Monad Q | |
Monad Query | |
Monad X | |
Monad FocusQuery Source # | |
Defined in XMonad.Hooks.Focus (>>=) :: FocusQuery a -> (a -> FocusQuery b) -> FocusQuery b # (>>) :: FocusQuery a -> FocusQuery b -> FocusQuery b # return :: a -> FocusQuery a # | |
Monad Parser Source # | |
Monad PureX Source # | |
Monad NonEmpty | Since: base-4.9.0.0 |
Monad Maybe | Since: base-2.1 |
Monad Solo | Since: base-4.15 |
Monad [] | Since: base-2.1 |
Monad m => Monad (WrappedMonad m) | Since: base-4.7.0.0 |
Defined in Control.Applicative (>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b # (>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b # return :: a -> WrappedMonad m a # | |
ArrowApply a => Monad (ArrowMonad a) | Since: base-2.1 |
Defined in Control.Arrow (>>=) :: ArrowMonad a a0 -> (a0 -> ArrowMonad a b) -> ArrowMonad a b # (>>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b # return :: a0 -> ArrowMonad a a0 # | |
Monad (Either e) | Since: base-4.4.0.0 |
Monad (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Monad (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Monad m => Monad (ListT m) | |
Monad m => Monad (MaybeT m) | |
Monad (TwoD a) Source # | |
Monad m => Monad (Invisible m) Source # | |
Monad (StateQuery s) Source # | |
Defined in XMonad.Util.WindowState (>>=) :: StateQuery s a -> (a -> StateQuery s b) -> StateQuery s b # (>>) :: StateQuery s a -> StateQuery s b -> StateQuery s b # return :: a -> StateQuery s a # | |
Monoid a => Monad ((,) a) | Since: base-4.9.0.0 |
Monad m => Monad (Kleisli m a) | Since: base-4.14.0.0 |
Monad f => Monad (Ap f) | Since: base-4.12.0.0 |
Monad f => Monad (Alt f) | Since: base-4.8.0.0 |
Monad f => Monad (Rec1 f) | Since: base-4.9.0.0 |
(Applicative f, Monad f) => Monad (WhenMissing f x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal (>>=) :: WhenMissing f x a -> (a -> WhenMissing f x b) -> WhenMissing f x b # (>>) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x b # return :: a -> WhenMissing f x a # | |
(Monad m, Error e) => Monad (ErrorT e m) | |
Monad m => Monad (ExceptT e m) | |
Monad m => Monad (IdentityT m) | |
Monad m => Monad (ReaderT r m) | |
Monad m => Monad (StateT s m) | |
Monad m => Monad (StateT s m) | |
(Monoid w, Monad m) => Monad (WriterT w m) | |
(Monoid w, Monad m) => Monad (WriterT w m) | |
(Monoid a, Monoid b) => Monad ((,,) a b) | Since: base-4.14.0.0 |
(Monad f, Monad g) => Monad (Product f g) | Since: base-4.9.0.0 |
(Monad f, Monad g) => Monad (f :*: g) | Since: base-4.9.0.0 |
(Monad f, Applicative f) => Monad (WhenMatched f x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal (>>=) :: WhenMatched f x y a -> (a -> WhenMatched f x y b) -> WhenMatched f x y b # (>>) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y b # return :: a -> WhenMatched f x y a # | |
(Applicative f, Monad f) => Monad (WhenMissing f k x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal (>>=) :: WhenMissing f k x a -> (a -> WhenMissing f k x b) -> WhenMissing f k x b # (>>) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x b # return :: a -> WhenMissing f k x a # | |
Monad (ContT r m) | |
(Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c) | Since: base-4.14.0.0 |
Monad ((->) r) | Since: base-2.1 |
Monad f => Monad (M1 i c f) | Since: base-4.9.0.0 |
(Monad f, Applicative f) => Monad (WhenMatched f k x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal (>>=) :: WhenMatched f k x y a -> (a -> WhenMatched f k x y b) -> WhenMatched f k x y b # (>>) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y b # return :: a -> WhenMatched f k x y a # | |
(Monoid w, Monad m) => Monad (RWST r w s m) | |
(Monoid w, Monad m) => Monad (RWST r w s m) | |
class Functor (f :: Type -> Type) where #
A type f
is a Functor if it provides a function fmap
which, given any types a
and b
lets you apply any function from (a -> b)
to turn an f a
into an f b
, preserving the
structure of f
. Furthermore f
needs to adhere to the following:
Note, that the second law follows from the free theorem of the type fmap
and
the first law, so you need only check that the former condition holds.
fmap :: (a -> b) -> f a -> f b #
fmap
is used to apply a function of type (a -> b)
to a value of type f a
,
where f is a functor, to produce a value of type f b
.
Note that for any type constructor with more than one parameter (e.g., Either
),
only the last type parameter can be modified with fmap
(e.g., b
in `Either a b`).
Some type constructors with two parameters or more have a
instance that allows
both the last and the penultimate parameters to be mapped over.Bifunctor
Examples
Convert from a
to a Maybe
IntMaybe String
using show
:
>>>
fmap show Nothing
Nothing>>>
fmap show (Just 3)
Just "3"
Convert from an
to an
Either
Int IntEither Int String
using show
:
>>>
fmap show (Left 17)
Left 17>>>
fmap show (Right 17)
Right "17"
Double each element of a list:
>>>
fmap (*2) [1,2,3]
[2,4,6]
Apply even
to the second element of a pair:
>>>
fmap even (2,2)
(2,True)
It may seem surprising that the function is only applied to the last element of the tuple
compared to the list example above which applies it to every element in the list.
To understand, remember that tuples are type constructors with multiple type parameters:
a tuple of 3 elements (a,b,c)
can also be written (,,) a b c
and its Functor
instance
is defined for Functor ((,,) a b)
(i.e., only the third parameter is free to be mapped over
with fmap
).
It explains why fmap
can be used with tuples containing values of different types as in the
following example:
>>>
fmap even ("hello", 1.0, 4)
("hello",1.0,True)
Instances
Functor ZipList | Since: base-2.1 |
Functor Handler | Since: base-4.6.0.0 |
Functor Complex | Since: base-4.9.0.0 |
Functor Identity | Since: base-4.8.0.0 |
Functor First | Since: base-4.8.0.0 |
Functor Last | Since: base-4.8.0.0 |
Functor Down | Since: base-4.11.0.0 |
Functor First | Since: base-4.9.0.0 |
Functor Last | Since: base-4.9.0.0 |
Functor Max | Since: base-4.9.0.0 |
Functor Min | Since: base-4.9.0.0 |
Functor Dual | Since: base-4.8.0.0 |
Functor Product | Since: base-4.8.0.0 |
Functor Sum | Since: base-4.8.0.0 |
Functor STM | Since: base-4.3.0.0 |
Functor Par1 | Since: base-4.9.0.0 |
Functor P | Since: base-4.8.0.0 |
Defined in Text.ParserCombinators.ReadP | |
Functor ReadP | Since: base-2.1 |
Functor ReadPrec | Since: base-2.1 |
Functor IntMap | |
Functor Digit | |
Functor Elem | |
Functor FingerTree | |
Defined in Data.Sequence.Internal fmap :: (a -> b) -> FingerTree a -> FingerTree b # (<$) :: a -> FingerTree b -> FingerTree a # | |
Functor Node | |
Functor Seq | |
Functor ViewL | |
Functor ViewR | |
Functor Tree | |
Functor IO | Since: base-2.1 |
Functor Q | |
Functor TyVarBndr | |
Functor Directories' | |
Defined in XMonad.Core fmap :: (a -> b) -> Directories' a -> Directories' b # (<$) :: a -> Directories' b -> Directories' a # | |
Functor Query | |
Functor X | |
Functor Stack | |
Functor Cursors Source # | |
Functor FocusQuery Source # | |
Defined in XMonad.Hooks.Focus fmap :: (a -> b) -> FocusQuery a -> FocusQuery b # (<$) :: a -> FocusQuery b -> FocusQuery a # | |
Functor Stream Source # | |
Functor Parser Source # | |
Functor PureX Source # | |
Functor NonEmpty | Since: base-4.9.0.0 |
Functor Maybe | Since: base-2.1 |
Functor Solo | Since: base-4.15 |
Functor [] | Since: base-2.1 |
Monad m => Functor (WrappedMonad m) | Since: base-2.1 |
Defined in Control.Applicative fmap :: (a -> b) -> WrappedMonad m a -> WrappedMonad m b # (<$) :: a -> WrappedMonad m b -> WrappedMonad m a # | |
Arrow a => Functor (ArrowMonad a) | Since: base-4.6.0.0 |
Defined in Control.Arrow fmap :: (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b # (<$) :: a0 -> ArrowMonad a b -> ArrowMonad a a0 # | |
Functor (Either a) | Since: base-3.0 |
Functor (StateL s) | Since: base-4.0 |
Defined in Data.Functor.Utils | |
Functor (StateR s) | Since: base-4.0 |
Defined in Data.Functor.Utils | |
Functor (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Functor (Arg a) | Since: base-4.9.0.0 |
Functor (Array i) | Since: base-2.1 |
Functor (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Functor (V1 :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Functor (Map k) | |
Functor m => Functor (ListT m) | |
Functor m => Functor (MaybeT m) | |
Functor (TwoD a) Source # | |
Functor (History k) Source # | |
Functor m => Functor (Invisible m) Source # | |
Functor (StateQuery s) Source # | |
Defined in XMonad.Util.WindowState fmap :: (a -> b) -> StateQuery s a -> StateQuery s b # (<$) :: a -> StateQuery s b -> StateQuery s a # | |
Functor ((,) a) | Since: base-2.1 |
Arrow a => Functor (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative fmap :: (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 # (<$) :: a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 # | |
Functor m => Functor (Kleisli m a) | Since: base-4.14.0.0 |
Functor (Const m :: Type -> Type) | Since: base-2.1 |
Functor f => Functor (Ap f) | Since: base-4.12.0.0 |
Functor f => Functor (Alt f) | Since: base-4.8.0.0 |
Functor f => Functor (Rec1 f) | Since: base-4.9.0.0 |
Functor (URec (Ptr ()) :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Functor (URec Char :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Functor (URec Double :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Functor (URec Float :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Functor (URec Int :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Functor (URec Word :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
(Applicative f, Monad f) => Functor (WhenMissing f x) | Since: containers-0.5.9 |
Defined in Data.IntMap.Internal fmap :: (a -> b) -> WhenMissing f x a -> WhenMissing f x b # (<$) :: a -> WhenMissing f x b -> WhenMissing f x a # | |
Functor m => Functor (ErrorT e m) | |
Functor m => Functor (ExceptT e m) | |
Functor m => Functor (IdentityT m) | |
Functor m => Functor (ReaderT r m) | |
Functor m => Functor (StateT s m) | |
Functor m => Functor (StateT s m) | |
Functor m => Functor (WriterT w m) | |
Functor m => Functor (WriterT w m) | |
Functor ((,,) a b) | Since: base-4.14.0.0 |
(Functor f, Functor g) => Functor (Product f g) | Since: base-4.9.0.0 |
(Functor f, Functor g) => Functor (Sum f g) | Since: base-4.9.0.0 |
(Functor f, Functor g) => Functor (f :*: g) | Since: base-4.9.0.0 |
(Functor f, Functor g) => Functor (f :+: g) | Since: base-4.9.0.0 |
Functor (K1 i c :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Functor f => Functor (WhenMatched f x y) | Since: containers-0.5.9 |
Defined in Data.IntMap.Internal fmap :: (a -> b) -> WhenMatched f x y a -> WhenMatched f x y b # (<$) :: a -> WhenMatched f x y b -> WhenMatched f x y a # | |
(Applicative f, Monad f) => Functor (WhenMissing f k x) | Since: containers-0.5.9 |
Defined in Data.Map.Internal fmap :: (a -> b) -> WhenMissing f k x a -> WhenMissing f k x b # (<$) :: a -> WhenMissing f k x b -> WhenMissing f k x a # | |
Functor (ContT r m) | |
Functor ((,,,) a b c) | Since: base-4.14.0.0 |
Functor ((->) r) | Since: base-2.1 |
(Functor f, Functor g) => Functor (Compose f g) | Since: base-4.9.0.0 |
(Functor f, Functor g) => Functor (f :.: g) | Since: base-4.9.0.0 |
Functor f => Functor (M1 i c f) | Since: base-4.9.0.0 |
Functor f => Functor (WhenMatched f k x y) | Since: containers-0.5.9 |
Defined in Data.Map.Internal fmap :: (a -> b) -> WhenMatched f k x y a -> WhenMatched f k x y b # (<$) :: a -> WhenMatched f k x y b -> WhenMatched f k x y a # | |
Functor m => Functor (RWST r w s m) | |
Functor m => Functor (RWST r w s m) | |
class Monad m => MonadFail (m :: Type -> Type) where #
When a value is bound in do
-notation, the pattern on the left
hand side of <-
might not match. In this case, this class
provides a function to recover.
A Monad
without a MonadFail
instance may only be used in conjunction
with pattern that always match, such as newtypes, tuples, data types with
only a single data constructor, and irrefutable patterns (~pat
).
Instances of MonadFail
should satisfy the following law: fail s
should
be a left zero for >>=
,
fail s >>= f = fail s
If your Monad
is also MonadPlus
, a popular definition is
fail _ = mzero
Since: base-4.9.0.0
Instances
class Functor f => Applicative (f :: Type -> Type) where #
A functor with application, providing operations to
A minimal complete definition must include implementations of pure
and of either <*>
or liftA2
. If it defines both, then they must behave
the same as their default definitions:
(<*>
) =liftA2
id
liftA2
f x y = f<$>
x<*>
y
Further, any definition must satisfy the following:
- Identity
pure
id
<*>
v = v- Composition
pure
(.)<*>
u<*>
v<*>
w = u<*>
(v<*>
w)- Homomorphism
pure
f<*>
pure
x =pure
(f x)- Interchange
u
<*>
pure
y =pure
($
y)<*>
u
The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:
As a consequence of these laws, the Functor
instance for f
will satisfy
It may be useful to note that supposing
forall x y. p (q x y) = f x . g y
it follows from the above that
liftA2
p (liftA2
q u v) =liftA2
f u .liftA2
g v
If f
is also a Monad
, it should satisfy
(which implies that pure
and <*>
satisfy the applicative functor laws).
Lift a value.
(<*>) :: f (a -> b) -> f a -> f b infixl 4 #
Sequential application.
A few functors support an implementation of <*>
that is more
efficient than the default one.
Example
Used in combination with (
, <$>
)(
can be used to build a record.<*>
)
>>>
data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
>>>
produceFoo :: Applicative f => f Foo
>>>
produceBar :: Applicative f => f Bar
>>>
produceBaz :: Applicative f => f Baz
>>>
mkState :: Applicative f => f MyState
>>>
mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz
liftA2 :: (a -> b -> c) -> f a -> f b -> f c #
Lift a binary function to actions.
Some functors support an implementation of liftA2
that is more
efficient than the default one. In particular, if fmap
is an
expensive operation, it is likely better to use liftA2
than to
fmap
over the structure and then use <*>
.
This became a typeclass method in 4.10.0.0. Prior to that, it was
a function defined in terms of <*>
and fmap
.
Example
>>>
liftA2 (,) (Just 3) (Just 5)
Just (3,5)
(*>) :: f a -> f b -> f b infixl 4 #
Sequence actions, discarding the value of the first argument.
Examples
If used in conjunction with the Applicative instance for Maybe
,
you can chain Maybe computations, with a possible "early return"
in case of Nothing
.
>>>
Just 2 *> Just 3
Just 3
>>>
Nothing *> Just 3
Nothing
Of course a more interesting use case would be to have effectful computations instead of just returning pure values.
>>>
import Data.Char
>>>
import Text.ParserCombinators.ReadP
>>>
let p = string "my name is " *> munch1 isAlpha <* eof
>>>
readP_to_S p "my name is Simon"
[("Simon","")]
(<*) :: f a -> f b -> f a infixl 4 #
Sequence actions, discarding the value of the second argument.
Instances
Applicative ZipList | f <$> ZipList xs1 <*> ... <*> ZipList xsN = ZipList (zipWithN f xs1 ... xsN) where (\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..] = ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..]) = ZipList {getZipList = ["a5","b6b6","c7c7c7"]} Since: base-2.1 |
Applicative Complex | Since: base-4.9.0.0 |
Applicative Identity | Since: base-4.8.0.0 |
Applicative First | Since: base-4.8.0.0 |
Applicative Last | Since: base-4.8.0.0 |
Applicative Down | Since: base-4.11.0.0 |
Applicative First | Since: base-4.9.0.0 |
Applicative Last | Since: base-4.9.0.0 |
Applicative Max | Since: base-4.9.0.0 |
Applicative Min | Since: base-4.9.0.0 |
Applicative Dual | Since: base-4.8.0.0 |
Applicative Product | Since: base-4.8.0.0 |
Applicative Sum | Since: base-4.8.0.0 |
Applicative STM | Since: base-4.8.0.0 |
Applicative Par1 | Since: base-4.9.0.0 |
Applicative P | Since: base-4.5.0.0 |
Applicative ReadP | Since: base-4.6.0.0 |
Applicative ReadPrec | Since: base-4.6.0.0 |
Applicative Seq | Since: containers-0.5.4 |
Applicative Tree | |
Applicative IO | Since: base-2.1 |
Applicative Q | |
Applicative Query | |
Applicative X | |
Applicative FocusQuery Source # | |
Defined in XMonad.Hooks.Focus pure :: a -> FocusQuery a # (<*>) :: FocusQuery (a -> b) -> FocusQuery a -> FocusQuery b # liftA2 :: (a -> b -> c) -> FocusQuery a -> FocusQuery b -> FocusQuery c # (*>) :: FocusQuery a -> FocusQuery b -> FocusQuery b # (<*) :: FocusQuery a -> FocusQuery b -> FocusQuery a # | |
Applicative Parser Source # | |
Applicative PureX Source # | |
Applicative NonEmpty | Since: base-4.9.0.0 |
Applicative Maybe | Since: base-2.1 |
Applicative Solo | Since: base-4.15 |
Applicative [] | Since: base-2.1 |
Monad m => Applicative (WrappedMonad m) | Since: base-2.1 |
Defined in Control.Applicative pure :: a -> WrappedMonad m a # (<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b # liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c # (*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b # (<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a # | |
Arrow a => Applicative (ArrowMonad a) | Since: base-4.6.0.0 |
Defined in Control.Arrow pure :: a0 -> ArrowMonad a a0 # (<*>) :: ArrowMonad a (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b # liftA2 :: (a0 -> b -> c) -> ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a c # (*>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b # (<*) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a a0 # | |
Applicative (Either e) | Since: base-3.0 |
Applicative (StateL s) | Since: base-4.0 |
Applicative (StateR s) | Since: base-4.0 |
Applicative (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Applicative (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Applicative m => Applicative (ListT m) | |
(Functor m, Monad m) => Applicative (MaybeT m) | |
Applicative (TwoD a) Source # | |
Applicative m => Applicative (Invisible m) Source # | |
Defined in XMonad.Util.Invisible | |
Applicative (StateQuery s) Source # | |
Defined in XMonad.Util.WindowState pure :: a -> StateQuery s a # (<*>) :: StateQuery s (a -> b) -> StateQuery s a -> StateQuery s b # liftA2 :: (a -> b -> c) -> StateQuery s a -> StateQuery s b -> StateQuery s c # (*>) :: StateQuery s a -> StateQuery s b -> StateQuery s b # (<*) :: StateQuery s a -> StateQuery s b -> StateQuery s a # | |
Monoid a => Applicative ((,) a) | For tuples, the ("hello ", (+15)) <*> ("world!", 2002) ("hello world!",2017) Since: base-2.1 |
Arrow a => Applicative (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative pure :: a0 -> WrappedArrow a b a0 # (<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 # liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c # (*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 # (<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 # | |
Applicative m => Applicative (Kleisli m a) | Since: base-4.14.0.0 |
Defined in Control.Arrow | |
Monoid m => Applicative (Const m :: Type -> Type) | Since: base-2.0.1 |
Applicative f => Applicative (Ap f) | Since: base-4.12.0.0 |
Applicative f => Applicative (Alt f) | Since: base-4.8.0.0 |
Applicative f => Applicative (Rec1 f) | Since: base-4.9.0.0 |
(Applicative f, Monad f) => Applicative (WhenMissing f x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal pure :: a -> WhenMissing f x a # (<*>) :: WhenMissing f x (a -> b) -> WhenMissing f x a -> WhenMissing f x b # liftA2 :: (a -> b -> c) -> WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x c # (*>) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x b # (<*) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x a # | |
(Functor m, Monad m) => Applicative (ErrorT e m) | |
Defined in Control.Monad.Trans.Error | |
(Functor m, Monad m) => Applicative (ExceptT e m) | |
Defined in Control.Monad.Trans.Except | |
Applicative m => Applicative (IdentityT m) | |
Defined in Control.Monad.Trans.Identity | |
Applicative m => Applicative (ReaderT r m) | |
Defined in Control.Monad.Trans.Reader | |
(Functor m, Monad m) => Applicative (StateT s m) | |
Defined in Control.Monad.Trans.State.Lazy | |
(Functor m, Monad m) => Applicative (StateT s m) | |
Defined in Control.Monad.Trans.State.Strict | |
(Monoid w, Applicative m) => Applicative (WriterT w m) | |
Defined in Control.Monad.Trans.Writer.Lazy | |
(Monoid w, Applicative m) => Applicative (WriterT w m) | |
Defined in Control.Monad.Trans.Writer.Strict | |
(Monoid a, Monoid b) => Applicative ((,,) a b) | Since: base-4.14.0.0 |
(Applicative f, Applicative g) => Applicative (Product f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product | |
(Applicative f, Applicative g) => Applicative (f :*: g) | Since: base-4.9.0.0 |
Monoid c => Applicative (K1 i c :: Type -> Type) | Since: base-4.12.0.0 |
(Monad f, Applicative f) => Applicative (WhenMatched f x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal pure :: a -> WhenMatched f x y a # (<*>) :: WhenMatched f x y (a -> b) -> WhenMatched f x y a -> WhenMatched f x y b # liftA2 :: (a -> b -> c) -> WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y c # (*>) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y b # (<*) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y a # | |
(Applicative f, Monad f) => Applicative (WhenMissing f k x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal pure :: a -> WhenMissing f k x a # (<*>) :: WhenMissing f k x (a -> b) -> WhenMissing f k x a -> WhenMissing f k x b # liftA2 :: (a -> b -> c) -> WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x c # (*>) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x b # (<*) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x a # | |
Applicative (ContT r m) | |
(Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c) | Since: base-4.14.0.0 |
Defined in GHC.Base | |
Applicative ((->) r) | Since: base-2.1 |
(Applicative f, Applicative g) => Applicative (Compose f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose | |
(Applicative f, Applicative g) => Applicative (f :.: g) | Since: base-4.9.0.0 |
Applicative f => Applicative (M1 i c f) | Since: base-4.9.0.0 |
(Monad f, Applicative f) => Applicative (WhenMatched f k x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal pure :: a -> WhenMatched f k x y a # (<*>) :: WhenMatched f k x y (a -> b) -> WhenMatched f k x y a -> WhenMatched f k x y b # liftA2 :: (a -> b -> c) -> WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y c # (*>) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y b # (<*) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y a # | |
(Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) | |
Defined in Control.Monad.Trans.RWS.Lazy | |
(Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) | |
Defined in Control.Monad.Trans.RWS.Strict |
class Foldable (t :: TYPE LiftedRep -> Type) where #
The Foldable class represents data structures that can be reduced to a summary value one element at a time. Strict left-associative folds are a good fit for space-efficient reduction, while lazy right-associative folds are a good fit for corecursive iteration, or for folds that short-circuit after processing an initial subsequence of the structure's elements.
Instances can be derived automatically by enabling the DeriveFoldable
extension. For example, a derived instance for a binary tree might be:
{-# LANGUAGE DeriveFoldable #-} data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a) deriving Foldable
A more detailed description can be found in the Overview section of Data.Foldable.
For the class laws see the Laws section of Data.Foldable.
fold :: Monoid m => t m -> m #
Given a structure with elements whose type is a Monoid
, combine them
via the monoid's (
operator. This fold is right-associative and
lazy in the accumulator. When you need a strict left-associative fold,
use <>
)foldMap'
instead, with id
as the map.
Examples
Basic usage:
>>>
fold [[1, 2, 3], [4, 5], [6], []]
[1,2,3,4,5,6]
>>>
fold $ Node (Leaf (Sum 1)) (Sum 3) (Leaf (Sum 5))
Sum {getSum = 9}
Folds of unbounded structures do not terminate when the monoid's
(
operator is strict:<>
)
>>>
fold (repeat Nothing)
* Hangs forever *
Lazy corecursive folds of unbounded structures are fine:
>>>
take 12 $ fold $ map (\i -> [i..i+2]) [0..]
[0,1,2,1,2,3,2,3,4,3,4,5]>>>
sum $ take 4000000 $ fold $ map (\i -> [i..i+2]) [0..]
2666668666666
foldMap :: Monoid m => (a -> m) -> t a -> m #
Map each element of the structure into a monoid, and combine the
results with (
. This fold is right-associative and lazy in the
accumulator. For strict left-associative folds consider <>
)foldMap'
instead.
Examples
Basic usage:
>>>
foldMap Sum [1, 3, 5]
Sum {getSum = 9}
>>>
foldMap Product [1, 3, 5]
Product {getProduct = 15}
>>>
foldMap (replicate 3) [1, 2, 3]
[1,1,1,2,2,2,3,3,3]
When a Monoid's (
is lazy in its second argument, <>
)foldMap
can
return a result even from an unbounded structure. For example, lazy
accumulation enables Data.ByteString.Builder to efficiently serialise
large data structures and produce the output incrementally:
>>>
import qualified Data.ByteString.Lazy as L
>>>
import qualified Data.ByteString.Builder as B
>>>
let bld :: Int -> B.Builder; bld i = B.intDec i <> B.word8 0x20
>>>
let lbs = B.toLazyByteString $ foldMap bld [0..]
>>>
L.take 64 lbs
"0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"
foldMap' :: Monoid m => (a -> m) -> t a -> m #
A left-associative variant of foldMap
that is strict in the
accumulator. Use this method for strict reduction when partial
results are merged via (
.<>
)
Examples
Define a Monoid
over finite bit strings under xor
. Use it to
strictly compute the xor
of a list of Int
values.
>>>
:set -XGeneralizedNewtypeDeriving
>>>
import Data.Bits (Bits, FiniteBits, xor, zeroBits)
>>>
import Data.Foldable (foldMap')
>>>
import Numeric (showHex)
>>>
>>>
newtype X a = X a deriving (Eq, Bounded, Enum, Bits, FiniteBits)
>>>
instance Bits a => Semigroup (X a) where X a <> X b = X (a `xor` b)
>>>
instance Bits a => Monoid (X a) where mempty = X zeroBits
>>>
>>>
let bits :: [Int]; bits = [0xcafe, 0xfeed, 0xdeaf, 0xbeef, 0x5411]
>>>
(\ (X a) -> showString "0x" . showHex a $ "") $ foldMap' X bits
"0x42"
Since: base-4.13.0.0
foldr :: (a -> b -> b) -> b -> t a -> b #
Right-associative fold of a structure, lazy in the accumulator.
In the case of lists, foldr
, when applied to a binary operator, a
starting value (typically the right-identity of the operator), and a
list, reduces the list using the binary operator, from right to left:
foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
Note that since the head of the resulting expression is produced by an
application of the operator to the first element of the list, given an
operator lazy in its right argument, foldr
can produce a terminating
expression from an unbounded list.
For a general Foldable
structure this should be semantically identical
to,
foldr f z =foldr
f z .toList
Examples
Basic usage:
>>>
foldr (||) False [False, True, False]
True
>>>
foldr (||) False []
False
>>>
foldr (\c acc -> acc ++ [c]) "foo" ['a', 'b', 'c', 'd']
"foodcba"
Infinite structures
⚠️ Applying foldr
to infinite structures usually doesn't terminate.
It may still terminate under one of the following conditions:
- the folding function is short-circuiting
- the folding function is lazy on its second argument
Short-circuiting
(
short-circuits on ||
)True
values, so the following terminates
because there is a True
value finitely far from the left side:
>>>
foldr (||) False (True : repeat False)
True
But the following doesn't terminate:
>>>
foldr (||) False (repeat False ++ [True])
* Hangs forever *
Laziness in the second argument
Applying foldr
to infinite structures terminates when the operator is
lazy in its second argument (the initial accumulator is never used in
this case, and so could be left undefined
, but []
is more clear):
>>>
take 5 $ foldr (\i acc -> i : fmap (+3) acc) [] (repeat 1)
[1,4,7,10,13]
foldr' :: (a -> b -> b) -> b -> t a -> b #
Right-associative fold of a structure, strict in the accumulator. This is rarely what you want.
Since: base-4.6.0.0
foldl :: (b -> a -> b) -> b -> t a -> b #
Left-associative fold of a structure, lazy in the accumulator. This is rarely what you want, but can work well for structures with efficient right-to-left sequencing and an operator that is lazy in its left argument.
In the case of lists, foldl
, when applied to a binary operator, a
starting value (typically the left-identity of the operator), and a
list, reduces the list using the binary operator, from left to right:
foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
Note that to produce the outermost application of the operator the
entire input list must be traversed. Like all left-associative folds,
foldl
will diverge if given an infinite list.
If you want an efficient strict left-fold, you probably want to use
foldl'
instead of foldl
. The reason for this is that the latter
does not force the inner results (e.g. z `f` x1
in the above
example) before applying them to the operator (e.g. to (`f` x2)
).
This results in a thunk chain \(\mathcal{O}(n)\) elements long, which
then must be evaluated from the outside-in.
For a general Foldable
structure this should be semantically identical
to:
foldl f z =foldl
f z .toList
Examples
The first example is a strict fold, which in practice is best performed
with foldl'
.
>>>
foldl (+) 42 [1,2,3,4]
52
Though the result below is lazy, the input is reversed before prepending it to the initial accumulator, so corecursion begins only after traversing the entire input string.
>>>
foldl (\acc c -> c : acc) "abcd" "efgh"
"hgfeabcd"
A left fold of a structure that is infinite on the right cannot terminate, even when for any finite input the fold just returns the initial accumulator:
>>>
foldl (\a _ -> a) 0 $ repeat 1
* Hangs forever *
WARNING: When it comes to lists, you always want to use either foldl'
or foldr
instead.
foldl' :: (b -> a -> b) -> b -> t a -> b #
Left-associative fold of a structure but with strict application of the operator.
This ensures that each step of the fold is forced to Weak Head Normal
Form before being applied, avoiding the collection of thunks that would
otherwise occur. This is often what you want to strictly reduce a
finite structure to a single strict result (e.g. sum
).
For a general Foldable
structure this should be semantically identical
to,
foldl' f z =foldl'
f z .toList
Since: base-4.6.0.0
foldr1 :: (a -> a -> a) -> t a -> a #
A variant of foldr
that has no base case,
and thus may only be applied to non-empty structures.
This function is non-total and will raise a runtime exception if the structure happens to be empty.
Examples
Basic usage:
>>>
foldr1 (+) [1..4]
10
>>>
foldr1 (+) []
Exception: Prelude.foldr1: empty list
>>>
foldr1 (+) Nothing
*** Exception: foldr1: empty structure
>>>
foldr1 (-) [1..4]
-2
>>>
foldr1 (&&) [True, False, True, True]
False
>>>
foldr1 (||) [False, False, True, True]
True
>>>
foldr1 (+) [1..]
* Hangs forever *
foldl1 :: (a -> a -> a) -> t a -> a #
A variant of foldl
that has no base case,
and thus may only be applied to non-empty structures.
This function is non-total and will raise a runtime exception if the structure happens to be empty.
foldl1
f =foldl1
f .toList
Examples
Basic usage:
>>>
foldl1 (+) [1..4]
10
>>>
foldl1 (+) []
*** Exception: Prelude.foldl1: empty list
>>>
foldl1 (+) Nothing
*** Exception: foldl1: empty structure
>>>
foldl1 (-) [1..4]
-8
>>>
foldl1 (&&) [True, False, True, True]
False
>>>
foldl1 (||) [False, False, True, True]
True
>>>
foldl1 (+) [1..]
* Hangs forever *
Test whether the structure is empty. The default implementation is Left-associative and lazy in both the initial element and the accumulator. Thus optimised for structures where the first element can be accessed in constant time. Structures where this is not the case should have a non-default implementation.
Examples
Basic usage:
>>>
null []
True
>>>
null [1]
False
null
is expected to terminate even for infinite structures.
The default implementation terminates provided the structure
is bounded on the left (there is a leftmost element).
>>>
null [1..]
False
Since: base-4.8.0.0
Returns the size/length of a finite structure as an Int
. The
default implementation just counts elements starting with the leftmost.
Instances for structures that can compute the element count faster
than via element-by-element counting, should provide a specialised
implementation.
Examples
Basic usage:
>>>
length []
0
>>>
length ['a', 'b', 'c']
3>>>
length [1..]
* Hangs forever *
Since: base-4.8.0.0
elem :: Eq a => a -> t a -> Bool infix 4 #
Does the element occur in the structure?
Note: elem
is often used in infix form.
Examples
Basic usage:
>>>
3 `elem` []
False
>>>
3 `elem` [1,2]
False
>>>
3 `elem` [1,2,3,4,5]
True
For infinite structures, the default implementation of elem
terminates if the sought-after value exists at a finite distance
from the left side of the structure:
>>>
3 `elem` [1..]
True
>>>
3 `elem` ([4..] ++ [3])
* Hangs forever *
Since: base-4.8.0.0
maximum :: Ord a => t a -> a #
The largest element of a non-empty structure.
This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the maximum in faster than linear time.
Examples
Basic usage:
>>>
maximum [1..10]
10
>>>
maximum []
*** Exception: Prelude.maximum: empty list
>>>
maximum Nothing
*** Exception: maximum: empty structure
WARNING: This function is partial for possibly-empty structures like lists.
Since: base-4.8.0.0
minimum :: Ord a => t a -> a #
The least element of a non-empty structure.
This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the minimum in faster than linear time.
Examples
Basic usage:
>>>
minimum [1..10]
1
>>>
minimum []
*** Exception: Prelude.minimum: empty list
>>>
minimum Nothing
*** Exception: minimum: empty structure
WARNING: This function is partial for possibly-empty structures like lists.
Since: base-4.8.0.0
The sum
function computes the sum of the numbers of a structure.
Examples
Basic usage:
>>>
sum []
0
>>>
sum [42]
42
>>>
sum [1..10]
55
>>>
sum [4.1, 2.0, 1.7]
7.8
>>>
sum [1..]
* Hangs forever *
Since: base-4.8.0.0
product :: Num a => t a -> a #
The product
function computes the product of the numbers of a
structure.
Examples
Basic usage:
>>>
product []
1
>>>
product [42]
42
>>>
product [1..10]
3628800
>>>
product [4.1, 2.0, 1.7]
13.939999999999998
>>>
product [1..]
* Hangs forever *
Since: base-4.8.0.0
Instances
Foldable ZipList | Since: base-4.9.0.0 |
Defined in Control.Applicative fold :: Monoid m => ZipList m -> m # foldMap :: Monoid m => (a -> m) -> ZipList a -> m # foldMap' :: Monoid m => (a -> m) -> ZipList a -> m # foldr :: (a -> b -> b) -> b -> ZipList a -> b # foldr' :: (a -> b -> b) -> b -> ZipList a -> b # foldl :: (b -> a -> b) -> b -> ZipList a -> b # foldl' :: (b -> a -> b) -> b -> ZipList a -> b # foldr1 :: (a -> a -> a) -> ZipList a -> a # foldl1 :: (a -> a -> a) -> ZipList a -> a # elem :: Eq a => a -> ZipList a -> Bool # maximum :: Ord a => ZipList a -> a # minimum :: Ord a => ZipList a -> a # | |
Foldable Complex | Since: base-4.9.0.0 |
Defined in Data.Complex fold :: Monoid m => Complex m -> m # foldMap :: Monoid m => (a -> m) -> Complex a -> m # foldMap' :: Monoid m => (a -> m) -> Complex a -> m # foldr :: (a -> b -> b) -> b -> Complex a -> b # foldr' :: (a -> b -> b) -> b -> Complex a -> b # foldl :: (b -> a -> b) -> b -> Complex a -> b # foldl' :: (b -> a -> b) -> b -> Complex a -> b # foldr1 :: (a -> a -> a) -> Complex a -> a # foldl1 :: (a -> a -> a) -> Complex a -> a # elem :: Eq a => a -> Complex a -> Bool # maximum :: Ord a => Complex a -> a # minimum :: Ord a => Complex a -> a # | |
Foldable Identity | Since: base-4.8.0.0 |
Defined in Data.Functor.Identity fold :: Monoid m => Identity m -> m # foldMap :: Monoid m => (a -> m) -> Identity a -> m # foldMap' :: Monoid m => (a -> m) -> Identity a -> m # foldr :: (a -> b -> b) -> b -> Identity a -> b # foldr' :: (a -> b -> b) -> b -> Identity a -> b # foldl :: (b -> a -> b) -> b -> Identity a -> b # foldl' :: (b -> a -> b) -> b -> Identity a -> b # foldr1 :: (a -> a -> a) -> Identity a -> a # foldl1 :: (a -> a -> a) -> Identity a -> a # elem :: Eq a => a -> Identity a -> Bool # maximum :: Ord a => Identity a -> a # minimum :: Ord a => Identity a -> a # | |
Foldable First | Since: base-4.8.0.0 |
Defined in Data.Foldable fold :: Monoid m => First m -> m # foldMap :: Monoid m => (a -> m) -> First a -> m # foldMap' :: Monoid m => (a -> m) -> First a -> m # foldr :: (a -> b -> b) -> b -> First a -> b # foldr' :: (a -> b -> b) -> b -> First a -> b # foldl :: (b -> a -> b) -> b -> First a -> b # foldl' :: (b -> a -> b) -> b -> First a -> b # foldr1 :: (a -> a -> a) -> First a -> a # foldl1 :: (a -> a -> a) -> First a -> a # elem :: Eq a => a -> First a -> Bool # maximum :: Ord a => First a -> a # minimum :: Ord a => First a -> a # | |
Foldable Last | Since: base-4.8.0.0 |
Defined in Data.Foldable fold :: Monoid m => Last m -> m # foldMap :: Monoid m => (a -> m) -> Last a -> m # foldMap' :: Monoid m => (a -> m) -> Last a -> m # foldr :: (a -> b -> b) -> b -> Last a -> b # foldr' :: (a -> b -> b) -> b -> Last a -> b # foldl :: (b -> a -> b) -> b -> Last a -> b # foldl' :: (b -> a -> b) -> b -> Last a -> b # foldr1 :: (a -> a -> a) -> Last a -> a # foldl1 :: (a -> a -> a) -> Last a -> a # elem :: Eq a => a -> Last a -> Bool # maximum :: Ord a => Last a -> a # | |
Foldable Down | Since: base-4.12.0.0 |
Defined in Data.Foldable fold :: Monoid m => Down m -> m # foldMap :: Monoid m => (a -> m) -> Down a -> m # foldMap' :: Monoid m => (a -> m) -> Down a -> m # foldr :: (a -> b -> b) -> b -> Down a -> b # foldr' :: (a -> b -> b) -> b -> Down a -> b # foldl :: (b -> a -> b) -> b -> Down a -> b # foldl' :: (b -> a -> b) -> b -> Down a -> b # foldr1 :: (a -> a -> a) -> Down a -> a # foldl1 :: (a -> a -> a) -> Down a -> a # elem :: Eq a => a -> Down a -> Bool # maximum :: Ord a => Down a -> a # | |
Foldable First | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => First m -> m # foldMap :: Monoid m => (a -> m) -> First a -> m # foldMap' :: Monoid m => (a -> m) -> First a -> m # foldr :: (a -> b -> b) -> b -> First a -> b # foldr' :: (a -> b -> b) -> b -> First a -> b # foldl :: (b -> a -> b) -> b -> First a -> b # foldl' :: (b -> a -> b) -> b -> First a -> b # foldr1 :: (a -> a -> a) -> First a -> a # foldl1 :: (a -> a -> a) -> First a -> a # elem :: Eq a => a -> First a -> Bool # maximum :: Ord a => First a -> a # minimum :: Ord a => First a -> a # | |
Foldable Last | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Last m -> m # foldMap :: Monoid m => (a -> m) -> Last a -> m # foldMap' :: Monoid m => (a -> m) -> Last a -> m # foldr :: (a -> b -> b) -> b -> Last a -> b # foldr' :: (a -> b -> b) -> b -> Last a -> b # foldl :: (b -> a -> b) -> b -> Last a -> b # foldl' :: (b -> a -> b) -> b -> Last a -> b # foldr1 :: (a -> a -> a) -> Last a -> a # foldl1 :: (a -> a -> a) -> Last a -> a # elem :: Eq a => a -> Last a -> Bool # maximum :: Ord a => Last a -> a # | |
Foldable Max | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Max m -> m # foldMap :: Monoid m => (a -> m) -> Max a -> m # foldMap' :: Monoid m => (a -> m) -> Max a -> m # foldr :: (a -> b -> b) -> b -> Max a -> b # foldr' :: (a -> b -> b) -> b -> Max a -> b # foldl :: (b -> a -> b) -> b -> Max a -> b # foldl' :: (b -> a -> b) -> b -> Max a -> b # foldr1 :: (a -> a -> a) -> Max a -> a # foldl1 :: (a -> a -> a) -> Max a -> a # elem :: Eq a => a -> Max a -> Bool # maximum :: Ord a => Max a -> a # | |
Foldable Min | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Min m -> m # foldMap :: Monoid m => (a -> m) -> Min a -> m # foldMap' :: Monoid m => (a -> m) -> Min a -> m # foldr :: (a -> b -> b) -> b -> Min a -> b # foldr' :: (a -> b -> b) -> b -> Min a -> b # foldl :: (b -> a -> b) -> b -> Min a -> b # foldl' :: (b -> a -> b) -> b -> Min a -> b # foldr1 :: (a -> a -> a) -> Min a -> a # foldl1 :: (a -> a -> a) -> Min a -> a # elem :: Eq a => a -> Min a -> Bool # maximum :: Ord a => Min a -> a # | |
Foldable Dual | Since: base-4.8.0.0 |
Defined in Data.Foldable fold :: Monoid m => Dual m -> m # foldMap :: Monoid m => (a -> m) -> Dual a -> m # foldMap' :: Monoid m => (a -> m) -> Dual a -> m # foldr :: (a -> b -> b) -> b -> Dual a -> b # foldr' :: (a -> b -> b) -> b -> Dual a -> b # foldl :: (b -> a -> b) -> b -> Dual a -> b # foldl' :: (b -> a -> b) -> b -> Dual a -> b # foldr1 :: (a -> a -> a) -> Dual a -> a # foldl1 :: (a -> a -> a) -> Dual a -> a # elem :: Eq a => a -> Dual a -> Bool # maximum :: Ord a => Dual a -> a # | |
Foldable Product | Since: base-4.8.0.0 |
Defined in Data.Foldable fold :: Monoid m => Product m -> m # foldMap :: Monoid m => (a -> m) -> Product a -> m # foldMap' :: Monoid m => (a -> m) -> Product a -> m # foldr :: (a -> b -> b) -> b -> Product a -> b # foldr' :: (a -> b -> b) -> b -> Product a -> b # foldl :: (b -> a -> b) -> b -> Product a -> b # foldl' :: (b -> a -> b) -> b -> Product a -> b # foldr1 :: (a -> a -> a) -> Product a -> a # foldl1 :: (a -> a -> a) -> Product a -> a # elem :: Eq a => a -> Product a -> Bool # maximum :: Ord a => Product a -> a # minimum :: Ord a => Product a -> a # | |
Foldable Sum | Since: base-4.8.0.0 |
Defined in Data.Foldable fold :: Monoid m => Sum m -> m # foldMap :: Monoid m => (a -> m) -> Sum a -> m # foldMap' :: Monoid m => (a -> m) -> Sum a -> m # foldr :: (a -> b -> b) -> b -> Sum a -> b # foldr' :: (a -> b -> b) -> b -> Sum a -> b # foldl :: (b -> a -> b) -> b -> Sum a -> b # foldl' :: (b -> a -> b) -> b -> Sum a -> b # foldr1 :: (a -> a -> a) -> Sum a -> a # foldl1 :: (a -> a -> a) -> Sum a -> a # elem :: Eq a => a -> Sum a -> Bool # maximum :: Ord a => Sum a -> a # | |
Foldable Par1 | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => Par1 m -> m # foldMap :: Monoid m => (a -> m) -> Par1 a -> m # foldMap' :: Monoid m => (a -> m) -> Par1 a -> m # foldr :: (a -> b -> b) -> b -> Par1 a -> b # foldr' :: (a -> b -> b) -> b -> Par1 a -> b # foldl :: (b -> a -> b) -> b -> Par1 a -> b # foldl' :: (b -> a -> b) -> b -> Par1 a -> b # foldr1 :: (a -> a -> a) -> Par1 a -> a # foldl1 :: (a -> a -> a) -> Par1 a -> a # elem :: Eq a => a -> Par1 a -> Bool # maximum :: Ord a => Par1 a -> a # | |
Foldable IntMap | Folds in order of increasing key. |
Defined in Data.IntMap.Internal fold :: Monoid m => IntMap m -> m # foldMap :: Monoid m => (a -> m) -> IntMap a -> m # foldMap' :: Monoid m => (a -> m) -> IntMap a -> m # foldr :: (a -> b -> b) -> b -> IntMap a -> b # foldr' :: (a -> b -> b) -> b -> IntMap a -> b # foldl :: (b -> a -> b) -> b -> IntMap a -> b # foldl' :: (b -> a -> b) -> b -> IntMap a -> b # foldr1 :: (a -> a -> a) -> IntMap a -> a # foldl1 :: (a -> a -> a) -> IntMap a -> a # elem :: Eq a => a -> IntMap a -> Bool # maximum :: Ord a => IntMap a -> a # minimum :: Ord a => IntMap a -> a # | |
Foldable Digit | |
Defined in Data.Sequence.Internal fold :: Monoid m => Digit m -> m # foldMap :: Monoid m => (a -> m) -> Digit a -> m # foldMap' :: Monoid m => (a -> m) -> Digit a -> m # foldr :: (a -> b -> b) -> b -> Digit a -> b # foldr' :: (a -> b -> b) -> b -> Digit a -> b # foldl :: (b -> a -> b) -> b -> Digit a -> b # foldl' :: (b -> a -> b) -> b -> Digit a -> b # foldr1 :: (a -> a -> a) -> Digit a -> a # foldl1 :: (a -> a -> a) -> Digit a -> a # elem :: Eq a => a -> Digit a -> Bool # maximum :: Ord a => Digit a -> a # minimum :: Ord a => Digit a -> a # | |
Foldable Elem | |
Defined in Data.Sequence.Internal fold :: Monoid m => Elem m -> m # foldMap :: Monoid m => (a -> m) -> Elem a -> m # foldMap' :: Monoid m => (a -> m) -> Elem a -> m # foldr :: (a -> b -> b) -> b -> Elem a -> b # foldr' :: (a -> b -> b) -> b -> Elem a -> b # foldl :: (b -> a -> b) -> b -> Elem a -> b # foldl' :: (b -> a -> b) -> b -> Elem a -> b # foldr1 :: (a -> a -> a) -> Elem a -> a # foldl1 :: (a -> a -> a) -> Elem a -> a # elem :: Eq a => a -> Elem a -> Bool # maximum :: Ord a => Elem a -> a # | |
Foldable FingerTree | |
Defined in Data.Sequence.Internal fold :: Monoid m => FingerTree m -> m # foldMap :: Monoid m => (a -> m) -> FingerTree a -> m # foldMap' :: Monoid m => (a -> m) -> FingerTree a -> m # foldr :: (a -> b -> b) -> b -> FingerTree a -> b # foldr' :: (a -> b -> b) -> b -> FingerTree a -> b # foldl :: (b -> a -> b) -> b -> FingerTree a -> b # foldl' :: (b -> a -> b) -> b -> FingerTree a -> b # foldr1 :: (a -> a -> a) -> FingerTree a -> a # foldl1 :: (a -> a -> a) -> FingerTree a -> a # toList :: FingerTree a -> [a] # null :: FingerTree a -> Bool # length :: FingerTree a -> Int # elem :: Eq a => a -> FingerTree a -> Bool # maximum :: Ord a => FingerTree a -> a # minimum :: Ord a => FingerTree a -> a # sum :: Num a => FingerTree a -> a # product :: Num a => FingerTree a -> a # | |
Foldable Node | |
Defined in Data.Sequence.Internal fold :: Monoid m => Node m -> m # foldMap :: Monoid m => (a -> m) -> Node a -> m # foldMap' :: Monoid m => (a -> m) -> Node a -> m # foldr :: (a -> b -> b) -> b -> Node a -> b # foldr' :: (a -> b -> b) -> b -> Node a -> b # foldl :: (b -> a -> b) -> b -> Node a -> b # foldl' :: (b -> a -> b) -> b -> Node a -> b # foldr1 :: (a -> a -> a) -> Node a -> a # foldl1 :: (a -> a -> a) -> Node a -> a # elem :: Eq a => a -> Node a -> Bool # maximum :: Ord a => Node a -> a # | |
Foldable Seq | |
Defined in Data.Sequence.Internal fold :: Monoid m => Seq m -> m # foldMap :: Monoid m => (a -> m) -> Seq a -> m # foldMap' :: Monoid m => (a -> m) -> Seq a -> m # foldr :: (a -> b -> b) -> b -> Seq a -> b # foldr' :: (a -> b -> b) -> b -> Seq a -> b # foldl :: (b -> a -> b) -> b -> Seq a -> b # foldl' :: (b -> a -> b) -> b -> Seq a -> b # foldr1 :: (a -> a -> a) -> Seq a -> a # foldl1 :: (a -> a -> a) -> Seq a -> a # elem :: Eq a => a -> Seq a -> Bool # maximum :: Ord a => Seq a -> a # | |
Foldable ViewL | |
Defined in Data.Sequence.Internal fold :: Monoid m => ViewL m -> m # foldMap :: Monoid m => (a -> m) -> ViewL a -> m # foldMap' :: Monoid m => (a -> m) -> ViewL a -> m # foldr :: (a -> b -> b) -> b -> ViewL a -> b # foldr' :: (a -> b -> b) -> b -> ViewL a -> b # foldl :: (b -> a -> b) -> b -> ViewL a -> b # foldl' :: (b -> a -> b) -> b -> ViewL a -> b # foldr1 :: (a -> a -> a) -> ViewL a -> a # foldl1 :: (a -> a -> a) -> ViewL a -> a # elem :: Eq a => a -> ViewL a -> Bool # maximum :: Ord a => ViewL a -> a # minimum :: Ord a => ViewL a -> a # | |
Foldable ViewR | |
Defined in Data.Sequence.Internal fold :: Monoid m => ViewR m -> m # foldMap :: Monoid m => (a -> m) -> ViewR a -> m # foldMap' :: Monoid m => (a -> m) -> ViewR a -> m # foldr :: (a -> b -> b) -> b -> ViewR a -> b # foldr' :: (a -> b -> b) -> b -> ViewR a -> b # foldl :: (b -> a -> b) -> b -> ViewR a -> b # foldl' :: (b -> a -> b) -> b -> ViewR a -> b # foldr1 :: (a -> a -> a) -> ViewR a -> a # foldl1 :: (a -> a -> a) -> ViewR a -> a # elem :: Eq a => a -> ViewR a -> Bool # maximum :: Ord a => ViewR a -> a # minimum :: Ord a => ViewR a -> a # | |
Foldable Set | Folds in order of increasing key. |
Defined in Data.Set.Internal fold :: Monoid m => Set m -> m # foldMap :: Monoid m => (a -> m) -> Set a -> m # foldMap' :: Monoid m => (a -> m) -> Set a -> m # foldr :: (a -> b -> b) -> b -> Set a -> b # foldr' :: (a -> b -> b) -> b -> Set a -> b # foldl :: (b -> a -> b) -> b -> Set a -> b # foldl' :: (b -> a -> b) -> b -> Set a -> b # foldr1 :: (a -> a -> a) -> Set a -> a # foldl1 :: (a -> a -> a) -> Set a -> a # elem :: Eq a => a -> Set a -> Bool # maximum :: Ord a => Set a -> a # | |
Foldable Tree | |
Defined in Data.Tree fold :: Monoid m => Tree m -> m # foldMap :: Monoid m => (a -> m) -> Tree a -> m # foldMap' :: Monoid m => (a -> m) -> Tree a -> m # foldr :: (a -> b -> b) -> b -> Tree a -> b # foldr' :: (a -> b -> b) -> b -> Tree a -> b # foldl :: (b -> a -> b) -> b -> Tree a -> b # foldl' :: (b -> a -> b) -> b -> Tree a -> b # foldr1 :: (a -> a -> a) -> Tree a -> a # foldl1 :: (a -> a -> a) -> Tree a -> a # elem :: Eq a => a -> Tree a -> Bool # maximum :: Ord a => Tree a -> a # | |
Foldable Directories' | |
Defined in XMonad.Core fold :: Monoid m => Directories' m -> m # foldMap :: Monoid m => (a -> m) -> Directories' a -> m # foldMap' :: Monoid m => (a -> m) -> Directories' a -> m # foldr :: (a -> b -> b) -> b -> Directories' a -> b # foldr' :: (a -> b -> b) -> b -> Directories' a -> b # foldl :: (b -> a -> b) -> b -> Directories' a -> b # foldl' :: (b -> a -> b) -> b -> Directories' a -> b # foldr1 :: (a -> a -> a) -> Directories' a -> a # foldl1 :: (a -> a -> a) -> Directories' a -> a # toList :: Directories' a -> [a] # null :: Directories' a -> Bool # length :: Directories' a -> Int # elem :: Eq a => a -> Directories' a -> Bool # maximum :: Ord a => Directories' a -> a # minimum :: Ord a => Directories' a -> a # sum :: Num a => Directories' a -> a # product :: Num a => Directories' a -> a # | |
Foldable Stack | |
Defined in XMonad.StackSet fold :: Monoid m => Stack m -> m # foldMap :: Monoid m => (a -> m) -> Stack a -> m # foldMap' :: Monoid m => (a -> m) -> Stack a -> m # foldr :: (a -> b -> b) -> b -> Stack a -> b # foldr' :: (a -> b -> b) -> b -> Stack a -> b # foldl :: (b -> a -> b) -> b -> Stack a -> b # foldl' :: (b -> a -> b) -> b -> Stack a -> b # foldr1 :: (a -> a -> a) -> Stack a -> a # foldl1 :: (a -> a -> a) -> Stack a -> a # elem :: Eq a => a -> Stack a -> Bool # maximum :: Ord a => Stack a -> a # minimum :: Ord a => Stack a -> a # | |
Foldable Cursors Source # | |
Defined in XMonad.Actions.WorkspaceCursors fold :: Monoid m => Cursors m -> m # foldMap :: Monoid m => (a -> m) -> Cursors a -> m # foldMap' :: Monoid m => (a -> m) -> Cursors a -> m # foldr :: (a -> b -> b) -> b -> Cursors a -> b # foldr' :: (a -> b -> b) -> b -> Cursors a -> b # foldl :: (b -> a -> b) -> b -> Cursors a -> b # foldl' :: (b -> a -> b) -> b -> Cursors a -> b # foldr1 :: (a -> a -> a) -> Cursors a -> a # foldl1 :: (a -> a -> a) -> Cursors a -> a # elem :: Eq a => a -> Cursors a -> Bool # maximum :: Ord a => Cursors a -> a # minimum :: Ord a => Cursors a -> a # | |
Foldable NonEmpty | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => NonEmpty m -> m # foldMap :: Monoid m => (a -> m) -> NonEmpty a -> m # foldMap' :: Monoid m => (a -> m) -> NonEmpty a -> m # foldr :: (a -> b -> b) -> b -> NonEmpty a -> b # foldr' :: (a -> b -> b) -> b -> NonEmpty a -> b # foldl :: (b -> a -> b) -> b -> NonEmpty a -> b # foldl' :: (b -> a -> b) -> b -> NonEmpty a -> b # foldr1 :: (a -> a -> a) -> NonEmpty a -> a # foldl1 :: (a -> a -> a) -> NonEmpty a -> a # elem :: Eq a => a -> NonEmpty a -> Bool # maximum :: Ord a => NonEmpty a -> a # minimum :: Ord a => NonEmpty a -> a # | |
Foldable Maybe | Since: base-2.1 |
Defined in Data.Foldable fold :: Monoid m => Maybe m -> m # foldMap :: Monoid m => (a -> m) -> Maybe a -> m # foldMap' :: Monoid m => (a -> m) -> Maybe a -> m # foldr :: (a -> b -> b) -> b -> Maybe a -> b # foldr' :: (a -> b -> b) -> b -> Maybe a -> b # foldl :: (b -> a -> b) -> b -> Maybe a -> b # foldl' :: (b -> a -> b) -> b -> Maybe a -> b # foldr1 :: (a -> a -> a) -> Maybe a -> a # foldl1 :: (a -> a -> a) -> Maybe a -> a # elem :: Eq a => a -> Maybe a -> Bool # maximum :: Ord a => Maybe a -> a # minimum :: Ord a => Maybe a -> a # | |
Foldable Solo | Since: base-4.15 |
Defined in Data.Foldable fold :: Monoid m => Solo m -> m # foldMap :: Monoid m => (a -> m) -> Solo a -> m # foldMap' :: Monoid m => (a -> m) -> Solo a -> m # foldr :: (a -> b -> b) -> b -> Solo a -> b # foldr' :: (a -> b -> b) -> b -> Solo a -> b # foldl :: (b -> a -> b) -> b -> Solo a -> b # foldl' :: (b -> a -> b) -> b -> Solo a -> b # foldr1 :: (a -> a -> a) -> Solo a -> a # foldl1 :: (a -> a -> a) -> Solo a -> a # elem :: Eq a => a -> Solo a -> Bool # maximum :: Ord a => Solo a -> a # | |
Foldable [] | Since: base-2.1 |
Defined in Data.Foldable fold :: Monoid m => [m] -> m # foldMap :: Monoid m => (a -> m) -> [a] -> m # foldMap' :: Monoid m => (a -> m) -> [a] -> m # foldr :: (a -> b -> b) -> b -> [a] -> b # foldr' :: (a -> b -> b) -> b -> [a] -> b # foldl :: (b -> a -> b) -> b -> [a] -> b # foldl' :: (b -> a -> b) -> b -> [a] -> b # foldr1 :: (a -> a -> a) -> [a] -> a # foldl1 :: (a -> a -> a) -> [a] -> a # elem :: Eq a => a -> [a] -> Bool # maximum :: Ord a => [a] -> a # | |
Foldable (Either a) | Since: base-4.7.0.0 |
Defined in Data.Foldable fold :: Monoid m => Either a m -> m # foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m # foldMap' :: Monoid m => (a0 -> m) -> Either a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 # toList :: Either a a0 -> [a0] # length :: Either a a0 -> Int # elem :: Eq a0 => a0 -> Either a a0 -> Bool # maximum :: Ord a0 => Either a a0 -> a0 # minimum :: Ord a0 => Either a a0 -> a0 # | |
Foldable (Proxy :: TYPE LiftedRep -> Type) | Since: base-4.7.0.0 |
Defined in Data.Foldable fold :: Monoid m => Proxy m -> m # foldMap :: Monoid m => (a -> m) -> Proxy a -> m # foldMap' :: Monoid m => (a -> m) -> Proxy a -> m # foldr :: (a -> b -> b) -> b -> Proxy a -> b # foldr' :: (a -> b -> b) -> b -> Proxy a -> b # foldl :: (b -> a -> b) -> b -> Proxy a -> b # foldl' :: (b -> a -> b) -> b -> Proxy a -> b # foldr1 :: (a -> a -> a) -> Proxy a -> a # foldl1 :: (a -> a -> a) -> Proxy a -> a # elem :: Eq a => a -> Proxy a -> Bool # maximum :: Ord a => Proxy a -> a # minimum :: Ord a => Proxy a -> a # | |
Foldable (Arg a) | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Arg a m -> m # foldMap :: Monoid m => (a0 -> m) -> Arg a a0 -> m # foldMap' :: Monoid m => (a0 -> m) -> Arg a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Arg a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Arg a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Arg a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Arg a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 # elem :: Eq a0 => a0 -> Arg a a0 -> Bool # maximum :: Ord a0 => Arg a a0 -> a0 # minimum :: Ord a0 => Arg a a0 -> a0 # | |
Foldable (Array i) | Since: base-4.8.0.0 |
Defined in Data.Foldable fold :: Monoid m => Array i m -> m # foldMap :: Monoid m => (a -> m) -> Array i a -> m # foldMap' :: Monoid m => (a -> m) -> Array i a -> m # foldr :: (a -> b -> b) -> b -> Array i a -> b # foldr' :: (a -> b -> b) -> b -> Array i a -> b # foldl :: (b -> a -> b) -> b -> Array i a -> b # foldl' :: (b -> a -> b) -> b -> Array i a -> b # foldr1 :: (a -> a -> a) -> Array i a -> a # foldl1 :: (a -> a -> a) -> Array i a -> a # elem :: Eq a => a -> Array i a -> Bool # maximum :: Ord a => Array i a -> a # minimum :: Ord a => Array i a -> a # | |
Foldable (U1 :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => U1 m -> m # foldMap :: Monoid m => (a -> m) -> U1 a -> m # foldMap' :: Monoid m => (a -> m) -> U1 a -> m # foldr :: (a -> b -> b) -> b -> U1 a -> b # foldr' :: (a -> b -> b) -> b -> U1 a -> b # foldl :: (b -> a -> b) -> b -> U1 a -> b # foldl' :: (b -> a -> b) -> b -> U1 a -> b # foldr1 :: (a -> a -> a) -> U1 a -> a # foldl1 :: (a -> a -> a) -> U1 a -> a # elem :: Eq a => a -> U1 a -> Bool # maximum :: Ord a => U1 a -> a # | |
Foldable (UAddr :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => UAddr m -> m # foldMap :: Monoid m => (a -> m) -> UAddr a -> m # foldMap' :: Monoid m => (a -> m) -> UAddr a -> m # foldr :: (a -> b -> b) -> b -> UAddr a -> b # foldr' :: (a -> b -> b) -> b -> UAddr a -> b # foldl :: (b -> a -> b) -> b -> UAddr a -> b # foldl' :: (b -> a -> b) -> b -> UAddr a -> b # foldr1 :: (a -> a -> a) -> UAddr a -> a # foldl1 :: (a -> a -> a) -> UAddr a -> a # elem :: Eq a => a -> UAddr a -> Bool # maximum :: Ord a => UAddr a -> a # minimum :: Ord a => UAddr a -> a # | |
Foldable (UChar :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => UChar m -> m # foldMap :: Monoid m => (a -> m) -> UChar a -> m # foldMap' :: Monoid m => (a -> m) -> UChar a -> m # foldr :: (a -> b -> b) -> b -> UChar a -> b # foldr' :: (a -> b -> b) -> b -> UChar a -> b # foldl :: (b -> a -> b) -> b -> UChar a -> b # foldl' :: (b -> a -> b) -> b -> UChar a -> b # foldr1 :: (a -> a -> a) -> UChar a -> a # foldl1 :: (a -> a -> a) -> UChar a -> a # elem :: Eq a => a -> UChar a -> Bool # maximum :: Ord a => UChar a -> a # minimum :: Ord a => UChar a -> a # | |
Foldable (UDouble :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => UDouble m -> m # foldMap :: Monoid m => (a -> m) -> UDouble a -> m # foldMap' :: Monoid m => (a -> m) -> UDouble a -> m # foldr :: (a -> b -> b) -> b -> UDouble a -> b # foldr' :: (a -> b -> b) -> b -> UDouble a -> b # foldl :: (b -> a -> b) -> b -> UDouble a -> b # foldl' :: (b -> a -> b) -> b -> UDouble a -> b # foldr1 :: (a -> a -> a) -> UDouble a -> a # foldl1 :: (a -> a -> a) -> UDouble a -> a # elem :: Eq a => a -> UDouble a -> Bool # maximum :: Ord a => UDouble a -> a # minimum :: Ord a => UDouble a -> a # | |
Foldable (UFloat :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => UFloat m -> m # foldMap :: Monoid m => (a -> m) -> UFloat a -> m # foldMap' :: Monoid m => (a -> m) -> UFloat a -> m # foldr :: (a -> b -> b) -> b -> UFloat a -> b # foldr' :: (a -> b -> b) -> b -> UFloat a -> b # foldl :: (b -> a -> b) -> b -> UFloat a -> b # foldl' :: (b -> a -> b) -> b -> UFloat a -> b # foldr1 :: (a -> a -> a) -> UFloat a -> a # foldl1 :: (a -> a -> a) -> UFloat a -> a # elem :: Eq a => a -> UFloat a -> Bool # maximum :: Ord a => UFloat a -> a # minimum :: Ord a => UFloat a -> a # | |
Foldable (UInt :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => UInt m -> m # foldMap :: Monoid m => (a -> m) -> UInt a -> m # foldMap' :: Monoid m => (a -> m) -> UInt a -> m # foldr :: (a -> b -> b) -> b -> UInt a -> b # foldr' :: (a -> b -> b) -> b -> UInt a -> b # foldl :: (b -> a -> b) -> b -> UInt a -> b # foldl' :: (b -> a -> b) -> b -> UInt a -> b # foldr1 :: (a -> a -> a) -> UInt a -> a # foldl1 :: (a -> a -> a) -> UInt a -> a # elem :: Eq a => a -> UInt a -> Bool # maximum :: Ord a => UInt a -> a # | |
Foldable (UWord :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => UWord m -> m # foldMap :: Monoid m => (a -> m) -> UWord a -> m # foldMap' :: Monoid m => (a -> m) -> UWord a -> m # foldr :: (a -> b -> b) -> b -> UWord a -> b # foldr' :: (a -> b -> b) -> b -> UWord a -> b # foldl :: (b -> a -> b) -> b -> UWord a -> b # foldl' :: (b -> a -> b) -> b -> UWord a -> b # foldr1 :: (a -> a -> a) -> UWord a -> a # foldl1 :: (a -> a -> a) -> UWord a -> a # elem :: Eq a => a -> UWord a -> Bool # maximum :: Ord a => UWord a -> a # minimum :: Ord a => UWord a -> a # | |
Foldable (V1 :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => V1 m -> m # foldMap :: Monoid m => (a -> m) -> V1 a -> m # foldMap' :: Monoid m => (a -> m) -> V1 a -> m # foldr :: (a -> b -> b) -> b -> V1 a -> b # foldr' :: (a -> b -> b) -> b -> V1 a -> b # foldl :: (b -> a -> b) -> b -> V1 a -> b # foldl' :: (b -> a -> b) -> b -> V1 a -> b # foldr1 :: (a -> a -> a) -> V1 a -> a # foldl1 :: (a -> a -> a) -> V1 a -> a # elem :: Eq a => a -> V1 a -> Bool # maximum :: Ord a => V1 a -> a # | |
Foldable (Map k) | Folds in order of increasing key. |
Defined in Data.Map.Internal fold :: Monoid m => Map k m -> m # foldMap :: Monoid m => (a -> m) -> Map k a -> m # foldMap' :: Monoid m => (a -> m) -> Map k a -> m # foldr :: (a -> b -> b) -> b -> Map k a -> b # foldr' :: (a -> b -> b) -> b -> Map k a -> b # foldl :: (b -> a -> b) -> b -> Map k a -> b # foldl' :: (b -> a -> b) -> b -> Map k a -> b # foldr1 :: (a -> a -> a) -> Map k a -> a # foldl1 :: (a -> a -> a) -> Map k a -> a # elem :: Eq a => a -> Map k a -> Bool # maximum :: Ord a => Map k a -> a # minimum :: Ord a => Map k a -> a # | |
Foldable f => Foldable (ListT f) | |
Defined in Control.Monad.Trans.List fold :: Monoid m => ListT f m -> m # foldMap :: Monoid m => (a -> m) -> ListT f a -> m # foldMap' :: Monoid m => (a -> m) -> ListT f a -> m # foldr :: (a -> b -> b) -> b -> ListT f a -> b # foldr' :: (a -> b -> b) -> b -> ListT f a -> b # foldl :: (b -> a -> b) -> b -> ListT f a -> b # foldl' :: (b -> a -> b) -> b -> ListT f a -> b # foldr1 :: (a -> a -> a) -> ListT f a -> a # foldl1 :: (a -> a -> a) -> ListT f a -> a # elem :: Eq a => a -> ListT f a -> Bool # maximum :: Ord a => ListT f a -> a # minimum :: Ord a => ListT f a -> a # | |
Foldable f => Foldable (MaybeT f) | |
Defined in Control.Monad.Trans.Maybe fold :: Monoid m => MaybeT f m -> m # foldMap :: Monoid m => (a -> m) -> MaybeT f a -> m # foldMap' :: Monoid m => (a -> m) -> MaybeT f a -> m # foldr :: (a -> b -> b) -> b -> MaybeT f a -> b # foldr' :: (a -> b -> b) -> b -> MaybeT f a -> b # foldl :: (b -> a -> b) -> b -> MaybeT f a -> b # foldl' :: (b -> a -> b) -> b -> MaybeT f a -> b # foldr1 :: (a -> a -> a) -> MaybeT f a -> a # foldl1 :: (a -> a -> a) -> MaybeT f a -> a # elem :: Eq a => a -> MaybeT f a -> Bool # maximum :: Ord a => MaybeT f a -> a # minimum :: Ord a => MaybeT f a -> a # | |
Foldable (History k) Source # | |
Defined in XMonad.Util.History fold :: Monoid m => History k m -> m # foldMap :: Monoid m => (a -> m) -> History k a -> m # foldMap' :: Monoid m => (a -> m) -> History k a -> m # foldr :: (a -> b -> b) -> b -> History k a -> b # foldr' :: (a -> b -> b) -> b -> History k a -> b # foldl :: (b -> a -> b) -> b -> History k a -> b # foldl' :: (b -> a -> b) -> b -> History k a -> b # foldr1 :: (a -> a -> a) -> History k a -> a # foldl1 :: (a -> a -> a) -> History k a -> a # toList :: History k a -> [a] # length :: History k a -> Int # elem :: Eq a => a -> History k a -> Bool # maximum :: Ord a => History k a -> a # minimum :: Ord a => History k a -> a # | |
Foldable ((,) a) | Since: base-4.7.0.0 |
Defined in Data.Foldable fold :: Monoid m => (a, m) -> m # foldMap :: Monoid m => (a0 -> m) -> (a, a0) -> m # foldMap' :: Monoid m => (a0 -> m) -> (a, a0) -> m # foldr :: (a0 -> b -> b) -> b -> (a, a0) -> b # foldr' :: (a0 -> b -> b) -> b -> (a, a0) -> b # foldl :: (b -> a0 -> b) -> b -> (a, a0) -> b # foldl' :: (b -> a0 -> b) -> b -> (a, a0) -> b # foldr1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 # foldl1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 # elem :: Eq a0 => a0 -> (a, a0) -> Bool # maximum :: Ord a0 => (a, a0) -> a0 # minimum :: Ord a0 => (a, a0) -> a0 # | |
Foldable (Const m :: TYPE LiftedRep -> Type) | Since: base-4.7.0.0 |
Defined in Data.Functor.Const fold :: Monoid m0 => Const m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 # foldMap' :: Monoid m0 => (a -> m0) -> Const m a -> m0 # foldr :: (a -> b -> b) -> b -> Const m a -> b # foldr' :: (a -> b -> b) -> b -> Const m a -> b # foldl :: (b -> a -> b) -> b -> Const m a -> b # foldl' :: (b -> a -> b) -> b -> Const m a -> b # foldr1 :: (a -> a -> a) -> Const m a -> a # foldl1 :: (a -> a -> a) -> Const m a -> a # elem :: Eq a => a -> Const m a -> Bool # maximum :: Ord a => Const m a -> a # minimum :: Ord a => Const m a -> a # | |
Foldable f => Foldable (Ap f) | Since: base-4.12.0.0 |
Defined in Data.Foldable fold :: Monoid m => Ap f m -> m # foldMap :: Monoid m => (a -> m) -> Ap f a -> m # foldMap' :: Monoid m => (a -> m) -> Ap f a -> m # foldr :: (a -> b -> b) -> b -> Ap f a -> b # foldr' :: (a -> b -> b) -> b -> Ap f a -> b # foldl :: (b -> a -> b) -> b -> Ap f a -> b # foldl' :: (b -> a -> b) -> b -> Ap f a -> b # foldr1 :: (a -> a -> a) -> Ap f a -> a # foldl1 :: (a -> a -> a) -> Ap f a -> a # elem :: Eq a => a -> Ap f a -> Bool # maximum :: Ord a => Ap f a -> a # | |
Foldable f => Foldable (Alt f) | Since: base-4.12.0.0 |
Defined in Data.Foldable fold :: Monoid m => Alt f m -> m # foldMap :: Monoid m => (a -> m) -> Alt f a -> m # foldMap' :: Monoid m => (a -> m) -> Alt f a -> m # foldr :: (a -> b -> b) -> b -> Alt f a -> b # foldr' :: (a -> b -> b) -> b -> Alt f a -> b # foldl :: (b -> a -> b) -> b -> Alt f a -> b # foldl' :: (b -> a -> b) -> b -> Alt f a -> b # foldr1 :: (a -> a -> a) -> Alt f a -> a # foldl1 :: (a -> a -> a) -> Alt f a -> a # elem :: Eq a => a -> Alt f a -> Bool # maximum :: Ord a => Alt f a -> a # minimum :: Ord a => Alt f a -> a # | |
Foldable f => Foldable (Rec1 f) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => Rec1 f m -> m # foldMap :: Monoid m => (a -> m) -> Rec1 f a -> m # foldMap' :: Monoid m => (a -> m) -> Rec1 f a -> m # foldr :: (a -> b -> b) -> b -> Rec1 f a -> b # foldr' :: (a -> b -> b) -> b -> Rec1 f a -> b # foldl :: (b -> a -> b) -> b -> Rec1 f a -> b # foldl' :: (b -> a -> b) -> b -> Rec1 f a -> b # foldr1 :: (a -> a -> a) -> Rec1 f a -> a # foldl1 :: (a -> a -> a) -> Rec1 f a -> a # elem :: Eq a => a -> Rec1 f a -> Bool # maximum :: Ord a => Rec1 f a -> a # minimum :: Ord a => Rec1 f a -> a # | |
Foldable f => Foldable (ErrorT e f) | |
Defined in Control.Monad.Trans.Error fold :: Monoid m => ErrorT e f m -> m # foldMap :: Monoid m => (a -> m) -> ErrorT e f a -> m # foldMap' :: Monoid m => (a -> m) -> ErrorT e f a -> m # foldr :: (a -> b -> b) -> b -> ErrorT e f a -> b # foldr' :: (a -> b -> b) -> b -> ErrorT e f a -> b # foldl :: (b -> a -> b) -> b -> ErrorT e f a -> b # foldl' :: (b -> a -> b) -> b -> ErrorT e f a -> b # foldr1 :: (a -> a -> a) -> ErrorT e f a -> a # foldl1 :: (a -> a -> a) -> ErrorT e f a -> a # toList :: ErrorT e f a -> [a] # null :: ErrorT e f a -> Bool # length :: ErrorT e f a -> Int # elem :: Eq a => a -> ErrorT e f a -> Bool # maximum :: Ord a => ErrorT e f a -> a # minimum :: Ord a => ErrorT e f a -> a # | |
Foldable f => Foldable (ExceptT e f) | |
Defined in Control.Monad.Trans.Except fold :: Monoid m => ExceptT e f m -> m # foldMap :: Monoid m => (a -> m) -> ExceptT e f a -> m # foldMap' :: Monoid m => (a -> m) -> ExceptT e f a -> m # foldr :: (a -> b -> b) -> b -> ExceptT e f a -> b # foldr' :: (a -> b -> b) -> b -> ExceptT e f a -> b # foldl :: (b -> a -> b) -> b -> ExceptT e f a -> b # foldl' :: (b -> a -> b) -> b -> ExceptT e f a -> b # foldr1 :: (a -> a -> a) -> ExceptT e f a -> a # foldl1 :: (a -> a -> a) -> ExceptT e f a -> a # toList :: ExceptT e f a -> [a] # null :: ExceptT e f a -> Bool # length :: ExceptT e f a -> Int # elem :: Eq a => a -> ExceptT e f a -> Bool # maximum :: Ord a => ExceptT e f a -> a # minimum :: Ord a => ExceptT e f a -> a # | |
Foldable f => Foldable (IdentityT f) | |
Defined in Control.Monad.Trans.Identity fold :: Monoid m => IdentityT f m -> m # foldMap :: Monoid m => (a -> m) -> IdentityT f a -> m # foldMap' :: Monoid m => (a -> m) -> IdentityT f a -> m # foldr :: (a -> b -> b) -> b -> IdentityT f a -> b # foldr' :: (a -> b -> b) -> b -> IdentityT f a -> b # foldl :: (b -> a -> b) -> b -> IdentityT f a -> b # foldl' :: (b -> a -> b) -> b -> IdentityT f a -> b # foldr1 :: (a -> a -> a) -> IdentityT f a -> a # foldl1 :: (a -> a -> a) -> IdentityT f a -> a # toList :: IdentityT f a -> [a] # null :: IdentityT f a -> Bool # length :: IdentityT f a -> Int # elem :: Eq a => a -> IdentityT f a -> Bool # maximum :: Ord a => IdentityT f a -> a # minimum :: Ord a => IdentityT f a -> a # | |
Foldable f => Foldable (WriterT w f) | |
Defined in Control.Monad.Trans.Writer.Lazy fold :: Monoid m => WriterT w f m -> m # foldMap :: Monoid m => (a -> m) -> WriterT w f a -> m # foldMap' :: Monoid m => (a -> m) -> WriterT w f a -> m # foldr :: (a -> b -> b) -> b -> WriterT w f a -> b # foldr' :: (a -> b -> b) -> b -> WriterT w f a -> b # foldl :: (b -> a -> b) -> b -> WriterT w f a -> b # foldl' :: (b -> a -> b) -> b -> WriterT w f a -> b # foldr1 :: (a -> a -> a) -> WriterT w f a -> a # foldl1 :: (a -> a -> a) -> WriterT w f a -> a # toList :: WriterT w f a -> [a] # null :: WriterT w f a -> Bool # length :: WriterT w f a -> Int # elem :: Eq a => a -> WriterT w f a -> Bool # maximum :: Ord a => WriterT w f a -> a # minimum :: Ord a => WriterT w f a -> a # | |
Foldable f => Foldable (WriterT w f) | |
Defined in Control.Monad.Trans.Writer.Strict fold :: Monoid m => WriterT w f m -> m # foldMap :: Monoid m => (a -> m) -> WriterT w f a -> m # foldMap' :: Monoid m => (a -> m) -> WriterT w f a -> m # foldr :: (a -> b -> b) -> b -> WriterT w f a -> b # foldr' :: (a -> b -> b) -> b -> WriterT w f a -> b # foldl :: (b -> a -> b) -> b -> WriterT w f a -> b # foldl' :: (b -> a -> b) -> b -> WriterT w f a -> b # foldr1 :: (a -> a -> a) -> WriterT w f a -> a # foldl1 :: (a -> a -> a) -> WriterT w f a -> a # toList :: WriterT w f a -> [a] # null :: WriterT w f a -> Bool # length :: WriterT w f a -> Int # elem :: Eq a => a -> WriterT w f a -> Bool # maximum :: Ord a => WriterT w f a -> a # minimum :: Ord a => WriterT w f a -> a # | |
(Foldable f, Foldable g) => Foldable (Product f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product fold :: Monoid m => Product f g m -> m # foldMap :: Monoid m => (a -> m) -> Product f g a -> m # foldMap' :: Monoid m => (a -> m) -> Product f g a -> m # foldr :: (a -> b -> b) -> b -> Product f g a -> b # foldr' :: (a -> b -> b) -> b -> Product f g a -> b # foldl :: (b -> a -> b) -> b -> Product f g a -> b # foldl' :: (b -> a -> b) -> b -> Product f g a -> b # foldr1 :: (a -> a -> a) -> Product f g a -> a # foldl1 :: (a -> a -> a) -> Product f g a -> a # toList :: Product f g a -> [a] # null :: Product f g a -> Bool # length :: Product f g a -> Int # elem :: Eq a => a -> Product f g a -> Bool # maximum :: Ord a => Product f g a -> a # minimum :: Ord a => Product f g a -> a # | |
(Foldable f, Foldable g) => Foldable (Sum f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum fold :: Monoid m => Sum f g m -> m # foldMap :: Monoid m => (a -> m) -> Sum f g a -> m # foldMap' :: Monoid m => (a -> m) -> Sum f g a -> m # foldr :: (a -> b -> b) -> b -> Sum f g a -> b # foldr' :: (a -> b -> b) -> b -> Sum f g a -> b # foldl :: (b -> a -> b) -> b -> Sum f g a -> b # foldl' :: (b -> a -> b) -> b -> Sum f g a -> b # foldr1 :: (a -> a -> a) -> Sum f g a -> a # foldl1 :: (a -> a -> a) -> Sum f g a -> a # elem :: Eq a => a -> Sum f g a -> Bool # maximum :: Ord a => Sum f g a -> a # minimum :: Ord a => Sum f g a -> a # | |
(Foldable f, Foldable g) => Foldable (f :*: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => (f :*: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :*: g) a -> m # foldMap' :: Monoid m => (a -> m) -> (f :*: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :*: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :*: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :*: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :*: g) a -> b # foldr1 :: (a -> a -> a) -> (f :*: g) a -> a # foldl1 :: (a -> a -> a) -> (f :*: g) a -> a # toList :: (f :*: g) a -> [a] # length :: (f :*: g) a -> Int # elem :: Eq a => a -> (f :*: g) a -> Bool # maximum :: Ord a => (f :*: g) a -> a # minimum :: Ord a => (f :*: g) a -> a # | |
(Foldable f, Foldable g) => Foldable (f :+: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => (f :+: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :+: g) a -> m # foldMap' :: Monoid m => (a -> m) -> (f :+: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :+: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :+: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :+: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :+: g) a -> b # foldr1 :: (a -> a -> a) -> (f :+: g) a -> a # foldl1 :: (a -> a -> a) -> (f :+: g) a -> a # toList :: (f :+: g) a -> [a] # length :: (f :+: g) a -> Int # elem :: Eq a => a -> (f :+: g) a -> Bool # maximum :: Ord a => (f :+: g) a -> a # minimum :: Ord a => (f :+: g) a -> a # | |
Foldable (K1 i c :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => K1 i c m -> m # foldMap :: Monoid m => (a -> m) -> K1 i c a -> m # foldMap' :: Monoid m => (a -> m) -> K1 i c a -> m # foldr :: (a -> b -> b) -> b -> K1 i c a -> b # foldr' :: (a -> b -> b) -> b -> K1 i c a -> b # foldl :: (b -> a -> b) -> b -> K1 i c a -> b # foldl' :: (b -> a -> b) -> b -> K1 i c a -> b # foldr1 :: (a -> a -> a) -> K1 i c a -> a # foldl1 :: (a -> a -> a) -> K1 i c a -> a # elem :: Eq a => a -> K1 i c a -> Bool # maximum :: Ord a => K1 i c a -> a # minimum :: Ord a => K1 i c a -> a # | |
(Foldable f, Foldable g) => Foldable (Compose f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose fold :: Monoid m => Compose f g m -> m # foldMap :: Monoid m => (a -> m) -> Compose f g a -> m # foldMap' :: Monoid m => (a -> m) -> Compose f g a -> m # foldr :: (a -> b -> b) -> b -> Compose f g a -> b # foldr' :: (a -> b -> b) -> b -> Compose f g a -> b # foldl :: (b -> a -> b) -> b -> Compose f g a -> b # foldl' :: (b -> a -> b) -> b -> Compose f g a -> b # foldr1 :: (a -> a -> a) -> Compose f g a -> a # foldl1 :: (a -> a -> a) -> Compose f g a -> a # toList :: Compose f g a -> [a] # null :: Compose f g a -> Bool # length :: Compose f g a -> Int # elem :: Eq a => a -> Compose f g a -> Bool # maximum :: Ord a => Compose f g a -> a # minimum :: Ord a => Compose f g a -> a # | |
(Foldable f, Foldable g) => Foldable (f :.: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => (f :.: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :.: g) a -> m # foldMap' :: Monoid m => (a -> m) -> (f :.: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :.: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :.: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :.: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :.: g) a -> b # foldr1 :: (a -> a -> a) -> (f :.: g) a -> a # foldl1 :: (a -> a -> a) -> (f :.: g) a -> a # toList :: (f :.: g) a -> [a] # length :: (f :.: g) a -> Int # elem :: Eq a => a -> (f :.: g) a -> Bool # maximum :: Ord a => (f :.: g) a -> a # minimum :: Ord a => (f :.: g) a -> a # | |
Foldable f => Foldable (M1 i c f) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => M1 i c f m -> m # foldMap :: Monoid m => (a -> m) -> M1 i c f a -> m # foldMap' :: Monoid m => (a -> m) -> M1 i c f a -> m # foldr :: (a -> b -> b) -> b -> M1 i c f a -> b # foldr' :: (a -> b -> b) -> b -> M1 i c f a -> b # foldl :: (b -> a -> b) -> b -> M1 i c f a -> b # foldl' :: (b -> a -> b) -> b -> M1 i c f a -> b # foldr1 :: (a -> a -> a) -> M1 i c f a -> a # foldl1 :: (a -> a -> a) -> M1 i c f a -> a # elem :: Eq a => a -> M1 i c f a -> Bool # maximum :: Ord a => M1 i c f a -> a # minimum :: Ord a => M1 i c f a -> a # |
class (Functor t, Foldable t) => Traversable (t :: Type -> Type) where #
Functors representing data structures that can be transformed to
structures of the same shape by performing an Applicative
(or,
therefore, Monad
) action on each element from left to right.
A more detailed description of what same shape means, the various methods, how traversals are constructed, and example advanced use-cases can be found in the Overview section of Data.Traversable.
For the class laws see the Laws section of Data.Traversable.
traverse :: Applicative f => (a -> f b) -> t a -> f (t b) #
Map each element of a structure to an action, evaluate these actions
from left to right, and collect the results. For a version that ignores
the results see traverse_
.
Examples
Basic usage:
In the first two examples we show each evaluated action mapping to the output structure.
>>>
traverse Just [1,2,3,4]
Just [1,2,3,4]
>>>
traverse id [Right 1, Right 2, Right 3, Right 4]
Right [1,2,3,4]
In the next examples, we show that Nothing
and Left
values short
circuit the created structure.
>>>
traverse (const Nothing) [1,2,3,4]
Nothing
>>>
traverse (\x -> if odd x then Just x else Nothing) [1,2,3,4]
Nothing
>>>
traverse id [Right 1, Right 2, Right 3, Right 4, Left 0]
Left 0
sequenceA :: Applicative f => t (f a) -> f (t a) #
Evaluate each action in the structure from left to right, and
collect the results. For a version that ignores the results
see sequenceA_
.
Examples
Basic usage:
For the first two examples we show sequenceA fully evaluating a a structure and collecting the results.
>>>
sequenceA [Just 1, Just 2, Just 3]
Just [1,2,3]
>>>
sequenceA [Right 1, Right 2, Right 3]
Right [1,2,3]
The next two example show Nothing
and Just
will short circuit
the resulting structure if present in the input. For more context,
check the Traversable
instances for Either
and Maybe
.
>>>
sequenceA [Just 1, Just 2, Just 3, Nothing]
Nothing
>>>
sequenceA [Right 1, Right 2, Right 3, Left 4]
Left 4
mapM :: Monad m => (a -> m b) -> t a -> m (t b) #
Map each element of a structure to a monadic action, evaluate
these actions from left to right, and collect the results. For
a version that ignores the results see mapM_
.
Examples
sequence :: Monad m => t (m a) -> m (t a) #
Evaluate each monadic action in the structure from left to
right, and collect the results. For a version that ignores the
results see sequence_
.
Examples
Basic usage:
The first two examples are instances where the input and
and output of sequence
are isomorphic.
>>>
sequence $ Right [1,2,3,4]
[Right 1,Right 2,Right 3,Right 4]
>>>
sequence $ [Right 1,Right 2,Right 3,Right 4]
Right [1,2,3,4]
The following examples demonstrate short circuit behavior
for sequence
.
>>>
sequence $ Left [1,2,3,4]
Left [1,2,3,4]
>>>
sequence $ [Left 0, Right 1,Right 2,Right 3,Right 4]
Left 0