Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Navi.Prelude
Description
Custom prelude. The idea is to:
- Re-export useful prelude functions/types
- Export various functions/types from base
- Export new functions meant to address prelude limitations (e.g. total replacements for partial functions).
This is not a comprehensive replacement for Prelude, just the functionality needed for this application. Thus it is natural to add new functionality/exports here over time.
Synopsis
- headMaybe :: [a] -> Maybe a
- (>.>) :: (a -> b) -> (b -> c) -> a -> c
- (<<$>>) :: (Functor f, Functor g) => (a -> b) -> g (f a) -> g (f b)
- maybeToEither :: e -> Maybe a -> Either e a
- monoBimap :: Bifunctor p => (a -> b) -> p a a -> p b b
- error :: Text -> a
- showt :: Show a => a -> Text
- seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b
- filter :: (a -> Bool) -> [a] -> [a]
- fst :: (a, b) -> a
- snd :: (a, b) -> b
- otherwise :: Bool
- ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
- fromIntegral :: (Integral a, Num b) => a -> b
- join :: Monad m => m (m a) -> m a
- class Bounded a where
- class Eq a where
- class (Real a, Enum a) => Integral a where
- class Applicative m => Monad (m :: Type -> Type) where
- class Functor (f :: Type -> Type) where
- class Num a where
- class Eq a => Ord a where
- class Show a where
- class Monad m => MonadFail (m :: Type -> Type) where
- class IsString a where
- fromString :: String -> a
- 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
- toList :: 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)
- class Generic a
- class Semigroup a where
- class Semigroup a => Monoid a where
- data Bool
- type String = [Char]
- data Char
- data Int
- data Int32
- data Integer
- data Natural where
- data Maybe a
- data IO a
- data Word8
- data Word16
- data Either a b
- data NonEmpty a = a :| [a]
- type Type = TYPE LiftedRep
- data Constraint
- id :: a -> a
- either :: (a -> c) -> (b -> c) -> Either a b -> c
- class Monad m => MonadReader r (m :: Type -> Type) | m -> r where
- data ByteString
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- const :: a -> b -> a
- (.) :: (b -> c) -> (a -> b) -> a -> c
- data Text
- data Handle
- class Bifunctor (p :: Type -> Type -> Type) where
- data Void
- absurd :: Void -> a
- class Monad m => MonadIO (m :: Type -> Type) where
- forever :: Applicative f => f a -> f b
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
- data IORef a
- class (Typeable e, Show e) => Exception e where
- toException :: e -> SomeException
- fromException :: SomeException -> Maybe e
- displayException :: e -> String
- traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
- for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
- all :: Foldable t => (a -> Bool) -> t a -> Bool
- data Proxy (t :: k) = Proxy
- data IOMode
- zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
- replicate :: Int -> a -> [a]
- maybeToList :: Maybe a -> [a]
- maybe :: b -> (a -> b) -> Maybe a -> b
- fromMaybe :: a -> Maybe a -> a
- void :: Functor f => f a -> f ()
- (<&>) :: Functor f => f a -> (a -> b) -> f b
- ($>) :: Functor f => f a -> b -> f b
- uncurry :: (a -> b -> c) -> (a, b) -> c
- class Applicative f => Alternative (f :: Type -> Type) where
- when :: Applicative f => Bool -> f () -> f ()
- flip :: (a -> b -> c) -> b -> a -> c
- (=<<) :: Monad m => (a -> m b) -> m a -> m b
- (<**>) :: Applicative f => f a -> f (a -> b) -> f b
- undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a
- type HasCallStack = ?callStack :: CallStack
- data SomeException
- (&&) :: Bool -> Bool -> Bool
- not :: Bool -> Bool
- (||) :: Bool -> Bool -> Bool
- newtype ReaderT r (m :: Type -> Type) a = ReaderT {
- runReaderT :: r -> m a
- class MonadTrans (t :: (Type -> Type) -> Type -> Type) where
- class Monad m => MonadThrow (m :: Type -> Type)
- data Seq a where
- class NFData a
- (</>) :: FilePath -> FilePath -> FilePath
- class MonadCatch m => MonadMask (m :: Type -> Type) where
- mask :: ((forall a. m a -> m a) -> m b) -> m b
- class MonadThrow m => MonadCatch (m :: Type -> Type)
- finally :: MonadMask m => m a -> m b -> m a
- bracket :: MonadMask m => m a -> (a -> m c) -> (a -> m b) -> m b
- data LogStr
- logOther :: Text -> Q Exp
- logError :: Q Exp
- logWarn :: Q Exp
- logInfo :: Q Exp
- logDebug :: Q Exp
- data LogLevel
- class Monad m => MonadLogger (m :: Type -> Type) where
- monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> m ()
- asks :: MonadReader r m => (r -> a) -> m a
- _1 :: Field1 s t a b => Lens s t a b
- _2 :: Field2 s t a b => Lens s t a b
- type Traversal' s a = Optic' A_Traversal NoIx s a
- (.~) :: forall k (is :: IxList) s t a b. Is k A_Setter => Optic k is s t a b -> b -> s -> t
- (^?) :: forall k s (is :: IxList) a. Is k An_AffineFold => s -> Optic' k is s a -> Maybe a
- (^.) :: forall k s (is :: IxList) a. Is k A_Getter => s -> Optic' k is s a -> a
- set' :: forall k (is :: IxList) s t a b. Is k A_Setter => Optic k is s t a b -> b -> s -> t
- over' :: forall k (is :: IxList) s t a b. Is k A_Setter => Optic k is s t a b -> (a -> b) -> s -> t
- type Iso' s a = Optic' An_Iso NoIx s a
- review :: forall k (is :: IxList) t b. Is k A_Review => Optic' k is t b -> b -> t
- (%?) :: forall (is :: IxList) (js :: IxList) (ks :: IxList) k k' l m s t u v a b. (AppendIndices is js ks, JoinKinds k A_Prism k', JoinKinds k' l m) => Optic k is s t (Maybe u) (Maybe v) -> Optic l js u v a b -> Optic m ks s t a b
- _Just :: Prism (Maybe a) (Maybe b) a b
- lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
- type Lens' s a = Optic' A_Lens NoIx s a
- preview :: forall k (is :: IxList) s a. Is k An_AffineFold => Optic' k is s a -> s -> Maybe a
- type AffineTraversal' s a = Optic' An_AffineTraversal NoIx s a
- view :: forall k (is :: IxList) s a. Is k A_Getter => Optic' k is s a -> s -> a
- (%) :: forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a b. (JoinKinds k l m, AppendIndices is js ks) => Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
- makeFieldLabelsNoPrefix :: Name -> DecsQ
- makePrisms :: Name -> DecsQ
- catchAny :: MonadCatch m => m a -> (SomeException -> m a) -> m a
- throwM :: (MonadThrow m, Exception e) => e -> m a
- data TBQueue a
- pack :: String -> Text
- concat :: [Text] -> Text
- unpack :: Text -> String
- getArrayOf :: Decoder a -> Decoder [a]
- getFieldOptWith :: Decoder a -> Text -> Decoder (Maybe a)
- getFieldOpt :: DecodeTOML a => Text -> Decoder (Maybe a)
- getFieldWith :: Decoder a -> Text -> Decoder a
- getField :: DecodeTOML a => Text -> Decoder a
- decode :: DecodeTOML a => Text -> Either TOMLError a
- typeMismatch :: Value -> DecodeM a
- invalidValue :: Text -> Value -> DecodeM a
- makeDecoder :: (Value -> DecodeM a) -> Decoder a
- data Decoder a
- class DecodeTOML a where
- tomlDecoder :: Decoder a
- renderTOMLError :: TOMLError -> Text
- data TOMLError
- data Value
- class Monad m => MonadAsync (m :: Type -> Type)
- class Monad m => MonadThread (m :: Type -> Type)
- class Monad m => MonadSTM (m :: Type -> Type)
- class Monad m => MonadIORef (m :: Type -> Type) where
- newIORef :: HasCallStack => a -> m (IORef a)
- readIORef :: HasCallStack => IORef a -> m a
- writeIORef :: HasCallStack => IORef a -> a -> m ()
- modifyIORef' :: HasCallStack => IORef a -> (a -> a) -> m ()
- newTBQueueM :: (HasCallStack, MonadSTM m) => Natural -> m (TBQueue a)
- readTBQueueM :: (HasCallStack, MonadSTM m) => TBQueue a -> m a
- tryReadTBQueueM :: (HasCallStack, MonadSTM m) => TBQueue a -> m (Maybe a)
- writeTBQueueM :: (HasCallStack, MonadSTM m) => TBQueue a -> a -> m ()
- addCS :: (HasCallStack, MonadCatch m) => m a -> m a
- catchWithCS :: forall m e a. (Exception e, HasCallStack, MonadCatch m) => m a -> (e -> m a) -> m a
- throwWithCS :: forall m e a. (Exception e, HasCallStack, MonadThrow m) => e -> m a
- readFileUtf8ThrowM :: (HasCallStack, MonadFileReader m, MonadThrow m) => Path -> m Text
- class Monad m => MonadFileReader (m :: Type -> Type)
- type Path = FilePath
- writeFileUtf8 :: (HasCallStack, MonadFileWriter m) => Path -> Text -> m ()
- class Monad m => MonadFileWriter (m :: Type -> Type)
- class Monad m => MonadHandleWriter (m :: Type -> Type) where
- class Monad m => MonadPathReader (m :: Type -> Type)
- class Monad m => MonadTerminal (m :: Type -> Type) where
Total versions of partial functions
Misc utilities
monoBimap :: Bifunctor p => (a -> b) -> p a a -> p b b Source #
Convenience function for mapping (a -> b)
over a monomorphic bifunctor.
Text
replacements for String
functions.
Base exports
seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b infixr 0 Source #
The value of seq a b
is bottom if a
is bottom, and
otherwise equal to b
. In other words, it evaluates the first
argument a
to weak head normal form (WHNF). seq
is usually
introduced to improve performance by avoiding unneeded laziness.
A note on evaluation order: the expression seq a b
does
not guarantee that a
will be evaluated before b
.
The only guarantee given by seq
is that the both a
and b
will be evaluated before seq
returns a value.
In particular, this means that b
may be evaluated before
a
. If you need to guarantee a specific order of evaluation,
you must use the function pseq
from the "parallel" package.
filter :: (a -> Bool) -> [a] -> [a] Source #
\(\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]
($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b infixr 0 Source #
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.
fromIntegral :: (Integral a, Num b) => a -> b Source #
general coercion from integral types
join :: Monad m => m (m a) -> m a Source #
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 Bounded a where Source #
The Bounded
class is used to name the upper and lower limits of a
type. Ord
is not a superclass of Bounded
since types that are not
totally ordered may also have upper and lower bounds.
The Bounded
class may be derived for any enumeration type;
minBound
is the first constructor listed in the data
declaration
and maxBound
is the last.
Bounded
may also be derived for single-constructor datatypes whose
constituent types are in Bounded
.
Instances
Bounded ByteOrder | Since: base-4.11.0.0 |
Bounded Associativity | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Bounded DecidedStrictness | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Bounded SourceStrictness | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Bounded SourceUnpackedness | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Bounded Int16 | Since: base-2.1 |
Bounded Int32 | Since: base-2.1 |
Bounded Int64 | Since: base-2.1 |
Bounded Int8 | Since: base-2.1 |
Bounded Word16 | Since: base-2.1 |
Bounded Word32 | Since: base-2.1 |
Bounded Word64 | Since: base-2.1 |
Bounded Word8 | Since: base-2.1 |
Bounded Size | |
Bounded Extension | |
Bounded Ordering | Since: base-2.1 |
Bounded PollInterval Source # | Since: 0.1 |
Defined in Navi.Data.PollInterval | |
Bounded PortNumber | |
Defined in Network.Socket.Types | |
Bounded BatteryApp | |
Bounded GlobalIpApp | |
Bounded MemoryApp | |
Bounded NetInterfaceApp | |
Bounded TZLabel | |
Bounded () | Since: base-2.1 |
Bounded Bool | Since: base-2.1 |
Bounded Char | Since: base-2.1 |
Bounded Int | Since: base-2.1 |
Bounded Levity | Since: base-4.16.0.0 |
Bounded VecCount | Since: base-4.10.0.0 |
Bounded VecElem | Since: base-4.10.0.0 |
Bounded Word | Since: base-2.1 |
Bounded a => Bounded (And a) | Since: base-4.16 |
Bounded a => Bounded (Iff a) | Since: base-4.16 |
Bounded a => Bounded (Ior a) | Since: base-4.16 |
Bounded a => Bounded (Xor a) | Since: base-4.16 |
Bounded a => Bounded (Identity a) | Since: base-4.9.0.0 |
Bounded a => Bounded (Down a) | Swaps Since: base-4.14.0.0 |
Bounded a => Bounded (First a) | Since: base-4.9.0.0 |
Bounded a => Bounded (Last a) | Since: base-4.9.0.0 |
Bounded a => Bounded (Max a) | Since: base-4.9.0.0 |
Bounded a => Bounded (Min a) | Since: base-4.9.0.0 |
Bounded m => Bounded (WrappedMonoid m) | Since: base-4.9.0.0 |
Defined in Data.Semigroup | |
Bounded a => Bounded (Supremum a) | |
Bounded a => Bounded (a) | |
Bounded (Proxy t) | Since: base-4.7.0.0 |
Bounded n => Bounded (Bytes s n) | |
(Bounded a, Bounded b) => Bounded (Pair a b) | |
(Bounded a, Bounded b) => Bounded (a, b) | Since: base-2.1 |
Bounded a => Bounded (Const a b) | Since: base-4.9.0.0 |
(Applicative f, Bounded a) => Bounded (Ap f a) | Since: base-4.12.0.0 |
a ~ b => Bounded (a :~: b) | Since: base-4.7.0.0 |
(KnownNat l, KnownNat r, Num a) => Bounded (LRInterval l r a) | |
Bounded b => Bounded (Tagged s b) | |
(Bounded a, Bounded b, Bounded c) => Bounded (a, b, c) | Since: base-2.1 |
a ~~ b => Bounded (a :~~: b) | Since: base-4.10.0.0 |
(Bounded a, Bounded b, Bounded c, Bounded d) => Bounded (a, b, c, d) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e) => Bounded (a, b, c, d, e) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f) => Bounded (a, b, c, d, e, f) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g) => Bounded (a, b, c, d, e, f, g) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h) => Bounded (a, b, c, d, e, f, g, h) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i) => Bounded (a, b, c, d, e, f, g, h, i) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j) => Bounded (a, b, c, d, e, f, g, h, i, j) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k) => Bounded (a, b, c, d, e, f, g, h, i, j, k) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n, Bounded o) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | Since: base-2.1 |
The Eq
class defines equality (==
) and inequality (/=
).
All the basic datatypes exported by the Prelude are instances of Eq
,
and Eq
may be derived for any datatype whose constituents are also
instances of Eq
.
The Haskell Report defines no laws for Eq
. However, instances are
encouraged to follow these properties:
Instances
class (Real a, Enum a) => Integral a where Source #
Integral numbers, supporting integer division.
The Haskell Report defines no laws for Integral
. However, Integral
instances are customarily expected to define a Euclidean domain and have the
following properties for the div
/mod
and quot
/rem
pairs, given
suitable Euclidean functions f
and g
:
x
=y * quot x y + rem x y
withrem x y
=fromInteger 0
org (rem x y)
<g y
x
=y * div x y + mod x y
withmod x y
=fromInteger 0
orf (mod x y)
<f y
An example of a suitable Euclidean function, for Integer
's instance, is
abs
.
Methods
quot :: a -> a -> a infixl 7 Source #
integer division truncated toward zero
rem :: a -> a -> a infixl 7 Source #
integer remainder, satisfying
(x `quot` y)*y + (x `rem` y) == x
div :: a -> a -> a infixl 7 Source #
integer division truncated toward negative infinity
mod :: a -> a -> a infixl 7 Source #
integer modulus, satisfying
(x `div` y)*y + (x `mod` y) == x
quotRem :: a -> a -> (a, a) Source #
divMod :: a -> a -> (a, a) Source #
toInteger :: a -> Integer Source #
conversion to Integer
Instances
class Applicative m => Monad (m :: Type -> Type) where Source #
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.
Minimal complete definition
Methods
(>>=) :: m a -> (a -> m b) -> m b infixl 1 Source #
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 Source #
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
class Functor (f :: Type -> Type) where Source #
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.
Minimal complete definition
Methods
fmap :: (a -> b) -> f a -> f b Source #
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
Basic numeric class.
The Haskell Report defines no laws for Num
. However, (
and +
)(
are
customarily expected to define a ring and have the following properties:*
)
- Associativity of
(
+
) (x + y) + z
=x + (y + z)
- Commutativity of
(
+
) x + y
=y + x
is the additive identityfromInteger
0x + fromInteger 0
=x
negate
gives the additive inversex + negate x
=fromInteger 0
- Associativity of
(
*
) (x * y) * z
=x * (y * z)
is the multiplicative identityfromInteger
1x * fromInteger 1
=x
andfromInteger 1 * x
=x
- Distributivity of
(
with respect to*
)(
+
) a * (b + c)
=(a * b) + (a * c)
and(b + c) * a
=(b * a) + (c * a)
Note that it isn't customarily expected that a type instance of both Num
and Ord
implement an ordered ring. Indeed, in base
only Integer
and
Rational
do.
Methods
(+) :: a -> a -> a infixl 6 Source #
(-) :: a -> a -> a infixl 6 Source #
(*) :: a -> a -> a infixl 7 Source #
Unary negation.
Absolute value.
Sign of a number.
The functions abs
and signum
should satisfy the law:
abs x * signum x == x
For real numbers, the signum
is either -1
(negative), 0
(zero)
or 1
(positive).
fromInteger :: Integer -> a Source #
Conversion from an Integer
.
An integer literal represents the application of the function
fromInteger
to the appropriate value of type Integer
,
so such literals have type (
.Num
a) => a
Instances
Num Pos | |
Num Int16 | Since: base-2.1 |
Num Int32 | Since: base-2.1 |
Num Int64 | Since: base-2.1 |
Num Int8 | Since: base-2.1 |
Num Word16 | Since: base-2.1 |
Num Word32 | Since: base-2.1 |
Num Word64 | Since: base-2.1 |
Num Word8 | Since: base-2.1 |
Num PollInterval Source # | |
Defined in Navi.Data.PollInterval Methods (+) :: PollInterval -> PollInterval -> PollInterval Source # (-) :: PollInterval -> PollInterval -> PollInterval Source # (*) :: PollInterval -> PollInterval -> PollInterval Source # negate :: PollInterval -> PollInterval Source # abs :: PollInterval -> PollInterval Source # signum :: PollInterval -> PollInterval Source # fromInteger :: Integer -> PollInterval Source # | |
Num PortNumber | |
Defined in Network.Socket.Types Methods (+) :: PortNumber -> PortNumber -> PortNumber Source # (-) :: PortNumber -> PortNumber -> PortNumber Source # (*) :: PortNumber -> PortNumber -> PortNumber Source # negate :: PortNumber -> PortNumber Source # abs :: PortNumber -> PortNumber Source # signum :: PortNumber -> PortNumber Source # fromInteger :: Integer -> PortNumber Source # | |
Num Scientific | WARNING: |
Defined in Data.Scientific Methods (+) :: Scientific -> Scientific -> Scientific Source # (-) :: Scientific -> Scientific -> Scientific Source # (*) :: Scientific -> Scientific -> Scientific Source # negate :: Scientific -> Scientific Source # abs :: Scientific -> Scientific Source # signum :: Scientific -> Scientific Source # fromInteger :: Integer -> Scientific Source # | |
Num B | |
Num Integer | Since: base-2.1 |
Defined in GHC.Num | |
Num Natural | Note that Since: base-4.8.0.0 |
Defined in GHC.Num | |
Num Int | Since: base-2.1 |
Num Word | Since: base-2.1 |
Num a => Num (Identity a) | Since: base-4.9.0.0 |
Defined in Data.Functor.Identity Methods (+) :: Identity a -> Identity a -> Identity a Source # (-) :: Identity a -> Identity a -> Identity a Source # (*) :: Identity a -> Identity a -> Identity a Source # negate :: Identity a -> Identity a Source # abs :: Identity a -> Identity a Source # signum :: Identity a -> Identity a Source # fromInteger :: Integer -> Identity a Source # | |
Num a => Num (Down a) | Since: base-4.11.0.0 |
Num a => Num (Max a) | Since: base-4.9.0.0 |
Num a => Num (Min a) | Since: base-4.9.0.0 |
Integral a => Num (Ratio a) | Since: base-2.0.1 |
Defined in GHC.Real | |
Num a => Num (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods (+) :: Const a b -> Const a b -> Const a b Source # (-) :: Const a b -> Const a b -> Const a b Source # (*) :: Const a b -> Const a b -> Const a b Source # negate :: Const a b -> Const a b Source # abs :: Const a b -> Const a b Source # signum :: Const a b -> Const a b Source # fromInteger :: Integer -> Const a b Source # | |
(Applicative f, Num a) => Num (Ap f a) | Note that even if the underlying Commutativity:
Additive inverse:
Distributivity:
Since: base-4.12.0.0 |
Num a => Num (Tagged s a) | |
Defined in Data.Tagged Methods (+) :: Tagged s a -> Tagged s a -> Tagged s a Source # (-) :: Tagged s a -> Tagged s a -> Tagged s a Source # (*) :: Tagged s a -> Tagged s a -> Tagged s a Source # negate :: Tagged s a -> Tagged s a Source # abs :: Tagged s a -> Tagged s a Source # signum :: Tagged s a -> Tagged s a Source # fromInteger :: Integer -> Tagged s a Source # |
class Eq a => Ord a where Source #
The Ord
class is used for totally ordered datatypes.
Instances of Ord
can be derived for any user-defined datatype whose
constituent types are in Ord
. The declared order of the constructors in
the data declaration determines the ordering in derived Ord
instances. The
Ordering
datatype allows a single comparison to determine the precise
ordering of two objects.
Ord
, as defined by the Haskell report, implements a total order and has the
following properties:
- Comparability
x <= y || y <= x
=True
- Transitivity
- if
x <= y && y <= z
=True
, thenx <= z
=True
- Reflexivity
x <= x
=True
- Antisymmetry
- if
x <= y && y <= x
=True
, thenx == y
=True
The following operator interactions are expected to hold:
x >= y
=y <= x
x < y
=x <= y && x /= y
x > y
=y < x
x < y
=compare x y == LT
x > y
=compare x y == GT
x == y
=compare x y == EQ
min x y == if x <= y then x else y
=True
max x y == if x >= y then x else y
=True
Note that (7.) and (8.) do not require min
and max
to return either of
their arguments. The result is merely required to equal one of the
arguments in terms of (==)
.
Minimal complete definition: either compare
or <=
.
Using compare
can be more efficient for complex types.
Methods
compare :: a -> a -> Ordering Source #
(<) :: a -> a -> Bool infix 4 Source #
(<=) :: a -> a -> Bool infix 4 Source #
(>) :: a -> a -> Bool infix 4 Source #
Instances
Conversion of values to readable String
s.
Derived instances of Show
have the following properties, which
are compatible with derived instances of Read
:
- The result of
show
is a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used. - If the constructor is defined to be an infix operator, then
showsPrec
will produce infix applications of the constructor. - the representation will be enclosed in parentheses if the
precedence of the top-level constructor in
x
is less thand
(associativity is ignored). Thus, ifd
is0
then the result is never surrounded in parentheses; ifd
is11
it is always surrounded in parentheses, unless it is an atomic expression. - If the constructor is defined using record syntax, then
show
will produce the record-syntax form, with the fields given in the same order as the original declaration.
For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Show
is equivalent to
instance (Show a) => Show (Tree a) where showsPrec d (Leaf m) = showParen (d > app_prec) $ showString "Leaf " . showsPrec (app_prec+1) m where app_prec = 10 showsPrec d (u :^: v) = showParen (d > up_prec) $ showsPrec (up_prec+1) u . showString " :^: " . showsPrec (up_prec+1) v where up_prec = 5
Note that right-associativity of :^:
is ignored. For example,
produces the stringshow
(Leaf 1 :^: Leaf 2 :^: Leaf 3)"Leaf 1 :^: (Leaf 2 :^: Leaf 3)"
.
Methods
Arguments
:: Int | the operator precedence of the enclosing
context (a number from |
-> a | the value to be converted to a |
-> ShowS |
Convert a value to a readable String
.
showsPrec
should satisfy the law
showsPrec d x r ++ s == showsPrec d x (r ++ s)
Derived instances of Read
and Show
satisfy the following:
That is, readsPrec
parses the string produced by
showsPrec
, and delivers the value that showsPrec
started with.
Instances
class Monad m => MonadFail (m :: Type -> Type) where Source #
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 IsString a where Source #
Class for string-like datastructures; used by the overloaded string extension (-XOverloadedStrings in GHC).
Methods
fromString :: String -> a Source #
Instances
class Functor f => Applicative (f :: Type -> Type) where Source #
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).
Methods
Lift a value.
(<*>) :: f (a -> b) -> f a -> f b infixl 4 Source #
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 Source #
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 Source #
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 Source #
Sequence actions, discarding the value of the second argument.
Instances
class Foldable (t :: TYPE LiftedRep -> Type) where Source #
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.
Methods
fold :: Monoid m => t m -> m Source #
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 Source #
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 Source #
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 Source #
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 Source #
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 Source #
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 Source #
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 Source #
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 Source #
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 *
List of elements of a structure, from left to right. If the entire list is intended to be reduced via a fold, just fold the structure directly bypassing the list.
Examples
Basic usage:
>>>
toList Nothing
[]
>>>
toList (Just 42)
[42]
>>>
toList (Left "foo")
[]
>>>
toList (Node (Leaf 5) 17 (Node Empty 12 (Leaf 8)))
[5,17,12,8]
For lists, toList
is the identity:
>>>
toList [1, 2, 3]
[1,2,3]
Since: base-4.8.0.0
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 Source #
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 Source #
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 Source #
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
sum :: Num a => t a -> a Source #
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 Source #
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 KeyMap | |
Defined in Data.Aeson.KeyMap Methods fold :: Monoid m => KeyMap m -> m Source # foldMap :: Monoid m => (a -> m) -> KeyMap a -> m Source # foldMap' :: Monoid m => (a -> m) -> KeyMap a -> m Source # foldr :: (a -> b -> b) -> b -> KeyMap a -> b Source # foldr' :: (a -> b -> b) -> b -> KeyMap a -> b Source # foldl :: (b -> a -> b) -> b -> KeyMap a -> b Source # foldl' :: (b -> a -> b) -> b -> KeyMap a -> b Source # foldr1 :: (a -> a -> a) -> KeyMap a -> a Source # foldl1 :: (a -> a -> a) -> KeyMap a -> a Source # toList :: KeyMap a -> [a] Source # null :: KeyMap a -> Bool Source # length :: KeyMap a -> Int Source # elem :: Eq a => a -> KeyMap a -> Bool Source # maximum :: Ord a => KeyMap a -> a Source # minimum :: Ord a => KeyMap a -> a Source # | |
Foldable IResult | |
Defined in Data.Aeson.Types.Internal Methods fold :: Monoid m => IResult m -> m Source # foldMap :: Monoid m => (a -> m) -> IResult a -> m Source # foldMap' :: Monoid m => (a -> m) -> IResult a -> m Source # foldr :: (a -> b -> b) -> b -> IResult a -> b Source # foldr' :: (a -> b -> b) -> b -> IResult a -> b Source # foldl :: (b -> a -> b) -> b -> IResult a -> b Source # foldl' :: (b -> a -> b) -> b -> IResult a -> b Source # foldr1 :: (a -> a -> a) -> IResult a -> a Source # foldl1 :: (a -> a -> a) -> IResult a -> a Source # toList :: IResult a -> [a] Source # null :: IResult a -> Bool Source # length :: IResult a -> Int Source # elem :: Eq a => a -> IResult a -> Bool Source # maximum :: Ord a => IResult a -> a Source # minimum :: Ord a => IResult a -> a Source # | |
Foldable Result | |
Defined in Data.Aeson.Types.Internal Methods fold :: Monoid m => Result m -> m Source # foldMap :: Monoid m => (a -> m) -> Result a -> m Source # foldMap' :: Monoid m => (a -> m) -> Result a -> m Source # foldr :: (a -> b -> b) -> b -> Result a -> b Source # foldr' :: (a -> b -> b) -> b -> Result a -> b Source # foldl :: (b -> a -> b) -> b -> Result a -> b Source # foldl' :: (b -> a -> b) -> b -> Result a -> b Source # foldr1 :: (a -> a -> a) -> Result a -> a Source # foldl1 :: (a -> a -> a) -> Result a -> a Source # toList :: Result a -> [a] Source # null :: Result a -> Bool Source # length :: Result a -> Int Source # elem :: Eq a => a -> Result a -> Bool Source # maximum :: Ord a => Result a -> a Source # minimum :: Ord a => Result a -> a Source # | |
Foldable ZipList | Since: base-4.9.0.0 |
Defined in Control.Applicative Methods fold :: Monoid m => ZipList m -> m Source # foldMap :: Monoid m => (a -> m) -> ZipList a -> m Source # foldMap' :: Monoid m => (a -> m) -> ZipList a -> m Source # foldr :: (a -> b -> b) -> b -> ZipList a -> b Source # foldr' :: (a -> b -> b) -> b -> ZipList a -> b Source # foldl :: (b -> a -> b) -> b -> ZipList a -> b Source # foldl' :: (b -> a -> b) -> b -> ZipList a -> b Source # foldr1 :: (a -> a -> a) -> ZipList a -> a Source # foldl1 :: (a -> a -> a) -> ZipList a -> a Source # toList :: ZipList a -> [a] Source # null :: ZipList a -> Bool Source # length :: ZipList a -> Int Source # elem :: Eq a => a -> ZipList a -> Bool Source # maximum :: Ord a => ZipList a -> a Source # minimum :: Ord a => ZipList a -> a Source # | |
Foldable Identity | Since: base-4.8.0.0 |
Defined in Data.Functor.Identity Methods fold :: Monoid m => Identity m -> m Source # foldMap :: Monoid m => (a -> m) -> Identity a -> m Source # foldMap' :: Monoid m => (a -> m) -> Identity a -> m Source # foldr :: (a -> b -> b) -> b -> Identity a -> b Source # foldr' :: (a -> b -> b) -> b -> Identity a -> b Source # foldl :: (b -> a -> b) -> b -> Identity a -> b Source # foldl' :: (b -> a -> b) -> b -> Identity a -> b Source # foldr1 :: (a -> a -> a) -> Identity a -> a Source # foldl1 :: (a -> a -> a) -> Identity a -> a Source # toList :: Identity a -> [a] Source # null :: Identity a -> Bool Source # length :: Identity a -> Int Source # elem :: Eq a => a -> Identity a -> Bool Source # maximum :: Ord a => Identity a -> a Source # minimum :: Ord a => Identity a -> a Source # | |
Foldable First | Since: base-4.8.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => First m -> m Source # foldMap :: Monoid m => (a -> m) -> First a -> m Source # foldMap' :: Monoid m => (a -> m) -> First a -> m Source # foldr :: (a -> b -> b) -> b -> First a -> b Source # foldr' :: (a -> b -> b) -> b -> First a -> b Source # foldl :: (b -> a -> b) -> b -> First a -> b Source # foldl' :: (b -> a -> b) -> b -> First a -> b Source # foldr1 :: (a -> a -> a) -> First a -> a Source # foldl1 :: (a -> a -> a) -> First a -> a Source # toList :: First a -> [a] Source # null :: First a -> Bool Source # length :: First a -> Int Source # elem :: Eq a => a -> First a -> Bool Source # maximum :: Ord a => First a -> a Source # minimum :: Ord a => First a -> a Source # | |
Foldable Last | Since: base-4.8.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Last m -> m Source # foldMap :: Monoid m => (a -> m) -> Last a -> m Source # foldMap' :: Monoid m => (a -> m) -> Last a -> m Source # foldr :: (a -> b -> b) -> b -> Last a -> b Source # foldr' :: (a -> b -> b) -> b -> Last a -> b Source # foldl :: (b -> a -> b) -> b -> Last a -> b Source # foldl' :: (b -> a -> b) -> b -> Last a -> b Source # foldr1 :: (a -> a -> a) -> Last a -> a Source # foldl1 :: (a -> a -> a) -> Last a -> a Source # toList :: Last a -> [a] Source # null :: Last a -> Bool Source # length :: Last a -> Int Source # elem :: Eq a => a -> Last a -> Bool Source # maximum :: Ord a => Last a -> a Source # minimum :: Ord a => Last a -> a Source # | |
Foldable Down | Since: base-4.12.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Down m -> m Source # foldMap :: Monoid m => (a -> m) -> Down a -> m Source # foldMap' :: Monoid m => (a -> m) -> Down a -> m Source # foldr :: (a -> b -> b) -> b -> Down a -> b Source # foldr' :: (a -> b -> b) -> b -> Down a -> b Source # foldl :: (b -> a -> b) -> b -> Down a -> b Source # foldl' :: (b -> a -> b) -> b -> Down a -> b Source # foldr1 :: (a -> a -> a) -> Down a -> a Source # foldl1 :: (a -> a -> a) -> Down a -> a Source # toList :: Down a -> [a] Source # null :: Down a -> Bool Source # length :: Down a -> Int Source # elem :: Eq a => a -> Down a -> Bool Source # maximum :: Ord a => Down a -> a Source # minimum :: Ord a => Down a -> a Source # | |
Foldable First | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methods fold :: Monoid m => First m -> m Source # foldMap :: Monoid m => (a -> m) -> First a -> m Source # foldMap' :: Monoid m => (a -> m) -> First a -> m Source # foldr :: (a -> b -> b) -> b -> First a -> b Source # foldr' :: (a -> b -> b) -> b -> First a -> b Source # foldl :: (b -> a -> b) -> b -> First a -> b Source # foldl' :: (b -> a -> b) -> b -> First a -> b Source # foldr1 :: (a -> a -> a) -> First a -> a Source # foldl1 :: (a -> a -> a) -> First a -> a Source # toList :: First a -> [a] Source # null :: First a -> Bool Source # length :: First a -> Int Source # elem :: Eq a => a -> First a -> Bool Source # maximum :: Ord a => First a -> a Source # minimum :: Ord a => First a -> a Source # | |
Foldable Last | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methods fold :: Monoid m => Last m -> m Source # foldMap :: Monoid m => (a -> m) -> Last a -> m Source # foldMap' :: Monoid m => (a -> m) -> Last a -> m Source # foldr :: (a -> b -> b) -> b -> Last a -> b Source # foldr' :: (a -> b -> b) -> b -> Last a -> b Source # foldl :: (b -> a -> b) -> b -> Last a -> b Source # foldl' :: (b -> a -> b) -> b -> Last a -> b Source # foldr1 :: (a -> a -> a) -> Last a -> a Source # foldl1 :: (a -> a -> a) -> Last a -> a Source # toList :: Last a -> [a] Source # null :: Last a -> Bool Source # length :: Last a -> Int Source # elem :: Eq a => a -> Last a -> Bool Source # maximum :: Ord a => Last a -> a Source # minimum :: Ord a => Last a -> a Source # | |
Foldable Max | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methods fold :: Monoid m => Max m -> m Source # foldMap :: Monoid m => (a -> m) -> Max a -> m Source # foldMap' :: Monoid m => (a -> m) -> Max a -> m Source # foldr :: (a -> b -> b) -> b -> Max a -> b Source # foldr' :: (a -> b -> b) -> b -> Max a -> b Source # foldl :: (b -> a -> b) -> b -> Max a -> b Source # foldl' :: (b -> a -> b) -> b -> Max a -> b Source # foldr1 :: (a -> a -> a) -> Max a -> a Source # foldl1 :: (a -> a -> a) -> Max a -> a Source # toList :: Max a -> [a] Source # null :: Max a -> Bool Source # length :: Max a -> Int Source # elem :: Eq a => a -> Max a -> Bool Source # maximum :: Ord a => Max a -> a Source # minimum :: Ord a => Max a -> a Source # | |
Foldable Min | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methods fold :: Monoid m => Min m -> m Source # foldMap :: Monoid m => (a -> m) -> Min a -> m Source # foldMap' :: Monoid m => (a -> m) -> Min a -> m Source # foldr :: (a -> b -> b) -> b -> Min a -> b Source # foldr' :: (a -> b -> b) -> b -> Min a -> b Source # foldl :: (b -> a -> b) -> b -> Min a -> b Source # foldl' :: (b -> a -> b) -> b -> Min a -> b Source # foldr1 :: (a -> a -> a) -> Min a -> a Source # foldl1 :: (a -> a -> a) -> Min a -> a Source # toList :: Min a -> [a] Source # null :: Min a -> Bool Source # length :: Min a -> Int Source # elem :: Eq a => a -> Min a -> Bool Source # maximum :: Ord a => Min a -> a Source # minimum :: Ord a => Min a -> a Source # | |
Foldable Dual | Since: base-4.8.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Dual m -> m Source # foldMap :: Monoid m => (a -> m) -> Dual a -> m Source # foldMap' :: Monoid m => (a -> m) -> Dual a -> m Source # foldr :: (a -> b -> b) -> b -> Dual a -> b Source # foldr' :: (a -> b -> b) -> b -> Dual a -> b Source # foldl :: (b -> a -> b) -> b -> Dual a -> b Source # foldl' :: (b -> a -> b) -> b -> Dual a -> b Source # foldr1 :: (a -> a -> a) -> Dual a -> a Source # foldl1 :: (a -> a -> a) -> Dual a -> a Source # toList :: Dual a -> [a] Source # null :: Dual a -> Bool Source # length :: Dual a -> Int Source # elem :: Eq a => a -> Dual a -> Bool Source # maximum :: Ord a => Dual a -> a Source # minimum :: Ord a => Dual a -> a Source # | |
Foldable Product | Since: base-4.8.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Product m -> m Source # foldMap :: Monoid m => (a -> m) -> Product a -> m Source # foldMap' :: Monoid m => (a -> m) -> Product a -> m Source # foldr :: (a -> b -> b) -> b -> Product a -> b Source # foldr' :: (a -> b -> b) -> b -> Product a -> b Source # foldl :: (b -> a -> b) -> b -> Product a -> b Source # foldl' :: (b -> a -> b) -> b -> Product a -> b Source # foldr1 :: (a -> a -> a) -> Product a -> a Source # foldl1 :: (a -> a -> a) -> Product a -> a Source # toList :: Product a -> [a] Source # null :: Product a -> Bool Source # length :: Product a -> Int Source # elem :: Eq a => a -> Product a -> Bool Source # maximum :: Ord a => Product a -> a Source # minimum :: Ord a => Product a -> a Source # | |
Foldable Sum | Since: base-4.8.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Sum m -> m Source # foldMap :: Monoid m => (a -> m) -> Sum a -> m Source # foldMap' :: Monoid m => (a -> m) -> Sum a -> m Source # foldr :: (a -> b -> b) -> b -> Sum a -> b Source # foldr' :: (a -> b -> b) -> b -> Sum a -> b Source # foldl :: (b -> a -> b) -> b -> Sum a -> b Source # foldl' :: (b -> a -> b) -> b -> Sum a -> b Source # foldr1 :: (a -> a -> a) -> Sum a -> a Source # foldl1 :: (a -> a -> a) -> Sum a -> a Source # toList :: Sum a -> [a] Source # null :: Sum a -> Bool Source # length :: Sum a -> Int Source # elem :: Eq a => a -> Sum a -> Bool Source # maximum :: Ord a => Sum a -> a Source # minimum :: Ord a => Sum a -> a Source # | |
Foldable Par1 | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Par1 m -> m Source # foldMap :: Monoid m => (a -> m) -> Par1 a -> m Source # foldMap' :: Monoid m => (a -> m) -> Par1 a -> m Source # foldr :: (a -> b -> b) -> b -> Par1 a -> b Source # foldr' :: (a -> b -> b) -> b -> Par1 a -> b Source # foldl :: (b -> a -> b) -> b -> Par1 a -> b Source # foldl' :: (b -> a -> b) -> b -> Par1 a -> b Source # foldr1 :: (a -> a -> a) -> Par1 a -> a Source # foldl1 :: (a -> a -> a) -> Par1 a -> a Source # toList :: Par1 a -> [a] Source # null :: Par1 a -> Bool Source # length :: Par1 a -> Int Source # elem :: Eq a => a -> Par1 a -> Bool Source # maximum :: Ord a => Par1 a -> a Source # minimum :: Ord a => Par1 a -> a Source # | |
Foldable Digit | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => Digit m -> m Source # foldMap :: Monoid m => (a -> m) -> Digit a -> m Source # foldMap' :: Monoid m => (a -> m) -> Digit a -> m Source # foldr :: (a -> b -> b) -> b -> Digit a -> b Source # foldr' :: (a -> b -> b) -> b -> Digit a -> b Source # foldl :: (b -> a -> b) -> b -> Digit a -> b Source # foldl' :: (b -> a -> b) -> b -> Digit a -> b Source # foldr1 :: (a -> a -> a) -> Digit a -> a Source # foldl1 :: (a -> a -> a) -> Digit a -> a Source # toList :: Digit a -> [a] Source # null :: Digit a -> Bool Source # length :: Digit a -> Int Source # elem :: Eq a => a -> Digit a -> Bool Source # maximum :: Ord a => Digit a -> a Source # minimum :: Ord a => Digit a -> a Source # | |
Foldable Elem | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => Elem m -> m Source # foldMap :: Monoid m => (a -> m) -> Elem a -> m Source # foldMap' :: Monoid m => (a -> m) -> Elem a -> m Source # foldr :: (a -> b -> b) -> b -> Elem a -> b Source # foldr' :: (a -> b -> b) -> b -> Elem a -> b Source # foldl :: (b -> a -> b) -> b -> Elem a -> b Source # foldl' :: (b -> a -> b) -> b -> Elem a -> b Source # foldr1 :: (a -> a -> a) -> Elem a -> a Source # foldl1 :: (a -> a -> a) -> Elem a -> a Source # toList :: Elem a -> [a] Source # null :: Elem a -> Bool Source # length :: Elem a -> Int Source # elem :: Eq a => a -> Elem a -> Bool Source # maximum :: Ord a => Elem a -> a Source # minimum :: Ord a => Elem a -> a Source # | |
Foldable FingerTree | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => FingerTree m -> m Source # foldMap :: Monoid m => (a -> m) -> FingerTree a -> m Source # foldMap' :: Monoid m => (a -> m) -> FingerTree a -> m Source # foldr :: (a -> b -> b) -> b -> FingerTree a -> b Source # foldr' :: (a -> b -> b) -> b -> FingerTree a -> b Source # foldl :: (b -> a -> b) -> b -> FingerTree a -> b Source # foldl' :: (b -> a -> b) -> b -> FingerTree a -> b Source # foldr1 :: (a -> a -> a) -> FingerTree a -> a Source # foldl1 :: (a -> a -> a) -> FingerTree a -> a Source # toList :: FingerTree a -> [a] Source # null :: FingerTree a -> Bool Source # length :: FingerTree a -> Int Source # elem :: Eq a => a -> FingerTree a -> Bool Source # maximum :: Ord a => FingerTree a -> a Source # minimum :: Ord a => FingerTree a -> a Source # sum :: Num a => FingerTree a -> a Source # product :: Num a => FingerTree a -> a Source # | |
Foldable Node | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => Node m -> m Source # foldMap :: Monoid m => (a -> m) -> Node a -> m Source # foldMap' :: Monoid m => (a -> m) -> Node a -> m Source # foldr :: (a -> b -> b) -> b -> Node a -> b Source # foldr' :: (a -> b -> b) -> b -> Node a -> b Source # foldl :: (b -> a -> b) -> b -> Node a -> b Source # foldl' :: (b -> a -> b) -> b -> Node a -> b Source # foldr1 :: (a -> a -> a) -> Node a -> a Source # foldl1 :: (a -> a -> a) -> Node a -> a Source # toList :: Node a -> [a] Source # null :: Node a -> Bool Source # length :: Node a -> Int Source # elem :: Eq a => a -> Node a -> Bool Source # maximum :: Ord a => Node a -> a Source # minimum :: Ord a => Node a -> a Source # | |
Foldable Seq | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => Seq m -> m Source # foldMap :: Monoid m => (a -> m) -> Seq a -> m Source # foldMap' :: Monoid m => (a -> m) -> Seq a -> m Source # foldr :: (a -> b -> b) -> b -> Seq a -> b Source # foldr' :: (a -> b -> b) -> b -> Seq a -> b Source # foldl :: (b -> a -> b) -> b -> Seq a -> b Source # foldl' :: (b -> a -> b) -> b -> Seq a -> b Source # foldr1 :: (a -> a -> a) -> Seq a -> a Source # foldl1 :: (a -> a -> a) -> Seq a -> a Source # toList :: Seq a -> [a] Source # null :: Seq a -> Bool Source # length :: Seq a -> Int Source # elem :: Eq a => a -> Seq a -> Bool Source # maximum :: Ord a => Seq a -> a Source # minimum :: Ord a => Seq a -> a Source # | |
Foldable ViewL | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => ViewL m -> m Source # foldMap :: Monoid m => (a -> m) -> ViewL a -> m Source # foldMap' :: Monoid m => (a -> m) -> ViewL a -> m Source # foldr :: (a -> b -> b) -> b -> ViewL a -> b Source # foldr' :: (a -> b -> b) -> b -> ViewL a -> b Source # foldl :: (b -> a -> b) -> b -> ViewL a -> b Source # foldl' :: (b -> a -> b) -> b -> ViewL a -> b Source # foldr1 :: (a -> a -> a) -> ViewL a -> a Source # foldl1 :: (a -> a -> a) -> ViewL a -> a Source # toList :: ViewL a -> [a] Source # null :: ViewL a -> Bool Source # length :: ViewL a -> Int Source # elem :: Eq a => a -> ViewL a -> Bool Source # maximum :: Ord a => ViewL a -> a Source # minimum :: Ord a => ViewL a -> a Source # | |
Foldable ViewR | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => ViewR m -> m Source # foldMap :: Monoid m => (a -> m) -> ViewR a -> m Source # foldMap' :: Monoid m => (a -> m) -> ViewR a -> m Source # foldr :: (a -> b -> b) -> b -> ViewR a -> b Source # foldr' :: (a -> b -> b) -> b -> ViewR a -> b Source # foldl :: (b -> a -> b) -> b -> ViewR a -> b Source # foldl' :: (b -> a -> b) -> b -> ViewR a -> b Source # foldr1 :: (a -> a -> a) -> ViewR a -> a Source # foldl1 :: (a -> a -> a) -> ViewR a -> a Source # toList :: ViewR a -> [a] Source # null :: ViewR a -> Bool Source # length :: ViewR a -> Int Source # elem :: Eq a => a -> ViewR a -> Bool Source # maximum :: Ord a => ViewR a -> a Source # minimum :: Ord a => ViewR a -> a Source # | |
Foldable Set | Folds in order of increasing key. |
Defined in Data.Set.Internal Methods fold :: Monoid m => Set m -> m Source # foldMap :: Monoid m => (a -> m) -> Set a -> m Source # foldMap' :: Monoid m => (a -> m) -> Set a -> m Source # foldr :: (a -> b -> b) -> b -> Set a -> b Source # foldr' :: (a -> b -> b) -> b -> Set a -> b Source # foldl :: (b -> a -> b) -> b -> Set a -> b Source # foldl' :: (b -> a -> b) -> b -> Set a -> b Source # foldr1 :: (a -> a -> a) -> Set a -> a Source # foldl1 :: (a -> a -> a) -> Set a -> a Source # toList :: Set a -> [a] Source # null :: Set a -> Bool Source # length :: Set a -> Int Source # elem :: Eq a => a -> Set a -> Bool Source # maximum :: Ord a => Set a -> a Source # minimum :: Ord a => Set a -> a Source # | |
Foldable DNonEmpty | |
Defined in Data.DList.DNonEmpty.Internal Methods fold :: Monoid m => DNonEmpty m -> m Source # foldMap :: Monoid m => (a -> m) -> DNonEmpty a -> m Source # foldMap' :: Monoid m => (a -> m) -> DNonEmpty a -> m Source # foldr :: (a -> b -> b) -> b -> DNonEmpty a -> b Source # foldr' :: (a -> b -> b) -> b -> DNonEmpty a -> b Source # foldl :: (b -> a -> b) -> b -> DNonEmpty a -> b Source # foldl' :: (b -> a -> b) -> b -> DNonEmpty a -> b Source # foldr1 :: (a -> a -> a) -> DNonEmpty a -> a Source # foldl1 :: (a -> a -> a) -> DNonEmpty a -> a Source # toList :: DNonEmpty a -> [a] Source # null :: DNonEmpty a -> Bool Source # length :: DNonEmpty a -> Int Source # elem :: Eq a => a -> DNonEmpty a -> Bool Source # maximum :: Ord a => DNonEmpty a -> a Source # minimum :: Ord a => DNonEmpty a -> a Source # | |
Foldable DList | |
Defined in Data.DList.Internal Methods fold :: Monoid m => DList m -> m Source # foldMap :: Monoid m => (a -> m) -> DList a -> m Source # foldMap' :: Monoid m => (a -> m) -> DList a -> m Source # foldr :: (a -> b -> b) -> b -> DList a -> b Source # foldr' :: (a -> b -> b) -> b -> DList a -> b Source # foldl :: (b -> a -> b) -> b -> DList a -> b Source # foldl' :: (b -> a -> b) -> b -> DList a -> b Source # foldr1 :: (a -> a -> a) -> DList a -> a Source # foldl1 :: (a -> a -> a) -> DList a -> a Source # toList :: DList a -> [a] Source # null :: DList a -> Bool Source # length :: DList a -> Int Source # elem :: Eq a => a -> DList a -> Bool Source # maximum :: Ord a => DList a -> a Source # minimum :: Ord a => DList a -> a Source # | |
Foldable Hashed | |
Defined in Data.Hashable.Class Methods fold :: Monoid m => Hashed m -> m Source # foldMap :: Monoid m => (a -> m) -> Hashed a -> m Source # foldMap' :: Monoid m => (a -> m) -> Hashed a -> m Source # foldr :: (a -> b -> b) -> b -> Hashed a -> b Source # foldr' :: (a -> b -> b) -> b -> Hashed a -> b Source # foldl :: (b -> a -> b) -> b -> Hashed a -> b Source # foldl' :: (b -> a -> b) -> b -> Hashed a -> b Source # foldr1 :: (a -> a -> a) -> Hashed a -> a Source # foldl1 :: (a -> a -> a) -> Hashed a -> a Source # toList :: Hashed a -> [a] Source # null :: Hashed a -> Bool Source # length :: Hashed a -> Int Source # elem :: Eq a => a -> Hashed a -> Bool Source # maximum :: Ord a => Hashed a -> a Source # minimum :: Ord a => Hashed a -> a Source # | |
Foldable SimpleDocStream | Collect all annotations from a document. |
Defined in Prettyprinter.Internal Methods fold :: Monoid m => SimpleDocStream m -> m Source # foldMap :: Monoid m => (a -> m) -> SimpleDocStream a -> m Source # foldMap' :: Monoid m => (a -> m) -> SimpleDocStream a -> m Source # foldr :: (a -> b -> b) -> b -> SimpleDocStream a -> b Source # foldr' :: (a -> b -> b) -> b -> SimpleDocStream a -> b Source # foldl :: (b -> a -> b) -> b -> SimpleDocStream a -> b Source # foldl' :: (b -> a -> b) -> b -> SimpleDocStream a -> b Source # foldr1 :: (a -> a -> a) -> SimpleDocStream a -> a Source # foldl1 :: (a -> a -> a) -> SimpleDocStream a -> a Source # toList :: SimpleDocStream a -> [a] Source # null :: SimpleDocStream a -> Bool Source # length :: SimpleDocStream a -> Int Source # elem :: Eq a => a -> SimpleDocStream a -> Bool Source # maximum :: Ord a => SimpleDocStream a -> a Source # minimum :: Ord a => SimpleDocStream a -> a Source # sum :: Num a => SimpleDocStream a -> a Source # product :: Num a => SimpleDocStream a -> a Source # | |
Foldable Array | |
Defined in Data.Primitive.Array Methods fold :: Monoid m => Array m -> m Source # foldMap :: Monoid m => (a -> m) -> Array a -> m Source # foldMap' :: Monoid m => (a -> m) -> Array a -> m Source # foldr :: (a -> b -> b) -> b -> Array a -> b Source # foldr' :: (a -> b -> b) -> b -> Array a -> b Source # foldl :: (b -> a -> b) -> b -> Array a -> b Source # foldl' :: (b -> a -> b) -> b -> Array a -> b Source # foldr1 :: (a -> a -> a) -> Array a -> a Source # foldl1 :: (a -> a -> a) -> Array a -> a Source # toList :: Array a -> [a] Source # null :: Array a -> Bool Source # length :: Array a -> Int Source # elem :: Eq a => a -> Array a -> Bool Source # maximum :: Ord a => Array a -> a Source # minimum :: Ord a => Array a -> a Source # | |
Foldable SmallArray | |
Defined in Data.Primitive.SmallArray Methods fold :: Monoid m => SmallArray m -> m Source # foldMap :: Monoid m => (a -> m) -> SmallArray a -> m Source # foldMap' :: Monoid m => (a -> m) -> SmallArray a -> m Source # foldr :: (a -> b -> b) -> b -> SmallArray a -> b Source # foldr' :: (a -> b -> b) -> b -> SmallArray a -> b Source # foldl :: (b -> a -> b) -> b -> SmallArray a -> b Source # foldl' :: (b -> a -> b) -> b -> SmallArray a -> b Source # foldr1 :: (a -> a -> a) -> SmallArray a -> a Source # foldl1 :: (a -> a -> a) -> SmallArray a -> a Source # toList :: SmallArray a -> [a] Source # null :: SmallArray a -> Bool Source # length :: SmallArray a -> Int Source # elem :: Eq a => a -> SmallArray a -> Bool Source # maximum :: Ord a => SmallArray a -> a Source # minimum :: Ord a => SmallArray a -> a Source # sum :: Num a => SmallArray a -> a Source # product :: Num a => SmallArray a -> a Source # | |
Foldable Maybe | |
Defined in Data.Strict.Maybe Methods fold :: Monoid m => Maybe m -> m Source # foldMap :: Monoid m => (a -> m) -> Maybe a -> m Source # foldMap' :: Monoid m => (a -> m) -> Maybe a -> m Source # foldr :: (a -> b -> b) -> b -> Maybe a -> b Source # foldr' :: (a -> b -> b) -> b -> Maybe a -> b Source # foldl :: (b -> a -> b) -> b -> Maybe a -> b Source # foldl' :: (b -> a -> b) -> b -> Maybe a -> b Source # foldr1 :: (a -> a -> a) -> Maybe a -> a Source # foldl1 :: (a -> a -> a) -> Maybe a -> a Source # toList :: Maybe a -> [a] Source # null :: Maybe a -> Bool Source # length :: Maybe a -> Int Source # elem :: Eq a => a -> Maybe a -> Bool Source # maximum :: Ord a => Maybe a -> a Source # minimum :: Ord a => Maybe a -> a Source # | |
Foldable Window | |
Defined in System.Console.Terminal.Common Methods fold :: Monoid m => Window m -> m Source # foldMap :: Monoid m => (a -> m) -> Window a -> m Source # foldMap' :: Monoid m => (a -> m) -> Window a -> m Source # foldr :: (a -> b -> b) -> b -> Window a -> b Source # foldr' :: (a -> b -> b) -> b -> Window a -> b Source # foldl :: (b -> a -> b) -> b -> Window a -> b Source # foldl' :: (b -> a -> b) -> b -> Window a -> b Source # foldr1 :: (a -> a -> a) -> Window a -> a Source # foldl1 :: (a -> a -> a) -> Window a -> a Source # toList :: Window a -> [a] Source # null :: Window a -> Bool Source # length :: Window a -> Int Source # elem :: Eq a => a -> Window a -> Bool Source # maximum :: Ord a => Window a -> a Source # minimum :: Ord a => Window a -> a Source # | |
Foldable HashSet | |
Defined in Data.HashSet.Internal Methods fold :: Monoid m => HashSet m -> m Source # foldMap :: Monoid m => (a -> m) -> HashSet a -> m Source # foldMap' :: Monoid m => (a -> m) -> HashSet a -> m Source # foldr :: (a -> b -> b) -> b -> HashSet a -> b Source # foldr' :: (a -> b -> b) -> b -> HashSet a -> b Source # foldl :: (b -> a -> b) -> b -> HashSet a -> b Source # foldl' :: (b -> a -> b) -> b -> HashSet a -> b Source # foldr1 :: (a -> a -> a) -> HashSet a -> a Source # foldl1 :: (a -> a -> a) -> HashSet a -> a Source # toList :: HashSet a -> [a] Source # null :: HashSet a -> Bool Source # length :: HashSet a -> Int Source # elem :: Eq a => a -> HashSet a -> Bool Source # maximum :: Ord a => HashSet a -> a Source # minimum :: Ord a => HashSet a -> a Source # | |
Foldable Vector | |
Defined in Data.Vector Methods fold :: Monoid m => Vector m -> m Source # foldMap :: Monoid m => (a -> m) -> Vector a -> m Source # foldMap' :: Monoid m => (a -> m) -> Vector a -> m Source # foldr :: (a -> b -> b) -> b -> Vector a -> b Source # foldr' :: (a -> b -> b) -> b -> Vector a -> b Source # foldl :: (b -> a -> b) -> b -> Vector a -> b Source # foldl' :: (b -> a -> b) -> b -> Vector a -> b Source # foldr1 :: (a -> a -> a) -> Vector a -> a Source # foldl1 :: (a -> a -> a) -> Vector a -> a Source # toList :: Vector a -> [a] Source # null :: Vector a -> Bool Source # length :: Vector a -> Int Source # elem :: Eq a => a -> Vector a -> Bool Source # maximum :: Ord a => Vector a -> a Source # minimum :: Ord a => Vector a -> a Source # | |
Foldable NonEmpty | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => NonEmpty m -> m Source # foldMap :: Monoid m => (a -> m) -> NonEmpty a -> m Source # foldMap' :: Monoid m => (a -> m) -> NonEmpty a -> m Source # foldr :: (a -> b -> b) -> b -> NonEmpty a -> b Source # foldr' :: (a -> b -> b) -> b -> NonEmpty a -> b Source # foldl :: (b -> a -> b) -> b -> NonEmpty a -> b Source # foldl' :: (b -> a -> b) -> b -> NonEmpty a -> b Source # foldr1 :: (a -> a -> a) -> NonEmpty a -> a Source # foldl1 :: (a -> a -> a) -> NonEmpty a -> a Source # toList :: NonEmpty a -> [a] Source # null :: NonEmpty a -> Bool Source # length :: NonEmpty a -> Int Source # elem :: Eq a => a -> NonEmpty a -> Bool Source # maximum :: Ord a => NonEmpty a -> a Source # minimum :: Ord a => NonEmpty a -> a Source # | |
Foldable Maybe | Since: base-2.1 |
Defined in Data.Foldable Methods fold :: Monoid m => Maybe m -> m Source # foldMap :: Monoid m => (a -> m) -> Maybe a -> m Source # foldMap' :: Monoid m => (a -> m) -> Maybe a -> m Source # foldr :: (a -> b -> b) -> b -> Maybe a -> b Source # foldr' :: (a -> b -> b) -> b -> Maybe a -> b Source # foldl :: (b -> a -> b) -> b -> Maybe a -> b Source # foldl' :: (b -> a -> b) -> b -> Maybe a -> b Source # foldr1 :: (a -> a -> a) -> Maybe a -> a Source # foldl1 :: (a -> a -> a) -> Maybe a -> a Source # toList :: Maybe a -> [a] Source # null :: Maybe a -> Bool Source # length :: Maybe a -> Int Source # elem :: Eq a => a -> Maybe a -> Bool Source # maximum :: Ord a => Maybe a -> a Source # minimum :: Ord a => Maybe a -> a Source # | |
Foldable Solo | Since: base-4.15 |
Defined in Data.Foldable Methods fold :: Monoid m => Solo m -> m Source # foldMap :: Monoid m => (a -> m) -> Solo a -> m Source # foldMap' :: Monoid m => (a -> m) -> Solo a -> m Source # foldr :: (a -> b -> b) -> b -> Solo a -> b Source # foldr' :: (a -> b -> b) -> b -> Solo a -> b Source # foldl :: (b -> a -> b) -> b -> Solo a -> b Source # foldl' :: (b -> a -> b) -> b -> Solo a -> b Source # foldr1 :: (a -> a -> a) -> Solo a -> a Source # foldl1 :: (a -> a -> a) -> Solo a -> a Source # toList :: Solo a -> [a] Source # null :: Solo a -> Bool Source # length :: Solo a -> Int Source # elem :: Eq a => a -> Solo a -> Bool Source # maximum :: Ord a => Solo a -> a Source # minimum :: Ord a => Solo a -> a Source # | |
Foldable [] | Since: base-2.1 |
Defined in Data.Foldable Methods fold :: Monoid m => [m] -> m Source # foldMap :: Monoid m => (a -> m) -> [a] -> m Source # foldMap' :: Monoid m => (a -> m) -> [a] -> m Source # foldr :: (a -> b -> b) -> b -> [a] -> b Source # foldr' :: (a -> b -> b) -> b -> [a] -> b Source # foldl :: (b -> a -> b) -> b -> [a] -> b Source # foldl' :: (b -> a -> b) -> b -> [a] -> b Source # foldr1 :: (a -> a -> a) -> [a] -> a Source # foldl1 :: (a -> a -> a) -> [a] -> a Source # elem :: Eq a => a -> [a] -> Bool Source # maximum :: Ord a => [a] -> a Source # minimum :: Ord a => [a] -> a Source # | |
Foldable (Either a) | Since: base-4.7.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Either a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> Either a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source # toList :: Either a a0 -> [a0] Source # null :: Either a a0 -> Bool Source # length :: Either a a0 -> Int Source # elem :: Eq a0 => a0 -> Either a a0 -> Bool Source # maximum :: Ord a0 => Either a a0 -> a0 Source # minimum :: Ord a0 => Either a a0 -> a0 Source # | |
Foldable (Proxy :: TYPE LiftedRep -> Type) | Since: base-4.7.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Proxy m -> m Source # foldMap :: Monoid m => (a -> m) -> Proxy a -> m Source # foldMap' :: Monoid m => (a -> m) -> Proxy a -> m Source # foldr :: (a -> b -> b) -> b -> Proxy a -> b Source # foldr' :: (a -> b -> b) -> b -> Proxy a -> b Source # foldl :: (b -> a -> b) -> b -> Proxy a -> b Source # foldl' :: (b -> a -> b) -> b -> Proxy a -> b Source # foldr1 :: (a -> a -> a) -> Proxy a -> a Source # foldl1 :: (a -> a -> a) -> Proxy a -> a Source # toList :: Proxy a -> [a] Source # null :: Proxy a -> Bool Source # length :: Proxy a -> Int Source # elem :: Eq a => a -> Proxy a -> Bool Source # maximum :: Ord a => Proxy a -> a Source # minimum :: Ord a => Proxy a -> a Source # | |
Foldable (Arg a) | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methods fold :: Monoid m => Arg a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> Arg a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> Arg a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> Arg a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> Arg a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> Arg a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> Arg a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 Source # toList :: Arg a a0 -> [a0] Source # null :: Arg a a0 -> Bool Source # length :: Arg a a0 -> Int Source # elem :: Eq a0 => a0 -> Arg a a0 -> Bool Source # maximum :: Ord a0 => Arg a a0 -> a0 Source # minimum :: Ord a0 => Arg a a0 -> a0 Source # | |
Foldable (Array i) | Since: base-4.8.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Array i m -> m Source # foldMap :: Monoid m => (a -> m) -> Array i a -> m Source # foldMap' :: Monoid m => (a -> m) -> Array i a -> m Source # foldr :: (a -> b -> b) -> b -> Array i a -> b Source # foldr' :: (a -> b -> b) -> b -> Array i a -> b Source # foldl :: (b -> a -> b) -> b -> Array i a -> b Source # foldl' :: (b -> a -> b) -> b -> Array i a -> b Source # foldr1 :: (a -> a -> a) -> Array i a -> a Source # foldl1 :: (a -> a -> a) -> Array i a -> a Source # toList :: Array i a -> [a] Source # null :: Array i a -> Bool Source # length :: Array i a -> Int Source # elem :: Eq a => a -> Array i a -> Bool Source # maximum :: Ord a => Array i a -> a Source # minimum :: Ord a => Array i a -> a Source # | |
Foldable (U1 :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => U1 m -> m Source # foldMap :: Monoid m => (a -> m) -> U1 a -> m Source # foldMap' :: Monoid m => (a -> m) -> U1 a -> m Source # foldr :: (a -> b -> b) -> b -> U1 a -> b Source # foldr' :: (a -> b -> b) -> b -> U1 a -> b Source # foldl :: (b -> a -> b) -> b -> U1 a -> b Source # foldl' :: (b -> a -> b) -> b -> U1 a -> b Source # foldr1 :: (a -> a -> a) -> U1 a -> a Source # foldl1 :: (a -> a -> a) -> U1 a -> a Source # toList :: U1 a -> [a] Source # length :: U1 a -> Int Source # elem :: Eq a => a -> U1 a -> Bool Source # maximum :: Ord a => U1 a -> a Source # minimum :: Ord a => U1 a -> a Source # | |
Foldable (UAddr :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => UAddr m -> m Source # foldMap :: Monoid m => (a -> m) -> UAddr a -> m Source # foldMap' :: Monoid m => (a -> m) -> UAddr a -> m Source # foldr :: (a -> b -> b) -> b -> UAddr a -> b Source # foldr' :: (a -> b -> b) -> b -> UAddr a -> b Source # foldl :: (b -> a -> b) -> b -> UAddr a -> b Source # foldl' :: (b -> a -> b) -> b -> UAddr a -> b Source # foldr1 :: (a -> a -> a) -> UAddr a -> a Source # foldl1 :: (a -> a -> a) -> UAddr a -> a Source # toList :: UAddr a -> [a] Source # null :: UAddr a -> Bool Source # length :: UAddr a -> Int Source # elem :: Eq a => a -> UAddr a -> Bool Source # maximum :: Ord a => UAddr a -> a Source # minimum :: Ord a => UAddr a -> a Source # | |
Foldable (UChar :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => UChar m -> m Source # foldMap :: Monoid m => (a -> m) -> UChar a -> m Source # foldMap' :: Monoid m => (a -> m) -> UChar a -> m Source # foldr :: (a -> b -> b) -> b -> UChar a -> b Source # foldr' :: (a -> b -> b) -> b -> UChar a -> b Source # foldl :: (b -> a -> b) -> b -> UChar a -> b Source # foldl' :: (b -> a -> b) -> b -> UChar a -> b Source # foldr1 :: (a -> a -> a) -> UChar a -> a Source # foldl1 :: (a -> a -> a) -> UChar a -> a Source # toList :: UChar a -> [a] Source # null :: UChar a -> Bool Source # length :: UChar a -> Int Source # elem :: Eq a => a -> UChar a -> Bool Source # maximum :: Ord a => UChar a -> a Source # minimum :: Ord a => UChar a -> a Source # | |
Foldable (UDouble :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => UDouble m -> m Source # foldMap :: Monoid m => (a -> m) -> UDouble a -> m Source # foldMap' :: Monoid m => (a -> m) -> UDouble a -> m Source # foldr :: (a -> b -> b) -> b -> UDouble a -> b Source # foldr' :: (a -> b -> b) -> b -> UDouble a -> b Source # foldl :: (b -> a -> b) -> b -> UDouble a -> b Source # foldl' :: (b -> a -> b) -> b -> UDouble a -> b Source # foldr1 :: (a -> a -> a) -> UDouble a -> a Source # foldl1 :: (a -> a -> a) -> UDouble a -> a Source # toList :: UDouble a -> [a] Source # null :: UDouble a -> Bool Source # length :: UDouble a -> Int Source # elem :: Eq a => a -> UDouble a -> Bool Source # maximum :: Ord a => UDouble a -> a Source # minimum :: Ord a => UDouble a -> a Source # | |
Foldable (UFloat :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => UFloat m -> m Source # foldMap :: Monoid m => (a -> m) -> UFloat a -> m Source # foldMap' :: Monoid m => (a -> m) -> UFloat a -> m Source # foldr :: (a -> b -> b) -> b -> UFloat a -> b Source # foldr' :: (a -> b -> b) -> b -> UFloat a -> b Source # foldl :: (b -> a -> b) -> b -> UFloat a -> b Source # foldl' :: (b -> a -> b) -> b -> UFloat a -> b Source # foldr1 :: (a -> a -> a) -> UFloat a -> a Source # foldl1 :: (a -> a -> a) -> UFloat a -> a Source # toList :: UFloat a -> [a] Source # null :: UFloat a -> Bool Source # length :: UFloat a -> Int Source # elem :: Eq a => a -> UFloat a -> Bool Source # maximum :: Ord a => UFloat a -> a Source # minimum :: Ord a => UFloat a -> a Source # | |
Foldable (UInt :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => UInt m -> m Source # foldMap :: Monoid m => (a -> m) -> UInt a -> m Source # foldMap' :: Monoid m => (a -> m) -> UInt a -> m Source # foldr :: (a -> b -> b) -> b -> UInt a -> b Source # foldr' :: (a -> b -> b) -> b -> UInt a -> b Source # foldl :: (b -> a -> b) -> b -> UInt a -> b Source # foldl' :: (b -> a -> b) -> b -> UInt a -> b Source # foldr1 :: (a -> a -> a) -> UInt a -> a Source # foldl1 :: (a -> a -> a) -> UInt a -> a Source # toList :: UInt a -> [a] Source # null :: UInt a -> Bool Source # length :: UInt a -> Int Source # elem :: Eq a => a -> UInt a -> Bool Source # maximum :: Ord a => UInt a -> a Source # minimum :: Ord a => UInt a -> a Source # | |
Foldable (UWord :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => UWord m -> m Source # foldMap :: Monoid m => (a -> m) -> UWord a -> m Source # foldMap' :: Monoid m => (a -> m) -> UWord a -> m Source # foldr :: (a -> b -> b) -> b -> UWord a -> b Source # foldr' :: (a -> b -> b) -> b -> UWord a -> b Source # foldl :: (b -> a -> b) -> b -> UWord a -> b Source # foldl' :: (b -> a -> b) -> b -> UWord a -> b Source # foldr1 :: (a -> a -> a) -> UWord a -> a Source # foldl1 :: (a -> a -> a) -> UWord a -> a Source # toList :: UWord a -> [a] Source # null :: UWord a -> Bool Source # length :: UWord a -> Int Source # elem :: Eq a => a -> UWord a -> Bool Source # maximum :: Ord a => UWord a -> a Source # minimum :: Ord a => UWord a -> a Source # | |
Foldable (V1 :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => V1 m -> m Source # foldMap :: Monoid m => (a -> m) -> V1 a -> m Source # foldMap' :: Monoid m => (a -> m) -> V1 a -> m Source # foldr :: (a -> b -> b) -> b -> V1 a -> b Source # foldr' :: (a -> b -> b) -> b -> V1 a -> b Source # foldl :: (b -> a -> b) -> b -> V1 a -> b Source # foldl' :: (b -> a -> b) -> b -> V1 a -> b Source # foldr1 :: (a -> a -> a) -> V1 a -> a Source # foldl1 :: (a -> a -> a) -> V1 a -> a Source # toList :: V1 a -> [a] Source # length :: V1 a -> Int Source # elem :: Eq a => a -> V1 a -> Bool Source # maximum :: Ord a => V1 a -> a Source # minimum :: Ord a => V1 a -> a Source # | |
Foldable (Map k) | Folds in order of increasing key. |
Defined in Data.Map.Internal Methods fold :: Monoid m => Map k m -> m Source # foldMap :: Monoid m => (a -> m) -> Map k a -> m Source # foldMap' :: Monoid m => (a -> m) -> Map k a -> m Source # foldr :: (a -> b -> b) -> b -> Map k a -> b Source # foldr' :: (a -> b -> b) -> b -> Map k a -> b Source # foldl :: (b -> a -> b) -> b -> Map k a -> b Source # foldl' :: (b -> a -> b) -> b -> Map k a -> b Source # foldr1 :: (a -> a -> a) -> Map k a -> a Source # foldl1 :: (a -> a -> a) -> Map k a -> a Source # toList :: Map k a -> [a] Source # null :: Map k a -> Bool Source # length :: Map k a -> Int Source # elem :: Eq a => a -> Map k a -> Bool Source # maximum :: Ord a => Map k a -> a Source # minimum :: Ord a => Map k a -> a Source # | |
Foldable f => Foldable (Cofree f) | |
Defined in Control.Comonad.Cofree Methods fold :: Monoid m => Cofree f m -> m Source # foldMap :: Monoid m => (a -> m) -> Cofree f a -> m Source # foldMap' :: Monoid m => (a -> m) -> Cofree f a -> m Source # foldr :: (a -> b -> b) -> b -> Cofree f a -> b Source # foldr' :: (a -> b -> b) -> b -> Cofree f a -> b Source # foldl :: (b -> a -> b) -> b -> Cofree f a -> b Source # foldl' :: (b -> a -> b) -> b -> Cofree f a -> b Source # foldr1 :: (a -> a -> a) -> Cofree f a -> a Source # foldl1 :: (a -> a -> a) -> Cofree f a -> a Source # toList :: Cofree f a -> [a] Source # null :: Cofree f a -> Bool Source # length :: Cofree f a -> Int Source # elem :: Eq a => a -> Cofree f a -> Bool Source # maximum :: Ord a => Cofree f a -> a Source # minimum :: Ord a => Cofree f a -> a Source # | |
Foldable f => Foldable (Free f) | |
Defined in Control.Monad.Free Methods fold :: Monoid m => Free f m -> m Source # foldMap :: Monoid m => (a -> m) -> Free f a -> m Source # foldMap' :: Monoid m => (a -> m) -> Free f a -> m Source # foldr :: (a -> b -> b) -> b -> Free f a -> b Source # foldr' :: (a -> b -> b) -> b -> Free f a -> b Source # foldl :: (b -> a -> b) -> b -> Free f a -> b Source # foldl' :: (b -> a -> b) -> b -> Free f a -> b Source # foldr1 :: (a -> a -> a) -> Free f a -> a Source # foldl1 :: (a -> a -> a) -> Free f a -> a Source # toList :: Free f a -> [a] Source # null :: Free f a -> Bool Source # length :: Free f a -> Int Source # elem :: Eq a => a -> Free f a -> Bool Source # maximum :: Ord a => Free f a -> a Source # minimum :: Ord a => Free f a -> a Source # | |
Foldable f => Foldable (Yoneda f) | |
Defined in Data.Functor.Yoneda Methods fold :: Monoid m => Yoneda f m -> m Source # foldMap :: Monoid m => (a -> m) -> Yoneda f a -> m Source # foldMap' :: Monoid m => (a -> m) -> Yoneda f a -> m Source # foldr :: (a -> b -> b) -> b -> Yoneda f a -> b Source # foldr' :: (a -> b -> b) -> b -> Yoneda f a -> b Source # foldl :: (b -> a -> b) -> b -> Yoneda f a -> b Source # foldl' :: (b -> a -> b) -> b -> Yoneda f a -> b Source # foldr1 :: (a -> a -> a) -> Yoneda f a -> a Source # foldl1 :: (a -> a -> a) -> Yoneda f a -> a Source # toList :: Yoneda f a -> [a] Source # null :: Yoneda f a -> Bool Source # length :: Yoneda f a -> Int Source # elem :: Eq a => a -> Yoneda f a -> Bool Source # maximum :: Ord a => Yoneda f a -> a Source # minimum :: Ord a => Yoneda f a -> a Source # | |
MonoFoldable mono => Foldable (WrappedMono mono) | |
Defined in Data.MonoTraversable Methods fold :: Monoid m => WrappedMono mono m -> m Source # foldMap :: Monoid m => (a -> m) -> WrappedMono mono a -> m Source # foldMap' :: Monoid m => (a -> m) -> WrappedMono mono a -> m Source # foldr :: (a -> b -> b) -> b -> WrappedMono mono a -> b Source # foldr' :: (a -> b -> b) -> b -> WrappedMono mono a -> b Source # foldl :: (b -> a -> b) -> b -> WrappedMono mono a -> b Source # foldl' :: (b -> a -> b) -> b -> WrappedMono mono a -> b Source # foldr1 :: (a -> a -> a) -> WrappedMono mono a -> a Source # foldl1 :: (a -> a -> a) -> WrappedMono mono a -> a Source # toList :: WrappedMono mono a -> [a] Source # null :: WrappedMono mono a -> Bool Source # length :: WrappedMono mono a -> Int Source # elem :: Eq a => a -> WrappedMono mono a -> Bool Source # maximum :: Ord a => WrappedMono mono a -> a Source # minimum :: Ord a => WrappedMono mono a -> a Source # sum :: Num a => WrappedMono mono a -> a Source # product :: Num a => WrappedMono mono a -> a Source # | |
Foldable f => Foldable (WrappedPoly f) | |
Defined in Data.MonoTraversable Methods fold :: Monoid m => WrappedPoly f m -> m Source # foldMap :: Monoid m => (a -> m) -> WrappedPoly f a -> m Source # foldMap' :: Monoid m => (a -> m) -> WrappedPoly f a -> m Source # foldr :: (a -> b -> b) -> b -> WrappedPoly f a -> b Source # foldr' :: (a -> b -> b) -> b -> WrappedPoly f a -> b Source # foldl :: (b -> a -> b) -> b -> WrappedPoly f a -> b Source # foldl' :: (b -> a -> b) -> b -> WrappedPoly f a -> b Source # foldr1 :: (a -> a -> a) -> WrappedPoly f a -> a Source # foldl1 :: (a -> a -> a) -> WrappedPoly f a -> a Source # toList :: WrappedPoly f a -> [a] Source # null :: WrappedPoly f a -> Bool Source # length :: WrappedPoly f a -> Int Source # elem :: Eq a => a -> WrappedPoly f a -> Bool Source # maximum :: Ord a => WrappedPoly f a -> a Source # minimum :: Ord a => WrappedPoly f a -> a Source # sum :: Num a => WrappedPoly f a -> a Source # product :: Num a => WrappedPoly f a -> a Source # | |
Foldable (Refined p) | Since: refined-0.2 |
Defined in Refined.Unsafe.Type Methods fold :: Monoid m => Refined p m -> m Source # foldMap :: Monoid m => (a -> m) -> Refined p a -> m Source # foldMap' :: Monoid m => (a -> m) -> Refined p a -> m Source # foldr :: (a -> b -> b) -> b -> Refined p a -> b Source # foldr' :: (a -> b -> b) -> b -> Refined p a -> b Source # foldl :: (b -> a -> b) -> b -> Refined p a -> b Source # foldl' :: (b -> a -> b) -> b -> Refined p a -> b Source # foldr1 :: (a -> a -> a) -> Refined p a -> a Source # foldl1 :: (a -> a -> a) -> Refined p a -> a Source # toList :: Refined p a -> [a] Source # null :: Refined p a -> Bool Source # length :: Refined p a -> Int Source # elem :: Eq a => a -> Refined p a -> Bool Source # maximum :: Ord a => Refined p a -> a Source # minimum :: Ord a => Refined p a -> a Source # | |
Foldable (Either e) | |
Defined in Data.Strict.Either Methods fold :: Monoid m => Either e m -> m Source # foldMap :: Monoid m => (a -> m) -> Either e a -> m Source # foldMap' :: Monoid m => (a -> m) -> Either e a -> m Source # foldr :: (a -> b -> b) -> b -> Either e a -> b Source # foldr' :: (a -> b -> b) -> b -> Either e a -> b Source # foldl :: (b -> a -> b) -> b -> Either e a -> b Source # foldl' :: (b -> a -> b) -> b -> Either e a -> b Source # foldr1 :: (a -> a -> a) -> Either e a -> a Source # foldl1 :: (a -> a -> a) -> Either e a -> a Source # toList :: Either e a -> [a] Source # null :: Either e a -> Bool Source # length :: Either e a -> Int Source # elem :: Eq a => a -> Either e a -> Bool Source # maximum :: Ord a => Either e a -> a Source # minimum :: Ord a => Either e a -> a Source # | |
Foldable (These a) | |
Defined in Data.Strict.These Methods fold :: Monoid m => These a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> These a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> These a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> These a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> These a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> These a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> These a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> These a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> These a a0 -> a0 Source # toList :: These a a0 -> [a0] Source # null :: These a a0 -> Bool Source # length :: These a a0 -> Int Source # elem :: Eq a0 => a0 -> These a a0 -> Bool Source # maximum :: Ord a0 => These a a0 -> a0 Source # minimum :: Ord a0 => These a a0 -> a0 Source # | |
Foldable (Pair e) | |
Defined in Data.Strict.Tuple Methods fold :: Monoid m => Pair e m -> m Source # foldMap :: Monoid m => (a -> m) -> Pair e a -> m Source # foldMap' :: Monoid m => (a -> m) -> Pair e a -> m Source # foldr :: (a -> b -> b) -> b -> Pair e a -> b Source # foldr' :: (a -> b -> b) -> b -> Pair e a -> b Source # foldl :: (b -> a -> b) -> b -> Pair e a -> b Source # foldl' :: (b -> a -> b) -> b -> Pair e a -> b Source # foldr1 :: (a -> a -> a) -> Pair e a -> a Source # foldl1 :: (a -> a -> a) -> Pair e a -> a Source # toList :: Pair e a -> [a] Source # null :: Pair e a -> Bool Source # length :: Pair e a -> Int Source # elem :: Eq a => a -> Pair e a -> Bool Source # maximum :: Ord a => Pair e a -> a Source # minimum :: Ord a => Pair e a -> a Source # | |
Foldable (These a) | |
Defined in Data.These Methods fold :: Monoid m => These a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> These a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> These a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> These a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> These a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> These a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> These a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> These a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> These a a0 -> a0 Source # toList :: These a a0 -> [a0] Source # null :: These a a0 -> Bool Source # length :: These a a0 -> Int Source # elem :: Eq a0 => a0 -> These a a0 -> Bool Source # maximum :: Ord a0 => These a a0 -> a0 Source # minimum :: Ord a0 => These a a0 -> a0 Source # | |
Foldable (These a) | |
Defined in Data.These Methods fold :: Monoid m => These a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> These a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> These a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> These a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> These a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> These a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> These a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> These a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> These a a0 -> a0 Source # toList :: These a a0 -> [a0] Source # null :: These a a0 -> Bool Source # length :: These a a0 -> Int Source # elem :: Eq a0 => a0 -> These a a0 -> Bool Source # maximum :: Ord a0 => These a a0 -> a0 Source # minimum :: Ord a0 => These a a0 -> a0 Source # | |
Foldable f => Foldable (ListT f) | |
Defined in Control.Monad.Trans.List Methods fold :: Monoid m => ListT f m -> m Source # foldMap :: Monoid m => (a -> m) -> ListT f a -> m Source # foldMap' :: Monoid m => (a -> m) -> ListT f a -> m Source # foldr :: (a -> b -> b) -> b -> ListT f a -> b Source # foldr' :: (a -> b -> b) -> b -> ListT f a -> b Source # foldl :: (b -> a -> b) -> b -> ListT f a -> b Source # foldl' :: (b -> a -> b) -> b -> ListT f a -> b Source # foldr1 :: (a -> a -> a) -> ListT f a -> a Source # foldl1 :: (a -> a -> a) -> ListT f a -> a Source # toList :: ListT f a -> [a] Source # null :: ListT f a -> Bool Source # length :: ListT f a -> Int Source # elem :: Eq a => a -> ListT f a -> Bool Source # maximum :: Ord a => ListT f a -> a Source # minimum :: Ord a => ListT f a -> a Source # | |
Foldable f => Foldable (MaybeT f) | |
Defined in Control.Monad.Trans.Maybe Methods fold :: Monoid m => MaybeT f m -> m Source # foldMap :: Monoid m => (a -> m) -> MaybeT f a -> m Source # foldMap' :: Monoid m => (a -> m) -> MaybeT f a -> m Source # foldr :: (a -> b -> b) -> b -> MaybeT f a -> b Source # foldr' :: (a -> b -> b) -> b -> MaybeT f a -> b Source # foldl :: (b -> a -> b) -> b -> MaybeT f a -> b Source # foldl' :: (b -> a -> b) -> b -> MaybeT f a -> b Source # foldr1 :: (a -> a -> a) -> MaybeT f a -> a Source # foldl1 :: (a -> a -> a) -> MaybeT f a -> a Source # toList :: MaybeT f a -> [a] Source # null :: MaybeT f a -> Bool Source # length :: MaybeT f a -> Int Source # elem :: Eq a => a -> MaybeT f a -> Bool Source # maximum :: Ord a => MaybeT f a -> a Source # minimum :: Ord a => MaybeT f a -> a Source # | |
Foldable (HashMap k) | |
Defined in Data.HashMap.Internal Methods fold :: Monoid m => HashMap k m -> m Source # foldMap :: Monoid m => (a -> m) -> HashMap k a -> m Source # foldMap' :: Monoid m => (a -> m) -> HashMap k a -> m Source # foldr :: (a -> b -> b) -> b -> HashMap k a -> b Source # foldr' :: (a -> b -> b) -> b -> HashMap k a -> b Source # foldl :: (b -> a -> b) -> b -> HashMap k a -> b Source # foldl' :: (b -> a -> b) -> b -> HashMap k a -> b Source # foldr1 :: (a -> a -> a) -> HashMap k a -> a Source # foldl1 :: (a -> a -> a) -> HashMap k a -> a Source # toList :: HashMap k a -> [a] Source # null :: HashMap k a -> Bool Source # length :: HashMap k a -> Int Source # elem :: Eq a => a -> HashMap k a -> Bool Source # maximum :: Ord a => HashMap k a -> a Source # minimum :: Ord a => HashMap k a -> a Source # | |
Foldable ((,) a) | Since: base-4.7.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => (a, m) -> m Source # foldMap :: Monoid m => (a0 -> m) -> (a, a0) -> m Source # foldMap' :: Monoid m => (a0 -> m) -> (a, a0) -> m Source # foldr :: (a0 -> b -> b) -> b -> (a, a0) -> b Source # foldr' :: (a0 -> b -> b) -> b -> (a, a0) -> b Source # foldl :: (b -> a0 -> b) -> b -> (a, a0) -> b Source # foldl' :: (b -> a0 -> b) -> b -> (a, a0) -> b Source # foldr1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 Source # toList :: (a, a0) -> [a0] Source # null :: (a, a0) -> Bool Source # length :: (a, a0) -> Int Source # elem :: Eq a0 => a0 -> (a, a0) -> Bool Source # maximum :: Ord a0 => (a, a0) -> a0 Source # minimum :: Ord a0 => (a, a0) -> a0 Source # | |
Foldable (Const m :: TYPE LiftedRep -> Type) | Since: base-4.7.0.0 |
Defined in Data.Functor.Const Methods fold :: Monoid m0 => Const m m0 -> m0 Source # foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 Source # foldMap' :: Monoid m0 => (a -> m0) -> Const m a -> m0 Source # foldr :: (a -> b -> b) -> b -> Const m a -> b Source # foldr' :: (a -> b -> b) -> b -> Const m a -> b Source # foldl :: (b -> a -> b) -> b -> Const m a -> b Source # foldl' :: (b -> a -> b) -> b -> Const m a -> b Source # foldr1 :: (a -> a -> a) -> Const m a -> a Source # foldl1 :: (a -> a -> a) -> Const m a -> a Source # toList :: Const m a -> [a] Source # null :: Const m a -> Bool Source # length :: Const m a -> Int Source # elem :: Eq a => a -> Const m a -> Bool Source # maximum :: Ord a => Const m a -> a Source # minimum :: Ord a => Const m a -> a Source # | |
Foldable f => Foldable (Ap f) | Since: base-4.12.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Ap f m -> m Source # foldMap :: Monoid m => (a -> m) -> Ap f a -> m Source # foldMap' :: Monoid m => (a -> m) -> Ap f a -> m Source # foldr :: (a -> b -> b) -> b -> Ap f a -> b Source # foldr' :: (a -> b -> b) -> b -> Ap f a -> b Source # foldl :: (b -> a -> b) -> b -> Ap f a -> b Source # foldl' :: (b -> a -> b) -> b -> Ap f a -> b Source # foldr1 :: (a -> a -> a) -> Ap f a -> a Source # foldl1 :: (a -> a -> a) -> Ap f a -> a Source # toList :: Ap f a -> [a] Source # null :: Ap f a -> Bool Source # length :: Ap f a -> Int Source # elem :: Eq a => a -> Ap f a -> Bool Source # maximum :: Ord a => Ap f a -> a Source # minimum :: Ord a => Ap f a -> a Source # | |
Foldable f => Foldable (Alt f) | Since: base-4.12.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Alt f m -> m Source # foldMap :: Monoid m => (a -> m) -> Alt f a -> m Source # foldMap' :: Monoid m => (a -> m) -> Alt f a -> m Source # foldr :: (a -> b -> b) -> b -> Alt f a -> b Source # foldr' :: (a -> b -> b) -> b -> Alt f a -> b Source # foldl :: (b -> a -> b) -> b -> Alt f a -> b Source # foldl' :: (b -> a -> b) -> b -> Alt f a -> b Source # foldr1 :: (a -> a -> a) -> Alt f a -> a Source # foldl1 :: (a -> a -> a) -> Alt f a -> a Source # toList :: Alt f a -> [a] Source # null :: Alt f a -> Bool Source # length :: Alt f a -> Int Source # elem :: Eq a => a -> Alt f a -> Bool Source # maximum :: Ord a => Alt f a -> a Source # minimum :: Ord a => Alt f a -> a Source # | |
Foldable f => Foldable (Rec1 f) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Rec1 f m -> m Source # foldMap :: Monoid m => (a -> m) -> Rec1 f a -> m Source # foldMap' :: Monoid m => (a -> m) -> Rec1 f a -> m Source # foldr :: (a -> b -> b) -> b -> Rec1 f a -> b Source # foldr' :: (a -> b -> b) -> b -> Rec1 f a -> b Source # foldl :: (b -> a -> b) -> b -> Rec1 f a -> b Source # foldl' :: (b -> a -> b) -> b -> Rec1 f a -> b Source # foldr1 :: (a -> a -> a) -> Rec1 f a -> a Source # foldl1 :: (a -> a -> a) -> Rec1 f a -> a Source # toList :: Rec1 f a -> [a] Source # null :: Rec1 f a -> Bool Source # length :: Rec1 f a -> Int Source # elem :: Eq a => a -> Rec1 f a -> Bool Source # maximum :: Ord a => Rec1 f a -> a Source # minimum :: Ord a => Rec1 f a -> a Source # | |
Bifoldable p => Foldable (Fix p) | |
Defined in Data.Bifunctor.Fix Methods fold :: Monoid m => Fix p m -> m Source # foldMap :: Monoid m => (a -> m) -> Fix p a -> m Source # foldMap' :: Monoid m => (a -> m) -> Fix p a -> m Source # foldr :: (a -> b -> b) -> b -> Fix p a -> b Source # foldr' :: (a -> b -> b) -> b -> Fix p a -> b Source # foldl :: (b -> a -> b) -> b -> Fix p a -> b Source # foldl' :: (b -> a -> b) -> b -> Fix p a -> b Source # foldr1 :: (a -> a -> a) -> Fix p a -> a Source # foldl1 :: (a -> a -> a) -> Fix p a -> a Source # toList :: Fix p a -> [a] Source # null :: Fix p a -> Bool Source # length :: Fix p a -> Int Source # elem :: Eq a => a -> Fix p a -> Bool Source # maximum :: Ord a => Fix p a -> a Source # minimum :: Ord a => Fix p a -> a Source # | |
Bifoldable p => Foldable (Join p) | |
Defined in Data.Bifunctor.Join Methods fold :: Monoid m => Join p m -> m Source # foldMap :: Monoid m => (a -> m) -> Join p a -> m Source # foldMap' :: Monoid m => (a -> m) -> Join p a -> m Source # foldr :: (a -> b -> b) -> b -> Join p a -> b Source # foldr' :: (a -> b -> b) -> b -> Join p a -> b Source # foldl :: (b -> a -> b) -> b -> Join p a -> b Source # foldl' :: (b -> a -> b) -> b -> Join p a -> b Source # foldr1 :: (a -> a -> a) -> Join p a -> a Source # foldl1 :: (a -> a -> a) -> Join p a -> a Source # toList :: Join p a -> [a] Source # null :: Join p a -> Bool Source # length :: Join p a -> Int Source # elem :: Eq a => a -> Join p a -> Bool Source # maximum :: Ord a => Join p a -> a Source # minimum :: Ord a => Join p a -> a Source # | |
Foldable f => Foldable (CofreeF f a) | |
Defined in Control.Comonad.Trans.Cofree Methods fold :: Monoid m => CofreeF f a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> CofreeF f a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> CofreeF f a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> CofreeF f a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> CofreeF f a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> CofreeF f a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> CofreeF f a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> CofreeF f a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> CofreeF f a a0 -> a0 Source # toList :: CofreeF f a a0 -> [a0] Source # null :: CofreeF f a a0 -> Bool Source # length :: CofreeF f a a0 -> Int Source # elem :: Eq a0 => a0 -> CofreeF f a a0 -> Bool Source # maximum :: Ord a0 => CofreeF f a a0 -> a0 Source # minimum :: Ord a0 => CofreeF f a a0 -> a0 Source # | |
(Foldable f, Foldable w) => Foldable (CofreeT f w) | |
Defined in Control.Comonad.Trans.Cofree Methods fold :: Monoid m => CofreeT f w m -> m Source # foldMap :: Monoid m => (a -> m) -> CofreeT f w a -> m Source # foldMap' :: Monoid m => (a -> m) -> CofreeT f w a -> m Source # foldr :: (a -> b -> b) -> b -> CofreeT f w a -> b Source # foldr' :: (a -> b -> b) -> b -> CofreeT f w a -> b Source # foldl :: (b -> a -> b) -> b -> CofreeT f w a -> b Source # foldl' :: (b -> a -> b) -> b -> CofreeT f w a -> b Source # foldr1 :: (a -> a -> a) -> CofreeT f w a -> a Source # foldl1 :: (a -> a -> a) -> CofreeT f w a -> a Source # toList :: CofreeT f w a -> [a] Source # null :: CofreeT f w a -> Bool Source # length :: CofreeT f w a -> Int Source # elem :: Eq a => a -> CofreeT f w a -> Bool Source # maximum :: Ord a => CofreeT f w a -> a Source # minimum :: Ord a => CofreeT f w a -> a Source # | |
Foldable f => Foldable (FreeF f a) | |
Defined in Control.Monad.Trans.Free Methods fold :: Monoid m => FreeF f a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> FreeF f a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> FreeF f a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> FreeF f a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> FreeF f a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> FreeF f a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> FreeF f a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> FreeF f a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> FreeF f a a0 -> a0 Source # toList :: FreeF f a a0 -> [a0] Source # null :: FreeF f a a0 -> Bool Source # length :: FreeF f a a0 -> Int Source # elem :: Eq a0 => a0 -> FreeF f a a0 -> Bool Source # maximum :: Ord a0 => FreeF f a a0 -> a0 Source # minimum :: Ord a0 => FreeF f a a0 -> a0 Source # | |
(Foldable m, Foldable f) => Foldable (FreeT f m) | |
Defined in Control.Monad.Trans.Free Methods fold :: Monoid m0 => FreeT f m m0 -> m0 Source # foldMap :: Monoid m0 => (a -> m0) -> FreeT f m a -> m0 Source # foldMap' :: Monoid m0 => (a -> m0) -> FreeT f m a -> m0 Source # foldr :: (a -> b -> b) -> b -> FreeT f m a -> b Source # foldr' :: (a -> b -> b) -> b -> FreeT f m a -> b Source # foldl :: (b -> a -> b) -> b -> FreeT f m a -> b Source # foldl' :: (b -> a -> b) -> b -> FreeT f m a -> b Source # foldr1 :: (a -> a -> a) -> FreeT f m a -> a Source # foldl1 :: (a -> a -> a) -> FreeT f m a -> a Source # toList :: FreeT f m a -> [a] Source # null :: FreeT f m a -> Bool Source # length :: FreeT f m a -> Int Source # elem :: Eq a => a -> FreeT f m a -> Bool Source # maximum :: Ord a => FreeT f m a -> a Source # minimum :: Ord a => FreeT f m a -> a Source # | |
Foldable (Tagged s) | |
Defined in Data.Tagged Methods fold :: Monoid m => Tagged s m -> m Source # foldMap :: Monoid m => (a -> m) -> Tagged s a -> m Source # foldMap' :: Monoid m => (a -> m) -> Tagged s a -> m Source # foldr :: (a -> b -> b) -> b -> Tagged s a -> b Source # foldr' :: (a -> b -> b) -> b -> Tagged s a -> b Source # foldl :: (b -> a -> b) -> b -> Tagged s a -> b Source # foldl' :: (b -> a -> b) -> b -> Tagged s a -> b Source # foldr1 :: (a -> a -> a) -> Tagged s a -> a Source # foldl1 :: (a -> a -> a) -> Tagged s a -> a Source # toList :: Tagged s a -> [a] Source # null :: Tagged s a -> Bool Source # length :: Tagged s a -> Int Source # elem :: Eq a => a -> Tagged s a -> Bool Source # maximum :: Ord a => Tagged s a -> a Source # minimum :: Ord a => Tagged s a -> a Source # | |
(Foldable f, Foldable g) => Foldable (These1 f g) | |
Defined in Data.Functor.These Methods fold :: Monoid m => These1 f g m -> m Source # foldMap :: Monoid m => (a -> m) -> These1 f g a -> m Source # foldMap' :: Monoid m => (a -> m) -> These1 f g a -> m Source # foldr :: (a -> b -> b) -> b -> These1 f g a -> b Source # foldr' :: (a -> b -> b) -> b -> These1 f g a -> b Source # foldl :: (b -> a -> b) -> b -> These1 f g a -> b Source # foldl' :: (b -> a -> b) -> b -> These1 f g a -> b Source # foldr1 :: (a -> a -> a) -> These1 f g a -> a Source # foldl1 :: (a -> a -> a) -> These1 f g a -> a Source # toList :: These1 f g a -> [a] Source # null :: These1 f g a -> Bool Source # length :: These1 f g a -> Int Source # elem :: Eq a => a -> These1 f g a -> Bool Source # maximum :: Ord a => These1 f g a -> a Source # minimum :: Ord a => These1 f g a -> a Source # | |
Foldable f => Foldable (ErrorT e f) | |
Defined in Control.Monad.Trans.Error Methods fold :: Monoid m => ErrorT e f m -> m Source # foldMap :: Monoid m => (a -> m) -> ErrorT e f a -> m Source # foldMap' :: Monoid m => (a -> m) -> ErrorT e f a -> m Source # foldr :: (a -> b -> b) -> b -> ErrorT e f a -> b Source # foldr' :: (a -> b -> b) -> b -> ErrorT e f a -> b Source # foldl :: (b -> a -> b) -> b -> ErrorT e f a -> b Source # foldl' :: (b -> a -> b) -> b -> ErrorT e f a -> b Source # foldr1 :: (a -> a -> a) -> ErrorT e f a -> a Source # foldl1 :: (a -> a -> a) -> ErrorT e f a -> a Source # toList :: ErrorT e f a -> [a] Source # null :: ErrorT e f a -> Bool Source # length :: ErrorT e f a -> Int Source # elem :: Eq a => a -> ErrorT e f a -> Bool Source # maximum :: Ord a => ErrorT e f a -> a Source # minimum :: Ord a => ErrorT e f a -> a Source # | |
Foldable f => Foldable (ExceptT e f) | |
Defined in Control.Monad.Trans.Except Methods fold :: Monoid m => ExceptT e f m -> m Source # foldMap :: Monoid m => (a -> m) -> ExceptT e f a -> m Source # foldMap' :: Monoid m => (a -> m) -> ExceptT e f a -> m Source # foldr :: (a -> b -> b) -> b -> ExceptT e f a -> b Source # foldr' :: (a -> b -> b) -> b -> ExceptT e f a -> b Source # foldl :: (b -> a -> b) -> b -> ExceptT e f a -> b Source # foldl' :: (b -> a -> b) -> b -> ExceptT e f a -> b Source # foldr1 :: (a -> a -> a) -> ExceptT e f a -> a Source # foldl1 :: (a -> a -> a) -> ExceptT e f a -> a Source # toList :: ExceptT e f a -> [a] Source # null :: ExceptT e f a -> Bool Source # length :: ExceptT e f a -> Int Source # elem :: Eq a => a -> ExceptT e f a -> Bool Source # maximum :: Ord a => ExceptT e f a -> a Source # minimum :: Ord a => ExceptT e f a -> a Source # | |
Foldable f => Foldable (IdentityT f) | |
Defined in Control.Monad.Trans.Identity Methods fold :: Monoid m => IdentityT f m -> m Source # foldMap :: Monoid m => (a -> m) -> IdentityT f a -> m Source # foldMap' :: Monoid m => (a -> m) -> IdentityT f a -> m Source # foldr :: (a -> b -> b) -> b -> IdentityT f a -> b Source # foldr' :: (a -> b -> b) -> b -> IdentityT f a -> b Source # foldl :: (b -> a -> b) -> b -> IdentityT f a -> b Source # foldl' :: (b -> a -> b) -> b -> IdentityT f a -> b Source # foldr1 :: (a -> a -> a) -> IdentityT f a -> a Source # foldl1 :: (a -> a -> a) -> IdentityT f a -> a Source # toList :: IdentityT f a -> [a] Source # null :: IdentityT f a -> Bool Source # length :: IdentityT f a -> Int Source # elem :: Eq a => a -> IdentityT f a -> Bool Source # maximum :: Ord a => IdentityT f a -> a Source # minimum :: Ord a => IdentityT f a -> a Source # | |
Foldable f => Foldable (WriterT w f) | |
Defined in Control.Monad.Trans.Writer.Lazy Methods fold :: Monoid m => WriterT w f m -> m Source # foldMap :: Monoid m => (a -> m) -> WriterT w f a -> m Source # foldMap' :: Monoid m => (a -> m) -> WriterT w f a -> m Source # foldr :: (a -> b -> b) -> b -> WriterT w f a -> b Source # foldr' :: (a -> b -> b) -> b -> WriterT w f a -> b Source # foldl :: (b -> a -> b) -> b -> WriterT w f a -> b Source # foldl' :: (b -> a -> b) -> b -> WriterT w f a -> b Source # foldr1 :: (a -> a -> a) -> WriterT w f a -> a Source # foldl1 :: (a -> a -> a) -> WriterT w f a -> a Source # toList :: WriterT w f a -> [a] Source # null :: WriterT w f a -> Bool Source # length :: WriterT w f a -> Int Source # elem :: Eq a => a -> WriterT w f a -> Bool Source # maximum :: Ord a => WriterT w f a -> a Source # minimum :: Ord a => WriterT w f a -> a Source # | |
Foldable f => Foldable (WriterT w f) | |
Defined in Control.Monad.Trans.Writer.Strict Methods fold :: Monoid m => WriterT w f m -> m Source # foldMap :: Monoid m => (a -> m) -> WriterT w f a -> m Source # foldMap' :: Monoid m => (a -> m) -> WriterT w f a -> m Source # foldr :: (a -> b -> b) -> b -> WriterT w f a -> b Source # foldr' :: (a -> b -> b) -> b -> WriterT w f a -> b Source # foldl :: (b -> a -> b) -> b -> WriterT w f a -> b Source # foldl' :: (b -> a -> b) -> b -> WriterT w f a -> b Source # foldr1 :: (a -> a -> a) -> WriterT w f a -> a Source # foldl1 :: (a -> a -> a) -> WriterT w f a -> a Source # toList :: WriterT w f a -> [a] Source # null :: WriterT w f a -> Bool Source # length :: WriterT w f a -> Int Source # elem :: Eq a => a -> WriterT w f a -> Bool Source # maximum :: Ord a => WriterT w f a -> a Source # minimum :: Ord a => WriterT w f a -> a Source # | |
(Foldable f, Foldable g) => Foldable (f :*: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => (f :*: g) m -> m Source # foldMap :: Monoid m => (a -> m) -> (f :*: g) a -> m Source # foldMap' :: Monoid m => (a -> m) -> (f :*: g) a -> m Source # foldr :: (a -> b -> b) -> b -> (f :*: g) a -> b Source # foldr' :: (a -> b -> b) -> b -> (f :*: g) a -> b Source # foldl :: (b -> a -> b) -> b -> (f :*: g) a -> b Source # foldl' :: (b -> a -> b) -> b -> (f :*: g) a -> b Source # foldr1 :: (a -> a -> a) -> (f :*: g) a -> a Source # foldl1 :: (a -> a -> a) -> (f :*: g) a -> a Source # toList :: (f :*: g) a -> [a] Source # null :: (f :*: g) a -> Bool Source # length :: (f :*: g) a -> Int Source # elem :: Eq a => a -> (f :*: g) a -> Bool Source # maximum :: Ord a => (f :*: g) a -> a Source # minimum :: Ord a => (f :*: g) a -> a Source # | |
(Foldable f, Foldable g) => Foldable (f :+: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => (f :+: g) m -> m Source # foldMap :: Monoid m => (a -> m) -> (f :+: g) a -> m Source # foldMap' :: Monoid m => (a -> m) -> (f :+: g) a -> m Source # foldr :: (a -> b -> b) -> b -> (f :+: g) a -> b Source # foldr' :: (a -> b -> b) -> b -> (f :+: g) a -> b Source # foldl :: (b -> a -> b) -> b -> (f :+: g) a -> b Source # foldl' :: (b -> a -> b) -> b -> (f :+: g) a -> b Source # foldr1 :: (a -> a -> a) -> (f :+: g) a -> a Source # foldl1 :: (a -> a -> a) -> (f :+: g) a -> a Source # toList :: (f :+: g) a -> [a] Source # null :: (f :+: g) a -> Bool Source # length :: (f :+: g) a -> Int Source # elem :: Eq a => a -> (f :+: g) a -> Bool Source # maximum :: Ord a => (f :+: g) a -> a Source # minimum :: Ord a => (f :+: g) a -> a Source # | |
Foldable (K1 i c :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => K1 i c m -> m Source # foldMap :: Monoid m => (a -> m) -> K1 i c a -> m Source # foldMap' :: Monoid m => (a -> m) -> K1 i c a -> m Source # foldr :: (a -> b -> b) -> b -> K1 i c a -> b Source # foldr' :: (a -> b -> b) -> b -> K1 i c a -> b Source # foldl :: (b -> a -> b) -> b -> K1 i c a -> b Source # foldl' :: (b -> a -> b) -> b -> K1 i c a -> b Source # foldr1 :: (a -> a -> a) -> K1 i c a -> a Source # foldl1 :: (a -> a -> a) -> K1 i c a -> a Source # toList :: K1 i c a -> [a] Source # null :: K1 i c a -> Bool Source # length :: K1 i c a -> Int Source # elem :: Eq a => a -> K1 i c a -> Bool Source # maximum :: Ord a => K1 i c a -> a Source # minimum :: Ord a => K1 i c a -> a Source # | |
(Foldable f, Foldable g) => Foldable (f :.: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => (f :.: g) m -> m Source # foldMap :: Monoid m => (a -> m) -> (f :.: g) a -> m Source # foldMap' :: Monoid m => (a -> m) -> (f :.: g) a -> m Source # foldr :: (a -> b -> b) -> b -> (f :.: g) a -> b Source # foldr' :: (a -> b -> b) -> b -> (f :.: g) a -> b Source # foldl :: (b -> a -> b) -> b -> (f :.: g) a -> b Source # foldl' :: (b -> a -> b) -> b -> (f :.: g) a -> b Source # foldr1 :: (a -> a -> a) -> (f :.: g) a -> a Source # foldl1 :: (a -> a -> a) -> (f :.: g) a -> a Source # toList :: (f :.: g) a -> [a] Source # null :: (f :.: g) a -> Bool Source # length :: (f :.: g) a -> Int Source # elem :: Eq a => a -> (f :.: g) a -> Bool Source # maximum :: Ord a => (f :.: g) a -> a Source # minimum :: Ord a => (f :.: g) a -> a Source # | |
Foldable f => Foldable (M1 i c f) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => M1 i c f m -> m Source # foldMap :: Monoid m => (a -> m) -> M1 i c f a -> m Source # foldMap' :: Monoid m => (a -> m) -> M1 i c f a -> m Source # foldr :: (a -> b -> b) -> b -> M1 i c f a -> b Source # foldr' :: (a -> b -> b) -> b -> M1 i c f a -> b Source # foldl :: (b -> a -> b) -> b -> M1 i c f a -> b Source # foldl' :: (b -> a -> b) -> b -> M1 i c f a -> b Source # foldr1 :: (a -> a -> a) -> M1 i c f a -> a Source # foldl1 :: (a -> a -> a) -> M1 i c f a -> a Source # toList :: M1 i c f a -> [a] Source # null :: M1 i c f a -> Bool Source # length :: M1 i c f a -> Int Source # elem :: Eq a => a -> M1 i c f a -> Bool Source # maximum :: Ord a => M1 i c f a -> a Source # minimum :: Ord a => M1 i c f a -> a Source # | |
Foldable (Clown f a :: TYPE LiftedRep -> Type) | |
Defined in Data.Bifunctor.Clown Methods fold :: Monoid m => Clown f a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> Clown f a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> Clown f a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> Clown f a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> Clown f a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> Clown f a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> Clown f a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> Clown f a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> Clown f a a0 -> a0 Source # toList :: Clown f a a0 -> [a0] Source # null :: Clown f a a0 -> Bool Source # length :: Clown f a a0 -> Int Source # elem :: Eq a0 => a0 -> Clown f a a0 -> Bool Source # maximum :: Ord a0 => Clown f a a0 -> a0 Source # minimum :: Ord a0 => Clown f a a0 -> a0 Source # | |
Bifoldable p => Foldable (Flip p a) | |
Defined in Data.Bifunctor.Flip Methods fold :: Monoid m => Flip p a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> Flip p a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> Flip p a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> Flip p a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> Flip p a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> Flip p a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> Flip p a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> Flip p a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> Flip p a a0 -> a0 Source # toList :: Flip p a a0 -> [a0] Source # null :: Flip p a a0 -> Bool Source # length :: Flip p a a0 -> Int Source # elem :: Eq a0 => a0 -> Flip p a a0 -> Bool Source # maximum :: Ord a0 => Flip p a a0 -> a0 Source # minimum :: Ord a0 => Flip p a a0 -> a0 Source # | |
Foldable g => Foldable (Joker g a) | |
Defined in Data.Bifunctor.Joker Methods fold :: Monoid m => Joker g a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> Joker g a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> Joker g a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> Joker g a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> Joker g a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> Joker g a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> Joker g a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> Joker g a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> Joker g a a0 -> a0 Source # toList :: Joker g a a0 -> [a0] Source # null :: Joker g a a0 -> Bool Source # length :: Joker g a a0 -> Int Source # elem :: Eq a0 => a0 -> Joker g a a0 -> Bool Source # maximum :: Ord a0 => Joker g a a0 -> a0 Source # minimum :: Ord a0 => Joker g a a0 -> a0 Source # | |
Bifoldable p => Foldable (WrappedBifunctor p a) | |
Defined in Data.Bifunctor.Wrapped Methods fold :: Monoid m => WrappedBifunctor p a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> WrappedBifunctor p a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> WrappedBifunctor p a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> WrappedBifunctor p a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> WrappedBifunctor p a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> WrappedBifunctor p a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> WrappedBifunctor p a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> WrappedBifunctor p a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> WrappedBifunctor p a a0 -> a0 Source # toList :: WrappedBifunctor p a a0 -> [a0] Source # null :: WrappedBifunctor p a a0 -> Bool Source # length :: WrappedBifunctor p a a0 -> Int Source # elem :: Eq a0 => a0 -> WrappedBifunctor p a a0 -> Bool Source # maximum :: Ord a0 => WrappedBifunctor p a a0 -> a0 Source # minimum :: Ord a0 => WrappedBifunctor p a a0 -> a0 Source # sum :: Num a0 => WrappedBifunctor p a a0 -> a0 Source # product :: Num a0 => WrappedBifunctor p a a0 -> a0 Source # | |
(Foldable f, Bifoldable p) => Foldable (Tannen f p a) | |
Defined in Data.Bifunctor.Tannen Methods fold :: Monoid m => Tannen f p a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> Tannen f p a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> Tannen f p a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> Tannen f p a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> Tannen f p a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> Tannen f p a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> Tannen f p a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> Tannen f p a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> Tannen f p a a0 -> a0 Source # toList :: Tannen f p a a0 -> [a0] Source # null :: Tannen f p a a0 -> Bool Source # length :: Tannen f p a a0 -> Int Source # elem :: Eq a0 => a0 -> Tannen f p a a0 -> Bool Source # maximum :: Ord a0 => Tannen f p a a0 -> a0 Source # minimum :: Ord a0 => Tannen f p a a0 -> a0 Source # | |
(Bifoldable p, Foldable g) => Foldable (Biff p f g a) | |
Defined in Data.Bifunctor.Biff Methods fold :: Monoid m => Biff p f g a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> Biff p f g a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> Biff p f g a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> Biff p f g a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> Biff p f g a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> Biff p f g a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> Biff p f g a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> Biff p f g a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> Biff p f g a a0 -> a0 Source # toList :: Biff p f g a a0 -> [a0] Source # null :: Biff p f g a a0 -> Bool Source # length :: Biff p f g a a0 -> Int Source # elem :: Eq a0 => a0 -> Biff p f g a a0 -> Bool Source # maximum :: Ord a0 => Biff p f g a a0 -> a0 Source # minimum :: Ord a0 => Biff p f g a a0 -> a0 Source # |
class (Functor t, Foldable t) => Traversable (t :: Type -> Type) where Source #
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.
Methods
traverse :: Applicative f => (a -> f b) -> t a -> f (t b) Source #
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) Source #
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) Source #
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) Source #
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
Instances
Representable types of kind *
.
This class is derivable in GHC with the DeriveGeneric
flag on.
A Generic
instance must satisfy the following laws:
from
.to
≡id
to
.from
≡id
Instances
class Semigroup a where Source #
The class of semigroups (types with an associative binary operation).
Instances should satisfy the following:
Since: base-4.9.0.0
Minimal complete definition
Methods
(<>) :: a -> a -> a infixr 6 Source #
An associative operation.
>>>
[1,2,3] <> [4,5,6]
[1,2,3,4,5,6]
sconcat :: NonEmpty a -> a Source #
Reduce a non-empty list with <>
The default definition should be sufficient, but this can be overridden for efficiency.
>>>
import Data.List.NonEmpty (NonEmpty (..))
>>>
sconcat $ "Hello" :| [" ", "Haskell", "!"]
"Hello Haskell!"
stimes :: Integral b => b -> a -> a Source #
Repeat a value n
times.
Given that this works on a Semigroup
it is allowed to fail if
you request 0 or fewer repetitions, and the default definition
will do so.
By making this a member of the class, idempotent semigroups
and monoids can upgrade this to execute in \(\mathcal{O}(1)\) by
picking stimes =
or stimesIdempotent
stimes =
respectively.stimesIdempotentMonoid
>>>
stimes 4 [1]
[1,1,1,1]
Instances
class Semigroup a => Monoid a where Source #
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following:
- Right identity
x
<>
mempty
= x- Left identity
mempty
<>
x = x- Associativity
x
(<>
(y<>
z) = (x<>
y)<>
zSemigroup
law)- Concatenation
mconcat
=foldr
(<>
)mempty
The method names refer to the monoid of lists under concatenation, but there are many other instances.
Some types can be viewed as a monoid in more than one way,
e.g. both addition and multiplication on numbers.
In such cases we often define newtype
s and make those instances
of Monoid
, e.g. Sum
and Product
.
NOTE: Semigroup
is a superclass of Monoid
since base-4.11.0.0.
Minimal complete definition
Methods
Identity of mappend
>>>
"Hello world" <> mempty
"Hello world"
mappend :: a -> a -> a Source #
An associative operation
NOTE: This method is redundant and has the default
implementation
since base-4.11.0.0.
Should it be implemented manually, since mappend
= (<>
)mappend
is a synonym for
(<>
), it is expected that the two functions are defined the same
way. In a future GHC release mappend
will be removed from Monoid
.
Fold a list using the monoid.
For most types, the default definition for mconcat
will be
used, but the function is included in the class definition so
that an optimized version can be provided for specific types.
>>>
mconcat ["Hello", " ", "Haskell", "!"]
"Hello Haskell!"
Instances
Monoid Key | |
Monoid Doc | |
Monoid More | |
Monoid Builder | |
Monoid ByteString | |
Defined in Data.ByteString.Internal Methods mempty :: ByteString Source # mappend :: ByteString -> ByteString -> ByteString Source # mconcat :: [ByteString] -> ByteString Source # | |
Monoid ByteString | |
Defined in Data.ByteString.Lazy.Internal Methods mempty :: ByteString Source # mappend :: ByteString -> ByteString -> ByteString Source # mconcat :: [ByteString] -> ByteString Source # | |
Monoid ShortByteString | |
Defined in Data.ByteString.Short.Internal Methods mempty :: ShortByteString Source # mappend :: ShortByteString -> ShortByteString -> ShortByteString Source # mconcat :: [ShortByteString] -> ShortByteString Source # | |
Monoid LogStr | |
Monoid Ordering | Since: base-2.1 |
Monoid Namespace | |
Monoid PrefsMod | |
Monoid Completer | |
Monoid ParseError | |
Defined in Options.Applicative.Types Methods mempty :: ParseError Source # mappend :: ParseError -> ParseError -> ParseError Source # mconcat :: [ParseError] -> ParseError Source # | |
Monoid PackageVersion | Since: package-version-0.1.0.0 |
Defined in Data.Version.Package.Internal Methods mempty :: PackageVersion Source # mappend :: PackageVersion -> PackageVersion -> PackageVersion Source # mconcat :: [PackageVersion] -> PackageVersion Source # | |
Monoid Doc | |
Monoid ByteArray | |
Monoid BatteryApp | |
Monoid GlobalIpApp | |
Monoid MemoryApp | |
Monoid NetInterfaceApp | |
Monoid ShortText | |
Monoid TimeFormat | |
Monoid () | Since: base-2.1 |
Monoid (KeyMap v) | |
Monoid (IResult a) | |
Monoid (Parser a) | |
Monoid (Result a) | |
(Semigroup a, Monoid a) => Monoid (Concurrently a) | Since: async-2.1.0 |
Defined in Control.Concurrent.Async Methods mempty :: Concurrently a Source # mappend :: Concurrently a -> Concurrently a -> Concurrently a Source # mconcat :: [Concurrently a] -> Concurrently a Source # | |
FiniteBits a => Monoid (And a) | This constraint is arguably too strong. However,
as some types (such as Since: base-4.16 |
FiniteBits a => Monoid (Iff a) | This constraint is arguably
too strong. However, as some types (such as Since: base-4.16 |
Bits a => Monoid (Ior a) | Since: base-4.16 |
Bits a => Monoid (Xor a) | Since: base-4.16 |
Monoid a => Monoid (Identity a) | Since: base-4.9.0.0 |
Monoid (First a) | Since: base-2.1 |
Monoid (Last a) | Since: base-2.1 |
Monoid a => Monoid (Down a) | Since: base-4.11.0.0 |
(Ord a, Bounded a) => Monoid (Max a) | Since: base-4.9.0.0 |
(Ord a, Bounded a) => Monoid (Min a) | Since: base-4.9.0.0 |
Monoid m => Monoid (WrappedMonoid m) | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methods mempty :: WrappedMonoid m Source # mappend :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m Source # mconcat :: [WrappedMonoid m] -> WrappedMonoid m Source # | |
Monoid p => Monoid (Par1 p) | Since: base-4.12.0.0 |
Monoid (Seq a) | |
Monoid (MergeSet a) | |
Ord a => Monoid (Set a) | |
Monoid (DList a) | |
Monoid a => Monoid (IO a) | Since: base-4.9.0.0 |
Monoid (InfoMod a) | |
Monoid (DefaultProp a) | |
Defined in Options.Applicative.Builder.Internal Methods mempty :: DefaultProp a Source # mappend :: DefaultProp a -> DefaultProp a -> DefaultProp a Source # mconcat :: [DefaultProp a] -> DefaultProp a Source # | |
Semigroup a => Monoid (Chunk a) | |
Monoid (Doc a) | |
Monoid (Doc ann) |
|
Monoid (Array a) | |
Monoid (PrimArray a) | Since: primitive-0.6.4.0 |
Monoid (SmallArray a) | |
Defined in Data.Primitive.SmallArray Methods mempty :: SmallArray a Source # mappend :: SmallArray a -> SmallArray a -> SmallArray a Source # mconcat :: [SmallArray a] -> SmallArray a Source # | |
(Bounded a, Ord a) => Monoid (Supremum a) | |
Monoid (ActionsResult r) | |
Monoid a => Monoid (GlobalIpConfig a) | |
Monoid (IpAddresses a) | |
Semigroup a => Monoid (Maybe a) | |
Monoid a => Monoid (Q a) | Since: template-haskell-2.17.0.0 |
(Hashable a, Eq a) => Monoid (HashSet a) | O(n+m) To obtain good performance, the smaller set must be presented as the first argument. Examples
|
Monoid (Vector a) | |
Prim a => Monoid (Vector a) | |
Storable a => Monoid (Vector a) | |
Semigroup a => Monoid (Maybe a) | Lift a semigroup into Since 4.11.0: constraint on inner Since: base-2.1 |
Monoid a => Monoid (a) | Since: base-4.15 |
Monoid [a] | Since: base-2.1 |
Monoid (Parser i a) | |
Monoid (Proxy s) | Since: base-4.7.0.0 |
Monoid (U1 p) | Since: base-4.12.0.0 |
Monoid a => Monoid (ST s a) | Since: base-4.11.0.0 |
Ord k => Monoid (Map k v) | |
Monoid (f a) => Monoid (Indexing f a) |
|
Monoid (ReifiedFold s a) | |
Defined in Control.Lens.Reified Methods mempty :: ReifiedFold s a Source # mappend :: ReifiedFold s a -> ReifiedFold s a -> ReifiedFold s a Source # mconcat :: [ReifiedFold s a] -> ReifiedFold s a Source # | |
(Stream s, Ord e) => Monoid (ParseError s e) | |
Defined in Text.Megaparsec.Error Methods mempty :: ParseError s e Source # mappend :: ParseError s e -> ParseError s e -> ParseError s e Source # mconcat :: [ParseError s e] -> ParseError s e Source # | |
(MonadAsync m, Monoid a) => Monoid (Concurrently m a) | |
(Applicative m, Monoid a) => Monoid (LoggingT m a) | |
(Applicative m, Monoid a) => Monoid (NoLoggingT m a) | |
Defined in Control.Monad.Logger Methods mempty :: NoLoggingT m a Source # mappend :: NoLoggingT m a -> NoLoggingT m a -> NoLoggingT m a Source # mconcat :: [NoLoggingT m a] -> NoLoggingT m a Source # | |
(Applicative m, Monoid a) => Monoid (WriterLoggingT m a) | |
Defined in Control.Monad.Logger Methods mempty :: WriterLoggingT m a Source # mappend :: WriterLoggingT m a -> WriterLoggingT m a -> WriterLoggingT m a Source # mconcat :: [WriterLoggingT m a] -> WriterLoggingT m a Source # | |
Monoid (Mod f a) | |
(Monoid a, Monoid b) => Monoid (Pair a b) | |
(Eq k, Hashable k) => Monoid (HashMap k v) | If a key occurs in both maps, the mapping from the first will be the mapping in the result. Examples
|
Monoid b => Monoid (a -> b) | Since: base-2.1 |
(Monoid a, Monoid b) => Monoid (a, b) | Since: base-2.1 |
Monoid a => Monoid (Const a b) | Since: base-4.9.0.0 |
(Applicative f, Monoid a) => Monoid (Ap f a) | Since: base-4.12.0.0 |
Monoid (f p) => Monoid (Rec1 f p) | Since: base-4.12.0.0 |
Monoid (ReifiedIndexedFold i s a) | |
Defined in Control.Lens.Reified Methods mempty :: ReifiedIndexedFold i s a Source # mappend :: ReifiedIndexedFold i s a -> ReifiedIndexedFold i s a -> ReifiedIndexedFold i s a Source # mconcat :: [ReifiedIndexedFold i s a] -> ReifiedIndexedFold i s a Source # | |
Reifies s (ReifiedMonoid a) => Monoid (ReflectedMonoid a s) | |
Defined in Data.Reflection Methods mempty :: ReflectedMonoid a s Source # mappend :: ReflectedMonoid a s -> ReflectedMonoid a s -> ReflectedMonoid a s Source # mconcat :: [ReflectedMonoid a s] -> ReflectedMonoid a s Source # | |
(Semigroup a, Monoid a) => Monoid (Tagged s a) | |
(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) | Since: base-2.1 |
(Monoid (f p), Monoid (g p)) => Monoid ((f :*: g) p) | Since: base-4.12.0.0 |
Monoid c => Monoid (K1 i c p) | Since: base-4.12.0.0 |
Monad m => Monoid (ConduitT i o m ()) | |
(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) | Since: base-2.1 |
Monoid (f (g p)) => Monoid ((f :.: g) p) | Since: base-4.12.0.0 |
Monoid (f p) => Monoid (M1 i c f p) | Since: base-4.12.0.0 |
(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) | Since: base-2.1 |
Monad m => Monoid (Pipe l i o u m ()) | |
Instances
The character type Char
is an enumeration whose values represent
Unicode (or equivalently ISO/IEC 10646) code points (i.e. characters, see
http://www.unicode.org/ for details). This set extends the ISO 8859-1
(Latin-1) character set (the first 256 characters), which is itself an extension
of the ASCII character set (the first 128 characters). A character literal in
Haskell has type Char
.
To convert a Char
to or from the corresponding Int
value defined
by Unicode, use toEnum
and fromEnum
from the
Enum
class respectively (or equivalently ord
and
chr
).
Instances
A fixed-precision integer type with at least the range [-2^29 .. 2^29-1]
.
The exact range for a given implementation can be determined by using
minBound
and maxBound
from the Bounded
class.
Instances
32-bit signed integer type
Instances
Arbitrary precision integers. In contrast with fixed-size integral types
such as Int
, the Integer
type represents the entire infinite range of
integers.
Integers are stored in a kind of sign-magnitude form, hence do not expect two's complement form when using bit operations.
If the value is small (fit into an Int
), IS
constructor is used.
Otherwise Integer
and IN
constructors are used to store a BigNat
representing respectively the positive or the negative value magnitude.
Invariant: Integer
and IN
are used iff value doesn't fit in IS
Instances
Natural number
Invariant: numbers <= 0xffffffffffffffff use the NS
constructor
Instances
The Maybe
type encapsulates an optional value. A value of type
either contains a value of type Maybe
aa
(represented as
),
or it is empty (represented as Just
aNothing
). Using Maybe
is a good way to
deal with errors or exceptional cases without resorting to drastic
measures such as error
.
The Maybe
type is also a monad. It is a simple kind of error
monad, where all errors are represented by Nothing
. A richer
error monad can be built using the Either
type.
Instances
MonadFail Maybe | Since: base-4.9.0.0 |
Foldable Maybe | Since: base-2.1 |
Defined in Data.Foldable Methods fold :: Monoid m => Maybe m -> m Source # foldMap :: Monoid m => (a -> m) -> Maybe a -> m Source # foldMap' :: Monoid m => (a -> m) -> Maybe a -> m Source # foldr :: (a -> b -> b) -> b -> Maybe a -> b Source # foldr' :: (a -> b -> b) -> b -> Maybe a -> b Source # foldl :: (b -> a -> b) -> b -> Maybe a -> b Source # foldl' :: (b -> a -> b) -> b -> Maybe a -> b Source # foldr1 :: (a -> a -> a) -> Maybe a -> a Source # foldl1 :: (a -> a -> a) -> Maybe a -> a Source # toList :: Maybe a -> [a] Source # null :: Maybe a -> Bool Source # length :: Maybe a -> Int Source # elem :: Eq a => a -> Maybe a -> Bool Source # maximum :: Ord a => Maybe a -> a Source # minimum :: Ord a => Maybe a -> a Source # | |
Eq1 Maybe | Since: base-4.9.0.0 |
Ord1 Maybe | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Read1 Maybe | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Maybe a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Maybe a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Maybe a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Maybe a] Source # | |
Show1 Maybe | Since: base-4.9.0.0 |
Traversable Maybe | Since: base-2.1 |
Alternative Maybe | Since: base-2.1 |
Applicative Maybe | Since: base-2.1 |
Functor Maybe | Since: base-2.1 |
Monad Maybe | Since: base-2.1 |
MonadPlus Maybe | Since: base-2.1 |
NFData1 Maybe | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
MonadThrow Maybe | |
Hashable1 Maybe | |
Defined in Data.Hashable.Class | |
Generic1 Maybe | |
MonadBaseControl Maybe Maybe | |
Lift a => Lift (Maybe a :: Type) | |
Pretty a => Pretty (Maybe a) | |
Semigroup a => Monoid (Maybe a) | Lift a semigroup into Since 4.11.0: constraint on inner Since: base-2.1 |
Semigroup a => Semigroup (Maybe a) | Since: base-4.9.0.0 |
Generic (Maybe a) | |
SingKind a => SingKind (Maybe a) | Since: base-4.9.0.0 |
Defined in GHC.Generics Associated Types type DemoteRep (Maybe a) | |
Show a => Show (Maybe a) | Since: base-2.1 |
NFData a => NFData (Maybe a) | |
Defined in Control.DeepSeq | |
Eq a => Eq (Maybe a) | Since: base-2.1 |
Ord a => Ord (Maybe a) | Since: base-2.1 |
Hashable a => Hashable (Maybe a) | |
At (Maybe a) | |
Ixed (Maybe a) | |
Defined in Control.Lens.At | |
MonoFoldable (Maybe a) | |
Defined in Data.MonoTraversable Methods ofoldMap :: Monoid m => (Element (Maybe a) -> m) -> Maybe a -> m Source # ofoldr :: (Element (Maybe a) -> b -> b) -> b -> Maybe a -> b Source # ofoldl' :: (a0 -> Element (Maybe a) -> a0) -> a0 -> Maybe a -> a0 Source # otoList :: Maybe a -> [Element (Maybe a)] Source # oall :: (Element (Maybe a) -> Bool) -> Maybe a -> Bool Source # oany :: (Element (Maybe a) -> Bool) -> Maybe a -> Bool Source # onull :: Maybe a -> Bool Source # olength :: Maybe a -> Int Source # olength64 :: Maybe a -> Int64 Source # ocompareLength :: Integral i => Maybe a -> i -> Ordering Source # otraverse_ :: Applicative f => (Element (Maybe a) -> f b) -> Maybe a -> f () Source # ofor_ :: Applicative f => Maybe a -> (Element (Maybe a) -> f b) -> f () Source # omapM_ :: Applicative m => (Element (Maybe a) -> m ()) -> Maybe a -> m () Source # oforM_ :: Applicative m => Maybe a -> (Element (Maybe a) -> m ()) -> m () Source # ofoldlM :: Monad m => (a0 -> Element (Maybe a) -> m a0) -> a0 -> Maybe a -> m a0 Source # ofoldMap1Ex :: Semigroup m => (Element (Maybe a) -> m) -> Maybe a -> m Source # ofoldr1Ex :: (Element (Maybe a) -> Element (Maybe a) -> Element (Maybe a)) -> Maybe a -> Element (Maybe a) Source # ofoldl1Ex' :: (Element (Maybe a) -> Element (Maybe a) -> Element (Maybe a)) -> Maybe a -> Element (Maybe a) Source # headEx :: Maybe a -> Element (Maybe a) Source # lastEx :: Maybe a -> Element (Maybe a) Source # unsafeHead :: Maybe a -> Element (Maybe a) Source # unsafeLast :: Maybe a -> Element (Maybe a) Source # maximumByEx :: (Element (Maybe a) -> Element (Maybe a) -> Ordering) -> Maybe a -> Element (Maybe a) Source # minimumByEx :: (Element (Maybe a) -> Element (Maybe a) -> Ordering) -> Maybe a -> Element (Maybe a) Source # | |
MonoFunctor (Maybe a) | |
MonoPointed (Maybe a) | |
MonoTraversable (Maybe a) | |
At (Maybe a) | |
Ixed (Maybe a) | |
Pretty a => Pretty (Maybe a) | Ignore
|
DecodeTOML a => DecodeTOML (Maybe a) | Since TOML doesn't support literal NULLs, this will only ever return |
Defined in TOML.Decode Methods tomlDecoder :: Decoder (Maybe a) Source # | |
SingI ('Nothing :: Maybe a) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
SingI a2 => SingI ('Just a2 :: Maybe a1) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep1 Maybe | Since: base-4.6.0.0 |
type StM Maybe a | |
Defined in Control.Monad.Trans.Control | |
type DemoteRep (Maybe a) | |
Defined in GHC.Generics | |
type Rep (Maybe a) | Since: base-4.6.0.0 |
Defined in GHC.Generics | |
data Sing (b :: Maybe a) | |
type Index (Maybe a) | |
Defined in Control.Lens.At | |
type IxValue (Maybe a) | |
Defined in Control.Lens.At | |
type Element (Maybe a) | |
Defined in Data.MonoTraversable | |
type Index (Maybe a) | |
Defined in Optics.At.Core | |
type IxKind (Maybe a) | |
Defined in Optics.At.Core | |
type IxValue (Maybe a) | |
Defined in Optics.At.Core |
A value of type
is a computation which, when performed,
does some I/O before returning a value of type IO
aa
.
There is really only one way to "perform" an I/O action: bind it to
Main.main
in your program. When your program is run, the I/O will
be performed. It isn't possible to perform I/O from an arbitrary
function, unless that function is itself in the IO
monad and called
at some point, directly or indirectly, from Main.main
.
IO
is a monad, so IO
actions can be combined using either the do-notation
or the >>
and >>=
operations from the Monad
class.
Instances
8-bit unsigned integer type
Instances
16-bit unsigned integer type
Instances
The Either
type represents values with two possibilities: a value of
type
is either Either
a b
or Left
a
.Right
b
The Either
type is sometimes used to represent a value which is
either correct or an error; by convention, the Left
constructor is
used to hold an error value and the Right
constructor is used to
hold a correct value (mnemonic: "right" also means "correct").
Examples
The type
is the type of values which can be either
a Either
String
Int
String
or an Int
. The Left
constructor can be used only on
String
s, and the Right
constructor can be used only on Int
s:
>>>
let s = Left "foo" :: Either String Int
>>>
s
Left "foo">>>
let n = Right 3 :: Either String Int
>>>
n
Right 3>>>
:type s
s :: Either String Int>>>
:type n
n :: Either String Int
The fmap
from our Functor
instance will ignore Left
values, but
will apply the supplied function to values contained in a Right
:
>>>
let s = Left "foo" :: Either String Int
>>>
let n = Right 3 :: Either String Int
>>>
fmap (*2) s
Left "foo">>>
fmap (*2) n
Right 6
The Monad
instance for Either
allows us to chain together multiple
actions which may fail, and fail overall if any of the individual
steps failed. First we'll write a function that can either parse an
Int
from a Char
, or fail.
>>>
import Data.Char ( digitToInt, isDigit )
>>>
:{
let parseEither :: Char -> Either String Int parseEither c | isDigit c = Right (digitToInt c) | otherwise = Left "parse error">>>
:}
The following should work, since both '1'
and '2'
can be
parsed as Int
s.
>>>
:{
let parseMultiple :: Either String Int parseMultiple = do x <- parseEither '1' y <- parseEither '2' return (x + y)>>>
:}
>>>
parseMultiple
Right 3
But the following should fail overall, since the first operation where
we attempt to parse 'm'
as an Int
will fail:
>>>
:{
let parseMultiple :: Either String Int parseMultiple = do x <- parseEither 'm' y <- parseEither '2' return (x + y)>>>
:}
>>>
parseMultiple
Left "parse error"
Instances
Non-empty (and non-strict) list type.
Since: base-4.9.0.0
Constructors
a :| [a] infixr 5 |
Instances
data Constraint Source #
The kind of constraints, like Show a
either :: (a -> c) -> (b -> c) -> Either a b -> c Source #
Case analysis for the Either
type.
If the value is
, apply the first function to Left
aa
;
if it is
, apply the second function to Right
bb
.
Examples
We create two values of type
, one using the
Either
String
Int
Left
constructor and another using the Right
constructor. Then
we apply "either" the length
function (if we have a String
)
or the "times-two" function (if we have an Int
):
>>>
let s = Left "foo" :: Either String Int
>>>
let n = Right 3 :: Either String Int
>>>
either length (*2) s
3>>>
either length (*2) n
6
class Monad m => MonadReader r (m :: Type -> Type) | m -> r where Source #
See examples in Control.Monad.Reader.
Note, the partially applied function type (->) r
is a simple reader monad.
See the instance
declaration below.
Methods
Retrieves the monad environment.
Arguments
:: (r -> r) | The function to modify the environment. |
-> m a |
|
-> m a |
Executes a computation in a modified environment.
Arguments
:: (r -> a) | The selector function to apply to the environment. |
-> m a |
Retrieves a function of the current environment.
Instances
data ByteString Source #
A space-efficient representation of a Word8
vector, supporting many
efficient operations.
A ByteString
contains 8-bit bytes, or by using the operations from
Data.ByteString.Char8 it can be interpreted as containing 8-bit
characters.
Instances
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 Source #
An infix synonym for fmap
.
The name of this operator is an allusion to $
.
Note the similarities between their types:
($) :: (a -> b) -> a -> b (<$>) :: Functor f => (a -> b) -> f a -> f b
Whereas $
is function application, <$>
is function
application lifted over a Functor
.
Examples
Convert from a
to a Maybe
Int
using Maybe
String
show
:
>>>
show <$> Nothing
Nothing>>>
show <$> Just 3
Just "3"
Convert from an
to an
Either
Int
Int
Either
Int
String
using show
:
>>>
show <$> Left 17
Left 17>>>
show <$> Right 17
Right "17"
Double each element of a list:
>>>
(*2) <$> [1,2,3]
[2,4,6]
Apply even
to the second element of a pair:
>>>
even <$> (2,2)
(2,True)
const x
is a unary function which evaluates to x
for all inputs.
>>>
const 42 "hello"
42
>>>
map (const 42) [0..3]
[42,42,42,42]
A space efficient, packed, unboxed Unicode text type.
Instances
Haskell defines operations to read and write characters from and to files,
represented by values of type Handle
. Each value of this type is a
handle: a record used by the Haskell run-time system to manage I/O
with file system objects. A handle has at least the following properties:
- whether it manages input or output or both;
- whether it is open, closed or semi-closed;
- whether the object is seekable;
- whether buffering is disabled, or enabled on a line or block basis;
- a buffer (whose length may be zero).
Most handles will also have a current I/O position indicating where the next
input or output operation will occur. A handle is readable if it
manages only input or both input and output; likewise, it is writable if
it manages only output or both input and output. A handle is open when
first allocated.
Once it is closed it can no longer be used for either input or output,
though an implementation cannot re-use its storage while references
remain to it. Handles are in the Show
and Eq
classes. The string
produced by showing a handle is system dependent; it should include
enough information to identify the handle for debugging. A handle is
equal according to ==
only to itself; no attempt
is made to compare the internal state of different handles for equality.
class Bifunctor (p :: Type -> Type -> Type) where Source #
A bifunctor is a type constructor that takes
two type arguments and is a functor in both arguments. That
is, unlike with Functor
, a type constructor such as Either
does not need to be partially applied for a Bifunctor
instance, and the methods in this class permit mapping
functions over the Left
value or the Right
value,
or both at the same time.
Formally, the class Bifunctor
represents a bifunctor
from Hask
-> Hask
.
Intuitively it is a bifunctor where both the first and second arguments are covariant.
You can define a Bifunctor
by either defining bimap
or by
defining both first
and second
.
If you supply bimap
, you should ensure that:
bimap
id
id
≡id
If you supply first
and second
, ensure:
first
id
≡id
second
id
≡id
If you supply both, you should also ensure:
bimap
f g ≡first
f.
second
g
These ensure by parametricity:
bimap
(f.
g) (h.
i) ≡bimap
f h.
bimap
g ifirst
(f.
g) ≡first
f.
first
gsecond
(f.
g) ≡second
f.
second
g
Since: base-4.8.0.0
Methods
bimap :: (a -> b) -> (c -> d) -> p a c -> p b d Source #
Map over both arguments at the same time.
bimap
f g ≡first
f.
second
g
Examples
>>>
bimap toUpper (+1) ('j', 3)
('J',4)
>>>
bimap toUpper (+1) (Left 'j')
Left 'J'
>>>
bimap toUpper (+1) (Right 3)
Right 4
Instances
Uninhabited data type
Since: base-4.8.0.0
Instances
Data Void | Since: base-4.8.0.0 |
Defined in Data.Void Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Void -> c Void Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Void Source # toConstr :: Void -> Constr Source # dataTypeOf :: Void -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Void) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Void) Source # gmapT :: (forall b. Data b => b -> b) -> Void -> Void Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Void -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Void -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Void -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Void -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Void -> m Void Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Void -> m Void Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Void -> m Void Source # | |
Semigroup Void | Since: base-4.9.0.0 |
Exception Void | Since: base-4.8.0.0 |
Defined in Data.Void Methods toException :: Void -> SomeException Source # fromException :: SomeException -> Maybe Void Source # displayException :: Void -> String Source # | |
Generic Void | |
Ix Void | Since: base-4.8.0.0 |
Defined in Data.Void | |
Read Void | Reading a Since: base-4.8.0.0 |
Show Void | Since: base-4.8.0.0 |
NFData Void | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
Eq Void | Since: base-4.8.0.0 |
Ord Void | Since: base-4.8.0.0 |
Hashable Void | |
ShowErrorComponent Void | |
Defined in Text.Megaparsec.Error | |
Pretty Void | Finding a good example for printing something that does not exist is hard, so here is an example of printing a list full of nothing.
|
DecodeTOML Void | |
Defined in TOML.Decode Methods | |
Lift Void | Since: template-haskell-2.15.0.0 |
type Rep Void | Since: base-4.8.0.0 |
Since Void
values logically don't exist, this witnesses the
logical reasoning tool of "ex falso quodlibet".
>>>
let x :: Either Void Int; x = Right 5
>>>
:{
case x of Right r -> r Left l -> absurd l :} 5
Since: base-4.8.0.0
class Monad m => MonadIO (m :: Type -> Type) where Source #
Monads in which IO
computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO
monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads:
Methods
liftIO :: IO a -> m a Source #
Lift a computation from the IO
monad.
This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations
(i.e. IO
is the base monad for the stack).
Example
import Control.Monad.Trans.State -- from the "transformers" library printState :: Show s => StateT s IO () printState = do state <- get liftIO $ print state
Had we omitted
, we would have ended up with this error:liftIO
• Couldn't match type ‘IO’ with ‘StateT s IO’ Expected type: StateT s IO () Actual type: IO ()
The important part here is the mismatch between StateT s IO ()
and
.IO
()
Luckily, we know of a function that takes an
and returns an IO
a(m a)
:
,
enabling us to run the program and see the expected results:liftIO
> evalStateT printState "hello" "hello" > evalStateT printState 3 3
Instances
forever :: Applicative f => f a -> f b Source #
Repeat an action indefinitely.
Examples
A common use of forever
is to process input from network sockets,
Handle
s, and channels
(e.g. MVar
and
Chan
).
For example, here is how we might implement an echo
server, using
forever
both to listen for client connections on a network socket
and to echo client input on client connection handles:
echoServer :: Socket -> IO () echoServer socket =forever
$ do client <- accept socketforkFinally
(echo client) (\_ -> hClose client) where echo :: Handle -> IO () echo client =forever
$ hGetLine client >>= hPutStrLn client
Note that "forever" isn't necessarily non-terminating.
If the action is in a
and short-circuits after some number of iterations.
then MonadPlus
actually returns forever
mzero
, effectively short-circuiting its caller.
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 Source #
Left-to-right composition of Kleisli arrows.
'(bs
' can be understood as the >=>
cs) ado
expression
do b <- bs a cs b
A mutable variable in the IO
monad
Instances
NFData1 IORef | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
NFData (IORef a) | NOTE: Only strict in the reference and not the referenced value. Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
Eq (IORef a) | Pointer equality. Since: base-4.0.0.0 |
class (Typeable e, Show e) => Exception e where Source #
Any type that you wish to throw or catch as an exception must be an
instance of the Exception
class. The simplest case is a new exception
type directly below the root:
data MyException = ThisException | ThatException deriving Show instance Exception MyException
The default method definitions in the Exception
class do what we need
in this case. You can now throw and catch ThisException
and
ThatException
as exceptions:
*Main> throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException)) Caught ThisException
In more complicated examples, you may wish to define a whole hierarchy of exceptions:
--------------------------------------------------------------------- -- Make the root exception type for all the exceptions in a compiler data SomeCompilerException = forall e . Exception e => SomeCompilerException e instance Show SomeCompilerException where show (SomeCompilerException e) = show e instance Exception SomeCompilerException compilerExceptionToException :: Exception e => e -> SomeException compilerExceptionToException = toException . SomeCompilerException compilerExceptionFromException :: Exception e => SomeException -> Maybe e compilerExceptionFromException x = do SomeCompilerException a <- fromException x cast a --------------------------------------------------------------------- -- Make a subhierarchy for exceptions in the frontend of the compiler data SomeFrontendException = forall e . Exception e => SomeFrontendException e instance Show SomeFrontendException where show (SomeFrontendException e) = show e instance Exception SomeFrontendException where toException = compilerExceptionToException fromException = compilerExceptionFromException frontendExceptionToException :: Exception e => e -> SomeException frontendExceptionToException = toException . SomeFrontendException frontendExceptionFromException :: Exception e => SomeException -> Maybe e frontendExceptionFromException x = do SomeFrontendException a <- fromException x cast a --------------------------------------------------------------------- -- Make an exception type for a particular frontend compiler exception data MismatchedParentheses = MismatchedParentheses deriving Show instance Exception MismatchedParentheses where toException = frontendExceptionToException fromException = frontendExceptionFromException
We can now catch a MismatchedParentheses
exception as
MismatchedParentheses
, SomeFrontendException
or
SomeCompilerException
, but not other types, e.g. IOException
:
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses)) Caught MismatchedParentheses *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException)) Caught MismatchedParentheses *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException)) Caught MismatchedParentheses *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: IOException)) *** Exception: MismatchedParentheses
Minimal complete definition
Nothing
Methods
toException :: e -> SomeException Source #
fromException :: SomeException -> Maybe e Source #
displayException :: e -> String Source #
Render this exception value in a human-friendly manner.
Default implementation:
.show
Since: base-4.8.0.0
Instances
traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f () Source #
Map each element of a structure to an Applicative
action, evaluate these
actions from left to right, and ignore the results. For a version that
doesn't ignore the results see traverse
.
traverse_
is just like mapM_
, but generalised to Applicative
actions.
Examples
Basic usage:
>>>
traverse_ print ["Hello", "world", "!"]
"Hello" "world" "!"
for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f () Source #
for_
is traverse_
with its arguments flipped. For a version
that doesn't ignore the results see for
. This
is forM_
generalised to Applicative
actions.
for_
is just like forM_
, but generalised to Applicative
actions.
Examples
Basic usage:
>>>
for_ [1..4] print
1 2 3 4
all :: Foldable t => (a -> Bool) -> t a -> Bool Source #
Determines whether all elements of the structure satisfy the predicate.
Examples
Basic usage:
>>>
all (> 3) []
True
>>>
all (> 3) [1,2]
False
>>>
all (> 3) [1,2,3,4,5]
False
>>>
all (> 3) [1..]
False
>>>
all (> 3) [4..]
* Hangs forever *
Proxy
is a type that holds no data, but has a phantom parameter of
arbitrary type (or even kind). Its use is to provide type information, even
though there is no value available of that type (or it may be too costly to
create one).
Historically,
is a safer alternative to the
Proxy
:: Proxy
a
idiom.undefined
:: a
>>>
Proxy :: Proxy (Void, Int -> Int)
Proxy
Proxy can even hold types of higher kinds,
>>>
Proxy :: Proxy Either
Proxy
>>>
Proxy :: Proxy Functor
Proxy
>>>
Proxy :: Proxy complicatedStructure
Proxy
Constructors
Proxy |
Instances
Generic1 (Proxy :: k -> Type) | |
Representable (Proxy :: Type -> Type) | |
Foldable (Proxy :: TYPE LiftedRep -> Type) | Since: base-4.7.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Proxy m -> m Source # foldMap :: Monoid m => (a -> m) -> Proxy a -> m Source # foldMap' :: Monoid m => (a -> m) -> Proxy a -> m Source # foldr :: (a -> b -> b) -> b -> Proxy a -> b Source # foldr' :: (a -> b -> b) -> b -> Proxy a -> b Source # foldl :: (b -> a -> b) -> b -> Proxy a -> b Source # foldl' :: (b -> a -> b) -> b -> Proxy a -> b Source # foldr1 :: (a -> a -> a) -> Proxy a -> a Source # foldl1 :: (a -> a -> a) -> Proxy a -> a Source # toList :: Proxy a -> [a] Source # null :: Proxy a -> Bool Source # length :: Proxy a -> Int Source # elem :: Eq a => a -> Proxy a -> Bool Source # maximum :: Ord a => Proxy a -> a Source # minimum :: Ord a => Proxy a -> a Source # | |
Eq1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Ord1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Read1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Proxy a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Proxy a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Proxy a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Proxy a] Source # | |
Show1 (Proxy :: TYPE LiftedRep -> Type) | Since: base-4.9.0.0 |
Traversable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Alternative (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Applicative (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Functor (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Monad (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
MonadPlus (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
NFData1 (Proxy :: TYPE LiftedRep -> Type) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Hashable1 (Proxy :: Type -> Type) | |
Defined in Data.Hashable.Class | |
Monoid (Proxy s) | Since: base-4.7.0.0 |
Semigroup (Proxy s) | Since: base-4.9.0.0 |
Bounded (Proxy t) | Since: base-4.7.0.0 |
Enum (Proxy s) | Since: base-4.7.0.0 |
Defined in Data.Proxy Methods succ :: Proxy s -> Proxy s Source # pred :: Proxy s -> Proxy s Source # toEnum :: Int -> Proxy s Source # fromEnum :: Proxy s -> Int Source # enumFrom :: Proxy s -> [Proxy s] Source # enumFromThen :: Proxy s -> Proxy s -> [Proxy s] Source # enumFromTo :: Proxy s -> Proxy s -> [Proxy s] Source # enumFromThenTo :: Proxy s -> Proxy s -> Proxy s -> [Proxy s] Source # | |
Generic (Proxy t) | |
Ix (Proxy s) | Since: base-4.7.0.0 |
Read (Proxy t) | Since: base-4.7.0.0 |
Show (Proxy s) | Since: base-4.7.0.0 |
NFData (Proxy a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
Eq (Proxy s) | Since: base-4.7.0.0 |
Ord (Proxy s) | Since: base-4.7.0.0 |
Hashable (Proxy a) | |
MonoFoldable (Proxy a) | Since: mono-traversable-1.0.11.0 |
Defined in Data.MonoTraversable Methods ofoldMap :: Monoid m => (Element (Proxy a) -> m) -> Proxy a -> m Source # ofoldr :: (Element (Proxy a) -> b -> b) -> b -> Proxy a -> b Source # ofoldl' :: (a0 -> Element (Proxy a) -> a0) -> a0 -> Proxy a -> a0 Source # otoList :: Proxy a -> [Element (Proxy a)] Source # oall :: (Element (Proxy a) -> Bool) -> Proxy a -> Bool Source # oany :: (Element (Proxy a) -> Bool) -> Proxy a -> Bool Source # onull :: Proxy a -> Bool Source # olength :: Proxy a -> Int Source # olength64 :: Proxy a -> Int64 Source # ocompareLength :: Integral i => Proxy a -> i -> Ordering Source # otraverse_ :: Applicative f => (Element (Proxy a) -> f b) -> Proxy a -> f () Source # ofor_ :: Applicative f => Proxy a -> (Element (Proxy a) -> f b) -> f () Source # omapM_ :: Applicative m => (Element (Proxy a) -> m ()) -> Proxy a -> m () Source # oforM_ :: Applicative m => Proxy a -> (Element (Proxy a) -> m ()) -> m () Source # ofoldlM :: Monad m => (a0 -> Element (Proxy a) -> m a0) -> a0 -> Proxy a -> m a0 Source # ofoldMap1Ex :: Semigroup m => (Element (Proxy a) -> m) -> Proxy a -> m Source # ofoldr1Ex :: (Element (Proxy a) -> Element (Proxy a) -> Element (Proxy a)) -> Proxy a -> Element (Proxy a) Source # ofoldl1Ex' :: (Element (Proxy a) -> Element (Proxy a) -> Element (Proxy a)) -> Proxy a -> Element (Proxy a) Source # headEx :: Proxy a -> Element (Proxy a) Source # lastEx :: Proxy a -> Element (Proxy a) Source # unsafeHead :: Proxy a -> Element (Proxy a) Source # unsafeLast :: Proxy a -> Element (Proxy a) Source # maximumByEx :: (Element (Proxy a) -> Element (Proxy a) -> Ordering) -> Proxy a -> Element (Proxy a) Source # minimumByEx :: (Element (Proxy a) -> Element (Proxy a) -> Ordering) -> Proxy a -> Element (Proxy a) Source # | |
MonoFunctor (Proxy a) | Since: mono-traversable-1.0.11.0 |
MonoPointed (Proxy a) | Since: mono-traversable-1.0.11.0 |
MonoTraversable (Proxy a) | Since: mono-traversable-1.0.11.0 |
DecodeTOML (Proxy a) | |
Defined in TOML.Decode Methods tomlDecoder :: Decoder (Proxy a) Source # | |
type Rep1 (Proxy :: k -> Type) | Since: base-4.6.0.0 |
type Rep (Proxy :: Type -> Type) | |
type Rep (Proxy t) | Since: base-4.6.0.0 |
type Element (Proxy a) | |
Defined in Data.MonoTraversable |
See openFile
Constructors
ReadMode | |
WriteMode | |
AppendMode | |
ReadWriteMode |
Instances
Enum IOMode | Since: base-4.2.0.0 |
Defined in GHC.IO.IOMode Methods succ :: IOMode -> IOMode Source # pred :: IOMode -> IOMode Source # toEnum :: Int -> IOMode Source # fromEnum :: IOMode -> Int Source # enumFrom :: IOMode -> [IOMode] Source # enumFromThen :: IOMode -> IOMode -> [IOMode] Source # enumFromTo :: IOMode -> IOMode -> [IOMode] Source # enumFromThenTo :: IOMode -> IOMode -> IOMode -> [IOMode] Source # | |
Ix IOMode | Since: base-4.2.0.0 |
Read IOMode | Since: base-4.2.0.0 |
Show IOMode | Since: base-4.2.0.0 |
Eq IOMode | Since: base-4.2.0.0 |
Ord IOMode | Since: base-4.2.0.0 |
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] Source #
\(\mathcal{O}(\min(m,n))\). zipWith
generalises zip
by zipping with the
function given as the first argument, instead of a tupling function.
zipWith (,) xs ys == zip xs ys zipWith f [x1,x2,x3..] [y1,y2,y3..] == [f x1 y1, f x2 y2, f x3 y3..]
For example,
is applied to two lists to produce the list of
corresponding sums:zipWith
(+)
>>>
zipWith (+) [1, 2, 3] [4, 5, 6]
[5,7,9]
zipWith
is right-lazy:
>>>
let f = undefined
>>>
zipWith f [] undefined
[]
zipWith
is capable of list fusion, but it is restricted to its
first list argument and its resulting list.
replicate :: Int -> a -> [a] Source #
replicate
n x
is a list of length n
with x
the value of
every element.
It is an instance of the more general genericReplicate
,
in which n
may be of any integral type.
>>>
replicate 0 True
[]>>>
replicate (-1) True
[]>>>
replicate 4 True
[True,True,True,True]
maybeToList :: Maybe a -> [a] Source #
The maybeToList
function returns an empty list when given
Nothing
or a singleton list when given Just
.
Examples
Basic usage:
>>>
maybeToList (Just 7)
[7]
>>>
maybeToList Nothing
[]
One can use maybeToList
to avoid pattern matching when combined
with a function that (safely) works on lists:
>>>
import Text.Read ( readMaybe )
>>>
sum $ maybeToList (readMaybe "3")
3>>>
sum $ maybeToList (readMaybe "")
0
maybe :: b -> (a -> b) -> Maybe a -> b Source #
The maybe
function takes a default value, a function, and a Maybe
value. If the Maybe
value is Nothing
, the function returns the
default value. Otherwise, it applies the function to the value inside
the Just
and returns the result.
Examples
Basic usage:
>>>
maybe False odd (Just 3)
True
>>>
maybe False odd Nothing
False
Read an integer from a string using readMaybe
. If we succeed,
return twice the integer; that is, apply (*2)
to it. If instead
we fail to parse an integer, return 0
by default:
>>>
import Text.Read ( readMaybe )
>>>
maybe 0 (*2) (readMaybe "5")
10>>>
maybe 0 (*2) (readMaybe "")
0
Apply show
to a Maybe Int
. If we have Just n
, we want to show
the underlying Int
n
. But if we have Nothing
, we return the
empty string instead of (for example) "Nothing":
>>>
maybe "" show (Just 5)
"5">>>
maybe "" show Nothing
""
fromMaybe :: a -> Maybe a -> a Source #
The fromMaybe
function takes a default value and a Maybe
value. If the Maybe
is Nothing
, it returns the default value;
otherwise, it returns the value contained in the Maybe
.
Examples
Basic usage:
>>>
fromMaybe "" (Just "Hello, World!")
"Hello, World!"
>>>
fromMaybe "" Nothing
""
Read an integer from a string using readMaybe
. If we fail to
parse an integer, we want to return 0
by default:
>>>
import Text.Read ( readMaybe )
>>>
fromMaybe 0 (readMaybe "5")
5>>>
fromMaybe 0 (readMaybe "")
0
void :: Functor f => f a -> f () Source #
discards or ignores the result of evaluation, such
as the return value of an void
valueIO
action.
Examples
Replace the contents of a
with unit:Maybe
Int
>>>
void Nothing
Nothing>>>
void (Just 3)
Just ()
Replace the contents of an
with unit, resulting in an Either
Int
Int
:Either
Int
()
>>>
void (Left 8675309)
Left 8675309>>>
void (Right 8675309)
Right ()
Replace every element of a list with unit:
>>>
void [1,2,3]
[(),(),()]
Replace the second element of a pair with unit:
>>>
void (1,2)
(1,())
Discard the result of an IO
action:
>>>
mapM print [1,2]
1 2 [(),()]>>>
void $ mapM print [1,2]
1 2
($>) :: Functor f => f a -> b -> f b infixl 4 Source #
Flipped version of <$
.
Examples
Replace the contents of a
with a constant
Maybe
Int
String
:
>>>
Nothing $> "foo"
Nothing>>>
Just 90210 $> "foo"
Just "foo"
Replace the contents of an
with a constant Either
Int
Int
String
, resulting in an
:Either
Int
String
>>>
Left 8675309 $> "foo"
Left 8675309>>>
Right 8675309 $> "foo"
Right "foo"
Replace each element of a list with a constant String
:
>>>
[1,2,3] $> "foo"
["foo","foo","foo"]
Replace the second element of a pair with a constant String
:
>>>
(1,2) $> "foo"
(1,"foo")
Since: base-4.7.0.0
uncurry :: (a -> b -> c) -> (a, b) -> c Source #
uncurry
converts a curried function to a function on pairs.
Examples
>>>
uncurry (+) (1,2)
3
>>>
uncurry ($) (show, 1)
"1"
>>>
map (uncurry max) [(1,2), (3,4), (6,8)]
[2,4,8]
class Applicative f => Alternative (f :: Type -> Type) where Source #
A monoid on applicative functors.
If defined, some
and many
should be the least solutions
of the equations:
Methods
The identity of <|>
(<|>) :: f a -> f a -> f a infixl 3 Source #
An associative binary operation
One or more.
Zero or more.
Instances
when :: Applicative f => Bool -> f () -> f () Source #
Conditional execution of Applicative
expressions. For example,
when debug (putStrLn "Debugging")
will output the string Debugging
if the Boolean value debug
is True
, and otherwise do nothing.
flip :: (a -> b -> c) -> b -> a -> c Source #
takes its (first) two arguments in the reverse order of flip
ff
.
>>>
flip (++) "hello" "world"
"worldhello"
(=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 Source #
Same as >>=
, but with the arguments interchanged.
(<**>) :: Applicative f => f a -> f (a -> b) -> f b infixl 4 Source #
A variant of <*>
with the arguments reversed.
undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a Source #
type HasCallStack = ?callStack :: CallStack Source #
Request a CallStack.
NOTE: The implicit parameter ?callStack :: CallStack
is an
implementation detail and should not be considered part of the
CallStack
API, we may decide to change the implementation in the
future.
Since: base-4.9.0.0
data SomeException Source #
The SomeException
type is the root of the exception type hierarchy.
When an exception of type e
is thrown, behind the scenes it is
encapsulated in a SomeException
.
Instances
Exception SomeException | Since: base-3.0 |
Defined in GHC.Exception.Type Methods toException :: SomeException -> SomeException Source # fromException :: SomeException -> Maybe SomeException Source # | |
Show SomeException | Since: base-3.0 |
Defined in GHC.Exception.Type |
newtype ReaderT r (m :: Type -> Type) a Source #
The reader monad transformer, which adds a read-only environment to the given monad.
The return
function ignores the environment, while >>=
passes
the inherited environment to both subcomputations.
Constructors
ReaderT | |
Fields
|
Instances
class MonadTrans (t :: (Type -> Type) -> Type -> Type) where Source #
The class of monad transformers. Instances should satisfy the
following laws, which state that lift
is a monad transformation:
Methods
lift :: Monad m => m a -> t m a Source #
Lift a computation from the argument monad to the constructed monad.
Instances
MonadTrans Free | This is not a true monad transformer. It is only a monad transformer "up to |
MonadTrans Yoneda | |
MonadTrans LoggingT | |
MonadTrans NoLoggingT | |
Defined in Control.Monad.Logger Methods lift :: Monad m => m a -> NoLoggingT m a Source # | |
MonadTrans WriterLoggingT | |
Defined in Control.Monad.Logger Methods lift :: Monad m => m a -> WriterLoggingT m a Source # | |
MonadTrans ResourceT | |
MonadTrans ListT | |
MonadTrans MaybeT | |
Alternative f => MonadTrans (CofreeT f) | |
Functor f => MonadTrans (FreeT f) | |
MonadTrans (NaviT e) Source # | |
MonadTrans (ErrorT e) | |
MonadTrans (ExceptT e) | |
MonadTrans (IdentityT :: (Type -> Type) -> Type -> Type) | |
MonadTrans (ReaderT r) | |
MonadTrans (StateT s) | |
MonadTrans (StateT s) | |
Monoid w => MonadTrans (WriterT w) | |
Monoid w => MonadTrans (WriterT w) | |
MonadTrans (ConduitT i o) | |
MonadTrans (ContT r) | |
Monoid w => MonadTrans (RWST r w s) | |
Monoid w => MonadTrans (RWST r w s) | |
MonadTrans (Pipe l i o u) | |
class Monad m => MonadThrow (m :: Type -> Type) Source #
A class for monads in which exceptions may be thrown.
Instances should obey the following law:
throwM e >> x = throwM e
In other words, throwing an exception short-circuits the rest of the monadic computation.
Minimal complete definition
Instances
General-purpose finite sequences.
Bundled Patterns
pattern (:<|) :: a -> Seq a -> Seq a infixr 5 | A bidirectional pattern synonym viewing the front of a non-empty sequence. Since: containers-0.5.8 |
pattern (:|>) :: Seq a -> a -> Seq a infixl 5 | A bidirectional pattern synonym viewing the rear of a non-empty sequence. Since: containers-0.5.8 |
Instances
A class of types that can be fully evaluated.
Since: deepseq-1.1.0.0
Instances
(</>) :: FilePath -> FilePath -> FilePath infixr 5 Source #
Combine two paths with a path separator.
If the second path starts with a path separator or a drive letter, then it returns the second.
The intention is that readFile (dir
will access the same file as
</>
file)setCurrentDirectory dir; readFile file
.
Posix: "/directory" </> "file.ext" == "/directory/file.ext" Windows: "/directory" </> "file.ext" == "/directory\\file.ext" "directory" </> "/file.ext" == "/file.ext" Valid x => (takeDirectory x </> takeFileName x) `equalFilePath` x
Combined:
Posix: "/" </> "test" == "/test" Posix: "home" </> "bob" == "home/bob" Posix: "x:" </> "foo" == "x:/foo" Windows: "C:\\foo" </> "bar" == "C:\\foo\\bar" Windows: "home" </> "bob" == "home\\bob"
Not combined:
Posix: "home" </> "/bob" == "/bob" Windows: "home" </> "C:\\bob" == "C:\\bob"
Not combined (tricky):
On Windows, if a filepath starts with a single slash, it is relative to the
root of the current drive. In [1], this is (confusingly) referred to as an
absolute path.
The current behavior of </>
is to never combine these forms.
Windows: "home" </> "/bob" == "/bob" Windows: "home" </> "\\bob" == "\\bob" Windows: "C:\\home" </> "\\bob" == "\\bob"
On Windows, from [1]: "If a file name begins with only a disk designator
but not the backslash after the colon, it is interpreted as a relative path
to the current directory on the drive with the specified letter."
The current behavior of </>
is to never combine these forms.
Windows: "D:\\foo" </> "C:bar" == "C:bar" Windows: "C:\\foo" </> "C:bar" == "C:bar"
class MonadCatch m => MonadMask (m :: Type -> Type) where Source #
A class for monads which provide for the ability to account for all possible exit points from a computation, and to mask asynchronous exceptions. Continuation-based monads are invalid instances of this class.
Instances should ensure that, in the following code:
fg = f `finally` g
The action g
is called regardless of what occurs within f
, including
async exceptions. Some monads allow f
to abort the computation via other
effects than throwing an exception. For simplicity, we will consider aborting
and throwing an exception to be two forms of "throwing an error".
If f
and g
both throw an error, the error thrown by fg
depends on which
errors we're talking about. In a monad transformer stack, the deeper layers
override the effects of the inner layers; for example, ExceptT e1 (Except
e2) a
represents a value of type Either e2 (Either e1 a)
, so throwing both
an e1
and an e2
will result in Left e2
. If f
and g
both throw an
error from the same layer, instances should ensure that the error from g
wins.
Effects other than throwing an error are also overriden by the deeper layers.
For example, StateT s Maybe a
represents a value of type s -> Maybe (a,
s)
, so if an error thrown from f
causes this function to return Nothing
,
any changes to the state which f
also performed will be erased. As a
result, g
will see the state as it was before f
. Once g
completes,
f
's error will be rethrown, so g
' state changes will be erased as well.
This is the normal interaction between effects in a monad transformer stack.
By contrast, lifted-base's
version of finally
always discards all of g
's non-IO effects, and g
never sees any of f
's non-IO effects, regardless of the layer ordering and
regardless of whether f
throws an error. This is not the result of
interacting effects, but a consequence of MonadBaseControl
's approach.
Minimal complete definition
Methods
mask :: ((forall a. m a -> m a) -> m b) -> m b Source #
Runs an action with asynchronous exceptions disabled. The action is
provided a method for restoring the async. environment to what it was
at the mask
call. See Control.Exception's mask
.
Instances
MonadMask IO | |
e ~ SomeException => MonadMask (Either e) | Since: exceptions-0.8.3 |
Defined in Control.Monad.Catch Methods mask :: ((forall a. Either e a -> Either e a) -> Either e b) -> Either e b Source # uninterruptibleMask :: ((forall a. Either e a -> Either e a) -> Either e b) -> Either e b Source # generalBracket :: Either e a -> (a -> ExitCase b -> Either e c) -> (a -> Either e b) -> Either e (b, c) Source # | |
MonadMask m => MonadMask (LoggingT m) | |
Defined in Control.Monad.Logger Methods mask :: ((forall a. LoggingT m a -> LoggingT m a) -> LoggingT m b) -> LoggingT m b Source # uninterruptibleMask :: ((forall a. LoggingT m a -> LoggingT m a) -> LoggingT m b) -> LoggingT m b Source # generalBracket :: LoggingT m a -> (a -> ExitCase b -> LoggingT m c) -> (a -> LoggingT m b) -> LoggingT m (b, c) Source # | |
MonadMask m => MonadMask (NoLoggingT m) | |
Defined in Control.Monad.Logger Methods mask :: ((forall a. NoLoggingT m a -> NoLoggingT m a) -> NoLoggingT m b) -> NoLoggingT m b Source # uninterruptibleMask :: ((forall a. NoLoggingT m a -> NoLoggingT m a) -> NoLoggingT m b) -> NoLoggingT m b Source # generalBracket :: NoLoggingT m a -> (a -> ExitCase b -> NoLoggingT m c) -> (a -> NoLoggingT m b) -> NoLoggingT m (b, c) Source # | |
MonadMask m => MonadMask (WriterLoggingT m) | |
Defined in Control.Monad.Logger Methods mask :: ((forall a. WriterLoggingT m a -> WriterLoggingT m a) -> WriterLoggingT m b) -> WriterLoggingT m b Source # uninterruptibleMask :: ((forall a. WriterLoggingT m a -> WriterLoggingT m a) -> WriterLoggingT m b) -> WriterLoggingT m b Source # generalBracket :: WriterLoggingT m a -> (a -> ExitCase b -> WriterLoggingT m c) -> (a -> WriterLoggingT m b) -> WriterLoggingT m (b, c) Source # | |
MonadMask m => MonadMask (ResourceT m) | |
Defined in Control.Monad.Trans.Resource.Internal Methods mask :: ((forall a. ResourceT m a -> ResourceT m a) -> ResourceT m b) -> ResourceT m b Source # uninterruptibleMask :: ((forall a. ResourceT m a -> ResourceT m a) -> ResourceT m b) -> ResourceT m b Source # generalBracket :: ResourceT m a -> (a -> ExitCase b -> ResourceT m c) -> (a -> ResourceT m b) -> ResourceT m (b, c) Source # | |
MonadMask m => MonadMask (MaybeT m) | Since: exceptions-0.10.0 |
Defined in Control.Monad.Catch Methods mask :: ((forall a. MaybeT m a -> MaybeT m a) -> MaybeT m b) -> MaybeT m b Source # uninterruptibleMask :: ((forall a. MaybeT m a -> MaybeT m a) -> MaybeT m b) -> MaybeT m b Source # generalBracket :: MaybeT m a -> (a -> ExitCase b -> MaybeT m c) -> (a -> MaybeT m b) -> MaybeT m (b, c) Source # | |
MonadMask m => MonadMask (NaviT e m) Source # | |
Defined in Navi.NaviT Methods mask :: ((forall a. NaviT e m a -> NaviT e m a) -> NaviT e m b) -> NaviT e m b Source # uninterruptibleMask :: ((forall a. NaviT e m a -> NaviT e m a) -> NaviT e m b) -> NaviT e m b Source # generalBracket :: NaviT e m a -> (a -> ExitCase b -> NaviT e m c) -> (a -> NaviT e m b) -> NaviT e m (b, c) Source # | |
(Error e, MonadMask m) => MonadMask (ErrorT e m) | |
Defined in Control.Monad.Catch Methods mask :: ((forall a. ErrorT e m a -> ErrorT e m a) -> ErrorT e m b) -> ErrorT e m b Source # uninterruptibleMask :: ((forall a. ErrorT e m a -> ErrorT e m a) -> ErrorT e m b) -> ErrorT e m b Source # generalBracket :: ErrorT e m a -> (a -> ExitCase b -> ErrorT e m c) -> (a -> ErrorT e m b) -> ErrorT e m (b, c) Source # | |
MonadMask m => MonadMask (ExceptT e m) | Since: exceptions-0.9.0 |
Defined in Control.Monad.Catch Methods mask :: ((forall a. ExceptT e m a -> ExceptT e m a) -> ExceptT e m b) -> ExceptT e m b Source # uninterruptibleMask :: ((forall a. ExceptT e m a -> ExceptT e m a) -> ExceptT e m b) -> ExceptT e m b Source # generalBracket :: ExceptT e m a -> (a -> ExitCase b -> ExceptT e m c) -> (a -> ExceptT e m b) -> ExceptT e m (b, c) Source # | |
MonadMask m => MonadMask (IdentityT m) | |
Defined in Control.Monad.Catch Methods mask :: ((forall a. IdentityT m a -> IdentityT m a) -> IdentityT m b) -> IdentityT m b Source # uninterruptibleMask :: ((forall a. IdentityT m a -> IdentityT m a) -> IdentityT m b) -> IdentityT m b Source # generalBracket :: IdentityT m a -> (a -> ExitCase b -> IdentityT m c) -> (a -> IdentityT m b) -> IdentityT m (b, c) Source # | |
MonadMask m => MonadMask (ReaderT r m) | |
Defined in Control.Monad.Catch Methods mask :: ((forall a. ReaderT r m a -> ReaderT r m a) -> ReaderT r m b) -> ReaderT r m b Source # uninterruptibleMask :: ((forall a. ReaderT r m a -> ReaderT r m a) -> ReaderT r m b) -> ReaderT r m b Source # generalBracket :: ReaderT r m a -> (a -> ExitCase b -> ReaderT r m c) -> (a -> ReaderT r m b) -> ReaderT r m (b, c) Source # | |
MonadMask m => MonadMask (StateT s m) | |
Defined in Control.Monad.Catch Methods mask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b Source # uninterruptibleMask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b Source # generalBracket :: StateT s m a -> (a -> ExitCase b -> StateT s m c) -> (a -> StateT s m b) -> StateT s m (b, c) Source # | |
MonadMask m => MonadMask (StateT s m) | |
Defined in Control.Monad.Catch Methods mask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b Source # uninterruptibleMask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b Source # generalBracket :: StateT s m a -> (a -> ExitCase b -> StateT s m c) -> (a -> StateT s m b) -> StateT s m (b, c) Source # | |
(MonadMask m, Monoid w) => MonadMask (WriterT w m) | |
Defined in Control.Monad.Catch Methods mask :: ((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b) -> WriterT w m b Source # uninterruptibleMask :: ((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b) -> WriterT w m b Source # generalBracket :: WriterT w m a -> (a -> ExitCase b -> WriterT w m c) -> (a -> WriterT w m b) -> WriterT w m (b, c) Source # | |
(MonadMask m, Monoid w) => MonadMask (WriterT w m) | |
Defined in Control.Monad.Catch Methods mask :: ((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b) -> WriterT w m b Source # uninterruptibleMask :: ((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b) -> WriterT w m b Source # generalBracket :: WriterT w m a -> (a -> ExitCase b -> WriterT w m c) -> (a -> WriterT w m b) -> WriterT w m (b, c) Source # | |
(MonadMask m, Monoid w) => MonadMask (RWST r w s m) | |
Defined in Control.Monad.Catch Methods mask :: ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b) -> RWST r w s m b Source # uninterruptibleMask :: ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b) -> RWST r w s m b Source # generalBracket :: RWST r w s m a -> (a -> ExitCase b -> RWST r w s m c) -> (a -> RWST r w s m b) -> RWST r w s m (b, c) Source # | |
(MonadMask m, Monoid w) => MonadMask (RWST r w s m) | |
Defined in Control.Monad.Catch Methods mask :: ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b) -> RWST r w s m b Source # uninterruptibleMask :: ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b) -> RWST r w s m b Source # generalBracket :: RWST r w s m a -> (a -> ExitCase b -> RWST r w s m c) -> (a -> RWST r w s m b) -> RWST r w s m (b, c) Source # |
class MonadThrow m => MonadCatch (m :: Type -> Type) Source #
A class for monads which allow exceptions to be caught, in particular
exceptions which were thrown by throwM
.
Instances should obey the following law:
catch (throwM e) f = f e
Note that the ability to catch an exception does not guarantee that we can
deal with all possible exit points from a computation. Some monads, such as
continuation-based stacks, allow for more than just a success/failure
strategy, and therefore catch
cannot be used by those monads to properly
implement a function such as finally
. For more information, see
MonadMask
.
Minimal complete definition
Instances
finally :: MonadMask m => m a -> m b -> m a Source #
Perform an action with a finalizer action that is run, even if an error occurs.
bracket :: MonadMask m => m a -> (a -> m c) -> (a -> m b) -> m b Source #
Generalized abstracted pattern of safe resource acquisition and release
in the face of errors. The first action "acquires" some value, which
is "released" by the second action at the end. The third action "uses"
the value and its result is the result of the bracket
.
If an error is thrown during the use, the release still happens before the error is rethrown.
Note that this is essentially a type-specialized version of
generalBracket
. This function has a more common signature (matching the
signature from Control.Exception), and is often more convenient to use. By
contrast, generalBracket
is more expressive, allowing us to implement
other functions like bracketOnError
.
Log message builder. Use (<>
) to append two LogStr in O(1).
logOther :: Text -> Q Exp Source #
Generates a function that takes a Text
and logs a LevelOther
message. Usage:
$(logOther "My new level") "This is a log message"
Generates a function that takes a Text
and logs a LevelDebug
message. Usage:
$(logDebug) "This is a debug log message"
Constructors
LevelDebug | |
LevelInfo | |
LevelWarn | |
LevelError |
Instances
Read LogLevel | |
Show LogLevel | |
Eq LogLevel | |
Ord LogLevel | |
Defined in Control.Monad.Logger | |
Lift LogLevel | |
class Monad m => MonadLogger (m :: Type -> Type) where Source #
A Monad
which has the ability to log messages in some manner.
Minimal complete definition
Nothing
Instances
Arguments
:: MonadReader r m | |
=> (r -> a) | The selector function to apply to the environment. |
-> m a |
Retrieves a function of the current environment.
_1 :: Field1 s t a b => Lens s t a b Source #
Access the 1st field of a tuple (and possibly change its type).
>>>
(1,2) ^. _1
1
>>>
(1,2) & _1 .~ "hello"
("hello",2)
>>>
traverseOf _1 putStrLn ("hello","world")
hello ((),"world")
This can also be used on larger tuples as well:
>>>
(1,2,3,4,5) & _1 %~ (+41)
(42,2,3,4,5)
_2 :: Field2 s t a b => Lens s t a b Source #
Access the 2nd field of a tuple.
>>>
_2 .~ "hello" $ (1,(),3,4)
(1,"hello",3,4)
>>>
(1,2,3,4) & _2 %~ (*3)
(1,6,3,4)
>>>
traverseOf _2 print (1,2)
2 (1,())
type Traversal' s a = Optic' A_Traversal NoIx s a Source #
Type synonym for a type-preserving traversal.
(.~) :: forall k (is :: IxList) s t a b. Is k A_Setter => Optic k is s t a b -> b -> s -> t infixr 4 Source #
Infix version of set
.
(^?) :: forall k s (is :: IxList) a. Is k An_AffineFold => s -> Optic' k is s a -> Maybe a infixl 8 Source #
Flipped infix version of preview
.
(^.) :: forall k s (is :: IxList) a. Is k A_Getter => s -> Optic' k is s a -> a infixl 8 Source #
Flipped infix version of view
.
set' :: forall k (is :: IxList) s t a b. Is k A_Setter => Optic k is s t a b -> b -> s -> t Source #
Apply a setter, strictly.
TODO DOC: what exactly is the strictness property?
over' :: forall k (is :: IxList) s t a b. Is k A_Setter => Optic k is s t a b -> (a -> b) -> s -> t Source #
Apply a setter as a modifier, strictly.
TODO DOC: what exactly is the strictness property?
Example:
f :: Int -> (Int, a) -> (Int, a) f k acc | k > 0 = f (k - 1) $over'
_1
(+1) acc | otherwise = acc
runs in constant space, but would result in a space leak if used with over
.
Note that replacing $
with $!
or _1
with
_1'
(which amount to the same thing) doesn't help when
over
is used, because the first coordinate of a pair is never forced.
review :: forall k (is :: IxList) t b. Is k A_Review => Optic' k is t b -> b -> t Source #
Retrieve the value targeted by a Review
.
>>>
review _Left "hi"
Left "hi"
(%?) :: forall (is :: IxList) (js :: IxList) (ks :: IxList) k k' l m s t u v a b. (AppendIndices is js ks, JoinKinds k A_Prism k', JoinKinds k' l m) => Optic k is s t (Maybe u) (Maybe v) -> Optic l js u v a b -> Optic m ks s t a b infixl 9 Source #
preview :: forall k (is :: IxList) s a. Is k An_AffineFold => Optic' k is s a -> s -> Maybe a Source #
Retrieve the value targeted by an AffineFold
.
>>>
let _Right = prism Right $ either (Left . Left) Right
>>>
preview _Right (Right 'x')
Just 'x'
>>>
preview _Right (Left 'y')
Nothing
type AffineTraversal' s a = Optic' An_AffineTraversal NoIx s a Source #
Type synonym for a type-preserving affine traversal.
(%) :: forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a b. (JoinKinds k l m, AppendIndices is js ks) => Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b infixl 9 Source #
Compose two optics of compatible flavours.
Returns an optic of the appropriate supertype. If either or both optics are indexed, the composition preserves all the indices.
makeFieldLabelsNoPrefix :: Name -> DecsQ Source #
An alias for makeFieldLabels noPrefixFieldLabels
.
Generate a Prism
for each constructor of a data type. Isos generated when
possible. Reviews are created for constructors with existentially quantified
constructors and GADTs.
e.g.
data FooBarBaz a = Foo Int | Bar a | Baz Int Char makePrisms ''FooBarBaz
will create
_Foo :: Prism' (FooBarBaz a) Int _Bar :: Prism (FooBarBaz a) (FooBarBaz b) a b _Baz :: Prism' (FooBarBaz a) (Int, Char)
catchAny :: MonadCatch m => m a -> (SomeException -> m a) -> m a Source #
catch
specialized to catch all synchronous exception
Since: safe-exceptions-0.1.0.0
throwM :: (MonadThrow m, Exception e) => e -> m a Source #
Synonym for throw
Since: safe-exceptions-0.1.0.0
TBQueue
is an abstract type representing a bounded FIFO channel.
Since: stm-2.4
getArrayOf :: Decoder a -> Decoder [a] Source #
Decode a list of values using the given Decoder
.
[[a]] b = 1 [[a]] b = 2
-- MyConfig [1, 2] MyConfig <$> getFieldWith (getArrayOf (getField "b")) "a"
getFieldOptWith :: Decoder a -> Text -> Decoder (Maybe a) Source #
Same as getFieldOpt
, except with the given Decoder
.
getFieldOpt :: DecodeTOML a => Text -> Decoder (Maybe a) Source #
Decode a field in a TOML Value, or Nothing if the field doesn't exist.
Equivalent to getFieldsOpt
with a single-element list.
a = 1
-- MyConfig (Just 1) Nothing MyConfig <$> getFieldOpt "a" <*> getFieldOpt "b"
getField :: DecodeTOML a => Text -> Decoder a Source #
Decode a field in a TOML Value.
Equivalent to getFields
with a single-element list.
a = 1
b = asdf
-- MyConfig 1 "asdf" MyConfig <$> getField "a" <*> getField "b"
typeMismatch :: Value -> DecodeM a Source #
Throw an error indicating that the given Value
isn't the correct type of value.
makeDecoder $ \v -> case v of String s -> ... _ -> typeMismatch v
invalidValue :: Text -> Value -> DecodeM a Source #
Throw an error indicating that the given Value
is invalid.
makeDecoder $ \v -> case v of Integer 42 -> invalidValue "We don't like this number" v _ -> runDecoder tomlDecoder v -- or alternatively, tomlDecoder >>= case 42 -> makeDecoder $ invalidValue "We don't like this number" v -> pure v
makeDecoder :: (Value -> DecodeM a) -> Decoder a Source #
Manually implement a Decoder
with the given function.
A Decoder a
represents a function for decoding a TOML value to a value of type a
.
Generally, you'd only need to chain the getField*
functions together, like
decoder = MyConfig <$> getField "a" <*> getField "b" <*> getField "c"
or use interfaces like Monad
and Alternative
:
decoder = do cfgType <- getField "type" case cfgType of "int" -> MyIntValue <$> (getField "int" <|> getField "integer") "bool" -> MyBoolValue <$> getField "bool" _ -> fail $ "Invalid type: " <> cfgType
but you can also manually implement a Decoder
with makeDecoder
.
class DecodeTOML a where Source #
A type class containing the default Decoder
for the given type.
See the docs for Decoder
for examples.
Methods
tomlDecoder :: Decoder a Source #
Instances
renderTOMLError :: TOMLError -> Text Source #
Instances
class Monad m => MonadAsync (m :: Type -> Type) #
Minimal complete definition
async, asyncBound, asyncOn, asyncWithUnmask, asyncOnWithUnmask, withAsync, withAsyncBound, withAsyncOn, withAsyncWithUnmask, withAsyncOnWithUnmask, linkOnly, link2Only, race, concurrently, concurrently_
Instances
class Monad m => MonadThread (m :: Type -> Type) #
Minimal complete definition
threadDelay, throwTo, getNumCapabilities, setNumCapabilities, threadCapability
Instances
MonadThread IO | |
Defined in Effects.Concurrent.Thread Methods threadDelay :: Int -> IO () throwTo :: (Exception e, HasCallStack) => ThreadId -> e -> IO () setNumCapabilities :: Int -> IO () threadCapability :: ThreadId -> IO (Int, Bool) | |
MonadThread m => MonadThread (NaviT e m) Source # | |
Defined in Navi.NaviT Methods threadDelay :: Int -> NaviT e m () throwTo :: (Exception e0, HasCallStack) => ThreadId -> e0 -> NaviT e m () getNumCapabilities :: NaviT e m Int setNumCapabilities :: Int -> NaviT e m () threadCapability :: ThreadId -> NaviT e m (Int, Bool) | |
MonadThread m => MonadThread (ReaderT e m) | |
Defined in Effects.Concurrent.Thread Methods threadDelay :: Int -> ReaderT e m () throwTo :: (Exception e0, HasCallStack) => ThreadId -> e0 -> ReaderT e m () getNumCapabilities :: ReaderT e m Int setNumCapabilities :: Int -> ReaderT e m () threadCapability :: ThreadId -> ReaderT e m (Int, Bool) |
class Monad m => MonadSTM (m :: Type -> Type) #
Minimal complete definition
atomically
Instances
MonadSTM IO | |
Defined in Effects.Concurrent.STM Methods atomically :: HasCallStack => STM a -> IO a | |
MonadSTM m => MonadSTM (NaviT e m) Source # | |
Defined in Navi.NaviT Methods atomically :: HasCallStack => STM a -> NaviT e m a | |
MonadSTM m => MonadSTM (ReaderT e m) | |
Defined in Effects.Concurrent.STM Methods atomically :: HasCallStack => STM a -> ReaderT e m a |
class Monad m => MonadIORef (m :: Type -> Type) where #
Minimal complete definition
newIORef, readIORef, writeIORef, atomicWriteIORef, modifyIORef', atomicModifyIORef'
Methods
newIORef :: HasCallStack => a -> m (IORef a) #
readIORef :: HasCallStack => IORef a -> m a #
writeIORef :: HasCallStack => IORef a -> a -> m () #
modifyIORef' :: HasCallStack => IORef a -> (a -> a) -> m () #
Instances
newTBQueueM :: (HasCallStack, MonadSTM m) => Natural -> m (TBQueue a) #
readTBQueueM :: (HasCallStack, MonadSTM m) => TBQueue a -> m a #
tryReadTBQueueM :: (HasCallStack, MonadSTM m) => TBQueue a -> m (Maybe a) #
writeTBQueueM :: (HasCallStack, MonadSTM m) => TBQueue a -> a -> m () #
addCS :: (HasCallStack, MonadCatch m) => m a -> m a #
catchWithCS :: forall m e a. (Exception e, HasCallStack, MonadCatch m) => m a -> (e -> m a) -> m a #
throwWithCS :: forall m e a. (Exception e, HasCallStack, MonadThrow m) => e -> m a #
readFileUtf8ThrowM :: (HasCallStack, MonadFileReader m, MonadThrow m) => Path -> m Text #
class Monad m => MonadFileReader (m :: Type -> Type) #
Minimal complete definition
readBinaryFile
Instances
MonadFileReader IO | |
Defined in Effects.FileSystem.FileReader Methods readBinaryFile :: Path -> IO ByteString | |
MonadFileReader m => MonadFileReader (NaviT e m) Source # | |
Defined in Navi.NaviT Methods readBinaryFile :: Path -> NaviT e m ByteString | |
MonadFileReader m => MonadFileReader (ReaderT e m) | |
Defined in Effects.FileSystem.FileReader Methods readBinaryFile :: Path -> ReaderT e m ByteString |
writeFileUtf8 :: (HasCallStack, MonadFileWriter m) => Path -> Text -> m () #
class Monad m => MonadFileWriter (m :: Type -> Type) #
Minimal complete definition
writeBinaryFile, appendBinaryFile
Instances
MonadFileWriter IO | |
Defined in Effects.FileSystem.FileWriter Methods writeBinaryFile :: Path -> ByteString -> IO () appendBinaryFile :: Path -> ByteString -> IO () | |
MonadFileWriter m => MonadFileWriter (ReaderT env m) | |
Defined in Effects.FileSystem.FileWriter Methods writeBinaryFile :: Path -> ByteString -> ReaderT env m () appendBinaryFile :: Path -> ByteString -> ReaderT env m () |
class Monad m => MonadHandleWriter (m :: Type -> Type) where #
Minimal complete definition
openBinaryFile, withBinaryFile, hClose, hFlush, hSetFileSize, hSetBuffering, hSeek, hTell, hSetEcho, hPut, hPutNonBlocking
Instances
class Monad m => MonadPathReader (m :: Type -> Type) #
Minimal complete definition
listDirectory, getDirectoryContents, getCurrentDirectory, getHomeDirectory, getXdgDirectory, getXdgDirectoryList, getAppUserDataDirectory, getUserDocumentsDirectory, getTemporaryDirectory, getFileSize, canonicalizePath, makeAbsolute, makeRelativeToCurrentDirectory, doesPathExist, doesFileExist, doesDirectoryExist, findExecutable, findExecutables, findExecutablesInDirectories, findFileWith, findFilesWith, pathIsSymbolicLink, getSymbolicLinkTarget, getPermissions, getAccessTime, getModificationTime
Instances
class Monad m => MonadTerminal (m :: Type -> Type) where #
Minimal complete definition
(putStr | putBinary), getChar, getLine, getContents', getTerminalSize
Instances
MonadTerminal IO | |
MonadTerminal (NaviT env IO) Source # | |
MonadTerminal m => MonadTerminal (ReaderT e m) | |