Control.Select
- Package
- purescript-selective-functors
- Repository
- artemisSystem/purescript-selective-functors
#Select Source
class Select :: (Type -> Type) -> Constraint
class (Apply f) <= Select f where
Select
is an abstraction that sits between Apply
and Bind
.
Instances must satisfy the following law:
- Associativity:
x <*? (y <*? z) = ((map Right <$> x) <*? (f <$> y)) <*? uncurry z
where
f (Left y) x = Tuple y x
f (Right y) x = y x
Members
Instances
Select Array
Select NonEmptyArray
Select List
Select NonEmptyList
Select List
Select NonEmptyList
Select Maybe
Select (Function r)
Select (Either e)
Select Effect
Select Aff
Select Identity
Select (ST h)
Select Lazy
Select (Free f)
Select (Run r)
(Semigroup w) => Select (Tuple w)
(Select f, Select g) => Select (Product f g)
(Select f) => Select (IdentityT f)
(Select f) => Select (ReaderT r f)
(Select f, Semigroup w) => Select (WriterT w f)
(Monad f, Monoid w) => Select (RWST r w s f)
(Apply f) => Select (ContT r f)
(Monad f) => Select (ExceptT e f)
(Monad f) => Select (StateT s f)
This instance requires the inner type to be a
Monad
, because theApply
instance requires it.(Monad f) => Select (ListT f)
This instance requires the inner type to be a
Monad
, because theApply
instance requires it.(Monad f) => Select (MaybeT f)
This instance requires the inner type to be a
Monad
, because theApply
instance requires it.Select (ReaderT r f)
Select (StateT s f)
(Monoid w) => Select (WriterT w f)
(Monoid w) => Select (RWSET r w s e f)
#selectTM Source
selectTM :: forall @t @a @b. Traversable t => t (Either a b) -> t (a -> b) -> t b
select
implemented in terms of sequence
. With this implementation,
depending on the Either
in the first argument, the first or the second
effect will be executed, but never both. Traversable
allows us to
inspect the Either
in the first parameter without including its effect
in the result. This implementation is well suited for array-like
traversables. (i.e. potentially containing more than one element)
#selectTS Source
selectTS :: forall @f @a @b. Traversable f => Apply f => f (Either a b) -> f (a -> b) -> f b
select
implemented in terms of sequence
and apply
. This
implementation uses apply
to keep the effects of the first parameter
when it is a Left
, unlike selectTM
. This implementation is well suited
for tuple-like traversables (i.e. containing one or fewer elements)
#fromMaybeS Source
fromMaybeS :: forall @f @a. Select f => f a -> f (Maybe a) -> f a
If the second action is Nothing
, run and return the first
- Modules
- Control.
Select - Control.
Selective - Control.
Selective. ComposeI - Control.
Selective. ComposeTM - Control.
Selective. ComposeTS - Control.
Selective. Free - Control.
Selective. Over - Control.
Selective. SelectA - Control.
Selective. SelectM - Control.
Selective. SelectTM - Control.
Selective. SelectTS - Control.
Selective. Under - Control.
Selective. Validation
This instance requires the inner type to be a
Monad
, because theApply
instance requires it.