Search results
sequence :: forall t a m. Traversable t => Applicative m => t (m a) -> m (t a)
sequence1 :: forall t b f. Traversable1 t => Apply f => t (f b) -> f (t b)
sequence1Default :: forall t a m. Traversable1 t => Apply m => t (m a) -> m (t a)
A default implementation of sequence1
using traverse1
.
sequenceDefault :: forall t a m. Traversable t => Applicative m => t (m a) -> m (t a)
A default implementation of sequence
using traverse
.
distribute :: forall f a g. Distributive f => Functor g => g (f a) -> f (g a)
distributeDefault :: forall a f g. Distributive f => Functor g => g (f a) -> f (g a)
A default implementation of distribute
, based on collect
.
parSequence :: forall a t m f. Parallel f m => Applicative f => Traversable t => t (m a) -> m (t a)
sequence :: forall m p q a. Dissect p q => MonadRec m => p (m a) -> m (p a)
A tail-recursive sequence
operation, implemented in terms of Dissect
.
sequence :: forall c b a. HasApply b => HasMap b => HasTraverse a => HasPure b => a (b c) -> b (a c)
Sequences actions and collects the results.
sequence [Just 1, Just 2] -- Just [1, 2]
join :: forall a m. Bind m => m (m a) -> m a
Collapse two applications of a monadic type constructor into one.
optional :: forall f a. Alt f => Applicative f => f a -> f (Maybe a)
One or none.
optional empty = pure Nothing
The behaviour of optional (pure x)
depends on whether the Alt
instance
satisfy the left catch law (pure a <|> b = pure a
).
Either e
does:
optional (Right x) = Right (Just x)
But Array
does not:
optional [x] = [Just x, Nothing]
oneOf :: forall f g a. Foldable f => Plus g => f (g a) -> g a
Combines a collection of elements using the Alt
operation.
genMaybe :: forall m a. MonadGen m => m a -> m (Maybe a)
Creates a generator that outputs Maybe
values, choosing a value from
another generator for the inner value. The generator has a 75% chance of
returning a Just
over a Nothing
.
oneOf :: forall m f a. MonadGen m => Foldable1 f => f (m a) -> m a
Creates a generator that outputs a value chosen from a selection of existing generators with uniform probability.
parOneOf :: forall a t m f. Parallel f m => Alternative f => Foldable t => Functor t => t (m a) -> m a
Race a collection in parallel.
wrapFree :: forall f m a. MonadFree f m => f (m a) -> m a
keepLatest :: forall event a. IsEvent event => event (event a) -> event a
optional :: forall f a. Alt f => Applicative f => f a -> f (Maybe a)
keepLatest :: forall event a. IsEvent event => event (event a) -> event a
join :: forall v m c. HasBind c m => HasIdentity c => ObjectOf c (m v) => m (m v) -> m v
choice :: forall a g f. Foldable f => Alt g => Plus g => f (g a) -> g a
flatten :: forall b a. HasChain a => a (a b) -> a b
Removes a level of nesting from a container.
flatten [[1, 2], [3, 4]] -- [1, 2, 3, 4]
oneOf :: forall a m f. Foldable f => Alternative m => f (m a) -> m a
optionMaybe :: forall a m. Alternative m => m a -> m (Maybe a)
warbler :: forall m a. Bind m => m (m a) -> m a
W combinator - warbler - omega
MM
Λ a b . (a → a → b) → a → b
λ f x . f x x
integrateM :: forall a stM m base. Applicative base => MonadBaseControl base m stM => m (stM a) -> m a
Pack a state belonging to m
back into it, instead of throwing it away
restoreM :: forall base m stM a. MonadBaseControl base m stM => base (stM a) -> m a
duplicate :: forall a w. Extend w => w a -> w (w a)
Duplicate a comonadic context.
duplicate
is dual to Control.Bind.join
.
fromMaybe :: forall f a. Unfoldable f => Maybe a -> f a
Convert a Maybe to any Unfoldable, such as lists or arrays.
fromMaybe (Nothing :: Maybe Int) == []
fromMaybe (Just 1) == [1]
unfoldable :: forall m f a. MonadRec m => MonadGen m => Unfoldable f => m a -> m (f a)
Creates a generator that produces unfoldable structures based on an existing generator for the elements.
The size of the unfoldable will be determined by the current size state
for the generator. To generate an unfoldable structure of a particular
size, use the resize
function from the MonadGen
class first.
unwrapCofree :: forall f w a. ComonadCofree f w => w a -> f (w a)
fork :: forall f m a. MonadFork f m => m a -> m (f a)
suspend :: forall f m a. MonadFork f m => m a -> m (f a)
toBase :: forall b m a. MonadUnlift b m => m a -> m (b a)
Run the given action inside the base monad b
.
lift :: forall a g f. Applicative f => Applicative g => a -> f (g a)
split :: forall f a. Applicative f => f a -> f (f a)
pure :: forall f a. Applicative f => a -> f a
fromJust :: forall a. Partial => Maybe a -> a
A partial function that extracts the value from the Just
data
constructor. Passing Nothing
to fromJust
will throw an error at
runtime.
forever :: forall m a b. MonadRec m => m a -> m b
forever
runs an action indefinitely, using the MonadRec
instance to
ensure constant stack usage.
For example:
main = forever $ trace "Hello, World!"
singleton :: forall f a. Unfoldable1 f => a -> f a
Contain a single value. For example:
singleton "foo" == (NEL.singleton "foo" :: NEL.NonEmptyList String)
proof :: forall a b p. TypeEquals a b => p a -> p b
elements :: forall m f a. MonadGen m => Foldable1 f => f a -> m a
Creates a generator that outputs a value chosen from a selection with uniform probability.
downFrom :: forall a u. Enum a => Unfoldable u => a -> u a
Produces all predecessors of an Enum
value, excluding the start value.
downFromIncluding :: forall a u. Enum a => Unfoldable1 u => a -> u a
Produces all predecessors of an Enum
value, including the start value.
downFromIncluding top
will return all values in an Enum
, in reverse
order.
upFrom :: forall a u. Enum a => Unfoldable u => a -> u a
Produces all successors of an Enum
value, excluding the start value.
upFromIncluding :: forall a u. Enum a => Unfoldable1 u => a -> u a
Produces all successors of an Enum
value, including the start value.
upFromIncluding bottom
will return all values in an Enum
.
coerce :: forall f a b. Contravariant f => Functor f => f a -> f b
throwError :: forall e m a. MonadThrow e m => e -> m a
inj :: forall f g a. Inject f g => f a -> g a
join :: forall f m a. MonadFork f m => f a -> m a