Copyright | (C) 2020 Aaron Allen |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Aaron Allen <aaronallen8455@gmail.com> |
Stability | provisional |
Portability | TypeFamilies, DataKinds, TypeApplications |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- liftAll :: forall s f g d n. (CountArgs f ~ n, Applicative g, EmbedDepth () s ~ d, ComposeUntil d s ~ g (), Applyable n d g f, Coercible s (g ())) => f -> App n d g f
- traverseAll :: forall s a b d f g res sa. (EmbedDepth () s ~ d, ComposeUntil d s ~ g (), FlattenUntil d (g b) ~ res, FlattenUntil d (g a) ~ sa, Applicative f, Traversable g, Coercible res (g b), Coercible sa (g a)) => (a -> f b) -> sa -> f res
- traverseAll_ :: forall s a b sa d f g. (EmbedDepth () s ~ d, ComposeUntil d s ~ g (), ComposeUntil d sa ~ g a, Foldable g, Applicative f, Coercible sa (g a)) => (a -> f b) -> sa -> f ()
- sequenceAll :: forall s a d f g res sfa. (EmbedDepth () s ~ d, ComposeUntil d s ~ g (), FlattenUntil d (g (f a)) ~ sfa, FlattenUntil d (g a) ~ res, Applicative f, Traversable g, Coercible sfa (g (f a)), Coercible res (g a)) => sfa -> f res
- sequenceAll_ :: forall s a d f g sfa. (EmbedDepth () s ~ d, ComposeUntil d s ~ g (), ComposeUntil d sfa ~ g (f a), Applicative f, Foldable g, Coercible sfa (g (f a))) => sfa -> f ()
- fmapAll :: forall s sa a b d f res. (EmbedDepth () s ~ d, FlattenUntil d (f b) ~ res, FlattenUntil d (f a) ~ sa, ComposeUntil d s ~ f (), Functor f, Coercible sa (f a), Coercible res (f b)) => (a -> b) -> sa -> res
- foldMapAll :: forall s sa a m d f. (EmbedDepth () s ~ d, ComposeUntil d sa ~ f a, Foldable f, Monoid m, Coercible sa (f a)) => (a -> m) -> sa -> m
- foldrAll :: forall s sa a b d f res. (EmbedDepth () s ~ d, ComposeUntil d sa ~ f a, Foldable f, Coercible sa (f a)) => (a -> b -> b) -> b -> sa -> b
- foldlAll :: forall s sa a b d f res. (EmbedDepth () s ~ d, ComposeUntil d sa ~ f a, Foldable f, Coercible sa (f a)) => (b -> a -> b) -> b -> sa -> b
- foldlAll' :: forall s sa a b d f res. (EmbedDepth () s ~ d, ComposeUntil d sa ~ f a, Foldable f, Coercible sa (f a)) => (b -> a -> b) -> b -> sa -> b
- concatAll :: forall s sa a b d f res. (EmbedDepth [()] s ~ d, ComposeUntil d sa ~ f [a], Foldable f, Coercible sa (f [a])) => sa -> [a]
- newtype Compose (f :: k -> *) (g :: k1 -> k) (a :: k1) :: forall k k1. (k -> *) -> (k1 -> k) -> k1 -> * = Compose {
- getCompose :: f (g a)
Documentation
liftAll :: forall s f g d n. (CountArgs f ~ n, Applicative g, EmbedDepth () s ~ d, ComposeUntil d s ~ g (), Applyable n d g f, Coercible s (g ())) => f -> App n d g f Source #
Lift any pure function over any Applicative
stack.
>>>
liftAll @[[()]] (+) [[1::Int]] [[2]]
[[3]]
>>>
liftAll @(Maybe [()]) (,,) (Just ["one"]) (Just ["two"]) (Just ["three", "four"])
Just [("one","two","three"),("one","two","four")]
traverseAll :: forall s a b d f g res sa. (EmbedDepth () s ~ d, ComposeUntil d s ~ g (), FlattenUntil d (g b) ~ res, FlattenUntil d (g a) ~ sa, Applicative f, Traversable g, Coercible res (g b), Coercible sa (g a)) => (a -> f b) -> sa -> f res Source #
Apply an Applicative
effect across any Traversable
stack.
>>>
traverseAll @(Maybe [()]) print (Just [1,2,3])
1 2 3 Just [(),(),()]
traverseAll_ :: forall s a b sa d f g. (EmbedDepth () s ~ d, ComposeUntil d s ~ g (), ComposeUntil d sa ~ g a, Foldable g, Applicative f, Coercible sa (g a)) => (a -> f b) -> sa -> f () Source #
Apply an Applicative
effect across any Foldable
stack, discarding the result.
>>>
traverseAll_ @[Maybe [()]] print [Just [1,2,3], Nothing, Just [4]]
1 2 3 4
sequenceAll :: forall s a d f g res sfa. (EmbedDepth () s ~ d, ComposeUntil d s ~ g (), FlattenUntil d (g (f a)) ~ sfa, FlattenUntil d (g a) ~ res, Applicative f, Traversable g, Coercible sfa (g (f a)), Coercible res (g a)) => sfa -> f res Source #
Run the Applicative
effects embedded in a Traversable
stack.
>>>
sequenceAll @[Maybe ()] [Just (print 1), Nothing, Just (print 2)]
1 2 [Just (), Nothing, Just ()]
sequenceAll_ :: forall s a d f g sfa. (EmbedDepth () s ~ d, ComposeUntil d s ~ g (), ComposeUntil d sfa ~ g (f a), Applicative f, Foldable g, Coercible sfa (g (f a))) => sfa -> f () Source #
Run the Applicative
effects embedded in a Foldable
stack, discarding the result.
>>>
sequenceAll_ @(Either () [()]) $ Right [print 1]
1
fmapAll :: forall s sa a b d f res. (EmbedDepth () s ~ d, FlattenUntil d (f b) ~ res, FlattenUntil d (f a) ~ sa, ComposeUntil d s ~ f (), Functor f, Coercible sa (f a), Coercible res (f b)) => (a -> b) -> sa -> res Source #
Map over any Functor
stack.
>>>
fmapAll @[Either String ()] (*2) [Right 3, Left "nope", Right 5]
[Right 6,Left "nope",Right 10]
foldMapAll :: forall s sa a m d f. (EmbedDepth () s ~ d, ComposeUntil d sa ~ f a, Foldable f, Monoid m, Coercible sa (f a)) => (a -> m) -> sa -> m Source #
Turn every embeded element of a Foldable
stack into a Monoid
then combine them.
>>>
foldMapAll @[Maybe[()]] Sum [Just [1,2,3], Nothing, Just [4,5]]
Sum {getSum = 15}
foldrAll :: forall s sa a b d f res. (EmbedDepth () s ~ d, ComposeUntil d sa ~ f a, Foldable f, Coercible sa (f a)) => (a -> b -> b) -> b -> sa -> b Source #
Right fold over any Foldable
stack.
>>>
foldrAll @[[()]] (\x acc -> acc ++ show x) [] [[1,2],[3]]
"321"
foldlAll :: forall s sa a b d f res. (EmbedDepth () s ~ d, ComposeUntil d sa ~ f a, Foldable f, Coercible sa (f a)) => (b -> a -> b) -> b -> sa -> b Source #
Left fold over any Foldable
stack.
>>>
foldlAll @[[()]] (\acc x -> acc ++ show x) [] [[1,2],[3]]
"123"
foldlAll' :: forall s sa a b d f res. (EmbedDepth () s ~ d, ComposeUntil d sa ~ f a, Foldable f, Coercible sa (f a)) => (b -> a -> b) -> b -> sa -> b Source #
Strict left fold over any Foldable
stack.
concatAll :: forall s sa a b d f res. (EmbedDepth [()] s ~ d, ComposeUntil d sa ~ f [a], Foldable f, Coercible sa (f [a])) => sa -> [a] Source #
Concatenates any Foldable
stack down to a list.
>>>
concatAll @(Maybe [[()]]) $ Just [[2], [3,4]]
[2,3,4]
newtype Compose (f :: k -> *) (g :: k1 -> k) (a :: k1) :: forall k k1. (k -> *) -> (k1 -> k) -> k1 -> * infixr 9 #
Right-to-left composition of functors. The composition of applicative functors is always applicative, but the composition of monads is not always a monad.
Compose infixr 9 | |
|
Instances
Functor f => Generic1 (Compose f g :: k -> *) | |
(Functor f, Functor g) => Functor (Compose f g) | Since: base-4.9.0.0 |
(Applicative f, Applicative g) => Applicative (Compose f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose | |
(Foldable f, Foldable g) => Foldable (Compose f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose fold :: Monoid m => Compose f g m -> m # foldMap :: Monoid m => (a -> m) -> Compose f g a -> m # foldr :: (a -> b -> b) -> b -> Compose f g a -> b # foldr' :: (a -> b -> b) -> b -> Compose f g a -> b # foldl :: (b -> a -> b) -> b -> Compose f g a -> b # foldl' :: (b -> a -> b) -> b -> Compose f g a -> b # foldr1 :: (a -> a -> a) -> Compose f g a -> a # foldl1 :: (a -> a -> a) -> Compose f g a -> a # toList :: Compose f g a -> [a] # null :: Compose f g a -> Bool # length :: Compose f g a -> Int # elem :: Eq a => a -> Compose f g a -> Bool # maximum :: Ord a => Compose f g a -> a # minimum :: Ord a => Compose f g a -> a # | |
(Traversable f, Traversable g) => Traversable (Compose f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose | |
(Eq1 f, Eq1 g) => Eq1 (Compose f g) | Since: base-4.9.0.0 |
(Ord1 f, Ord1 g) => Ord1 (Compose f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose | |
(Read1 f, Read1 g) => Read1 (Compose f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Compose f g a) # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Compose f g a] # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Compose f g a) # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Compose f g a] # | |
(Show1 f, Show1 g) => Show1 (Compose f g) | Since: base-4.9.0.0 |
(Alternative f, Applicative g) => Alternative (Compose f g) | Since: base-4.9.0.0 |
(Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) | Since: base-4.9.0.0 |
(Typeable a, Typeable f, Typeable g, Typeable k1, Typeable k2, Data (f (g a))) => Data (Compose f g a) | |
Defined in Data.Functor.Compose gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g0. g0 -> c g0) -> Compose f g a -> c (Compose f g a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Compose f g a) # toConstr :: Compose f g a -> Constr # dataTypeOf :: Compose f g a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Compose f g a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Compose f g a)) # gmapT :: (forall b. Data b => b -> b) -> Compose f g a -> Compose f g a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Compose f g a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Compose f g a -> r # gmapQ :: (forall d. Data d => d -> u) -> Compose f g a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Compose f g a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Compose f g a -> m (Compose f g a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Compose f g a -> m (Compose f g a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Compose f g a -> m (Compose f g a) # | |
(Ord1 f, Ord1 g, Ord a) => Ord (Compose f g a) | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose compare :: Compose f g a -> Compose f g a -> Ordering # (<) :: Compose f g a -> Compose f g a -> Bool # (<=) :: Compose f g a -> Compose f g a -> Bool # (>) :: Compose f g a -> Compose f g a -> Bool # (>=) :: Compose f g a -> Compose f g a -> Bool # | |
(Read1 f, Read1 g, Read a) => Read (Compose f g a) | Since: base-4.9.0.0 |
(Show1 f, Show1 g, Show a) => Show (Compose f g a) | Since: base-4.9.0.0 |
Generic (Compose f g a) | |
type Rep1 (Compose f g :: k -> *) | |
Defined in Data.Functor.Compose | |
type Rep (Compose f g a) | |
Defined in Data.Functor.Compose |