Copyright | (c) Justin Le 2019 |
---|---|
License | BSD3 |
Maintainer | justin@jle.im |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- newtype ListF f a = ListF {
- runListF :: [f a]
- mapListF :: ([f a] -> [g b]) -> ListF f a -> ListF g b
- newtype NonEmptyF f a where
- NonEmptyF {
- runNonEmptyF :: NonEmpty (f a)
- pattern ProdNonEmpty :: (f :*: ListF f) a -> NonEmptyF f a
- NonEmptyF {
- mapNonEmptyF :: (NonEmpty (f a) -> NonEmpty (g b)) -> NonEmptyF f a -> NonEmptyF g b
- toListF :: NonEmptyF f ~> ListF f
- fromListF :: ListF f ~> (Proxy :+: NonEmptyF f)
- newtype MaybeF f a = MaybeF {}
- mapMaybeF :: (Maybe (f a) -> Maybe (g b)) -> MaybeF f a -> MaybeF g b
- listToMaybeF :: ListF f ~> MaybeF f
- maybeToListF :: MaybeF f ~> ListF f
- newtype MapF k f a = MapF {}
- newtype NEMapF k f a = NEMapF {}
ListF
A list of f a
s. Can be used to describe a product of many different
values of type f a
.
This is the Free Plus
.
Instances
Interpret ListF Source # | A free |
FreeOf Plus ListF Source # | |
Functor f => Functor (ListF f) Source # | |
Applicative f => Applicative (ListF f) Source # | |
Foldable f => Foldable (ListF f) Source # | |
Defined in Control.Applicative.ListF fold :: Monoid m => ListF f m -> m # foldMap :: Monoid m => (a -> m) -> ListF f a -> m # foldr :: (a -> b -> b) -> b -> ListF f a -> b # foldr' :: (a -> b -> b) -> b -> ListF f a -> b # foldl :: (b -> a -> b) -> b -> ListF f a -> b # foldl' :: (b -> a -> b) -> b -> ListF f a -> b # foldr1 :: (a -> a -> a) -> ListF f a -> a # foldl1 :: (a -> a -> a) -> ListF f a -> a # elem :: Eq a => a -> ListF f a -> Bool # maximum :: Ord a => ListF f a -> a # minimum :: Ord a => ListF f a -> a # | |
Traversable f => Traversable (ListF f) Source # | |
Applicative f => Alternative (ListF f) Source # | |
Eq1 f => Eq1 (ListF f) Source # | |
Ord1 f => Ord1 (ListF f) Source # | |
Defined in Control.Applicative.ListF | |
Read1 f => Read1 (ListF f) Source # | |
Defined in Control.Applicative.ListF | |
Show1 f => Show1 (ListF f) Source # | |
Apply f => Apply (ListF f) Source # | |
Pointed f => Pointed (ListF f) Source # | |
Defined in Control.Applicative.ListF | |
Functor f => Plus (ListF f) Source # | |
Defined in Control.Applicative.ListF | |
Functor f => Alt (ListF f) Source # | |
HBind ListF Source # | |
Inject ListF Source # | |
HFunctor ListF Source # | |
Eq (f a) => Eq (ListF f a) Source # | |
(Typeable f, Typeable a, Data (f a)) => Data (ListF f a) Source # | |
Defined in Control.Applicative.ListF gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ListF f a -> c (ListF f a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ListF f a) # toConstr :: ListF f a -> Constr # dataTypeOf :: ListF f a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ListF f a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ListF f a)) # gmapT :: (forall b. Data b => b -> b) -> ListF f a -> ListF f a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ListF f a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ListF f a -> r # gmapQ :: (forall d. Data d => d -> u) -> ListF f a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ListF f a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a) # | |
Ord (f a) => Ord (ListF f a) Source # | |
Defined in Control.Applicative.ListF | |
Read (f a) => Read (ListF f a) Source # | |
Show (f a) => Show (ListF f a) Source # | |
Generic (ListF f a) Source # | |
Semigroup (ListF f a) Source # | |
Monoid (ListF f a) Source # | |
type C ListF Source # | |
Defined in Data.HFunctor.Interpret | |
type Rep (ListF f a) Source # | |
Defined in Control.Applicative.ListF |
mapListF :: ([f a] -> [g b]) -> ListF f a -> ListF g b Source #
Map a function over the inside of a ListF
.
NonEmptyF
newtype NonEmptyF f a Source #
A non-empty list of f a
s. Can be used to describe a product between
many different possible values of type f a
.
Essentially:
NonEmptyF
f ~ f -- one f:+:
(f:*:
f) -- two f's :+: (f :*: f :*: f) -- three f's :+: (f :*: f :*: f :*: f) -- four f's :+: ... -- etc.
This is the Free Plus
.
NonEmptyF | |
|
pattern ProdNonEmpty :: (f :*: ListF f) a -> NonEmptyF f a | Treat a
|
Instances
mapNonEmptyF :: (NonEmpty (f a) -> NonEmpty (g b)) -> NonEmptyF f a -> NonEmptyF g b Source #
Map a function over the inside of a NonEmptyF
.
MaybeF
A maybe f a
.
Can be useful for describing a "an f a
that may or may not be there".
This is the free structure for a "fail"-like typeclass that would only
have zero :: f a
.
Instances
Interpret MaybeF Source # | Technically, |
Functor f => Functor (MaybeF f) Source # | |
Applicative f => Applicative (MaybeF f) Source # | |
Foldable f => Foldable (MaybeF f) Source # | |
Defined in Control.Applicative.ListF fold :: Monoid m => MaybeF f m -> m # foldMap :: Monoid m => (a -> m) -> MaybeF f a -> m # foldr :: (a -> b -> b) -> b -> MaybeF f a -> b # foldr' :: (a -> b -> b) -> b -> MaybeF f a -> b # foldl :: (b -> a -> b) -> b -> MaybeF f a -> b # foldl' :: (b -> a -> b) -> b -> MaybeF f a -> b # foldr1 :: (a -> a -> a) -> MaybeF f a -> a # foldl1 :: (a -> a -> a) -> MaybeF f a -> a # elem :: Eq a => a -> MaybeF f a -> Bool # maximum :: Ord a => MaybeF f a -> a # minimum :: Ord a => MaybeF f a -> a # | |
Traversable f => Traversable (MaybeF f) Source # | |
Defined in Control.Applicative.ListF | |
Applicative f => Alternative (MaybeF f) Source # | |
Eq1 f => Eq1 (MaybeF f) Source # | |
Ord1 f => Ord1 (MaybeF f) Source # | |
Defined in Control.Applicative.ListF | |
Read1 f => Read1 (MaybeF f) Source # | |
Defined in Control.Applicative.ListF | |
Show1 f => Show1 (MaybeF f) Source # | |
Pointed f => Pointed (MaybeF f) Source # | |
Defined in Control.Applicative.ListF | |
Functor f => Plus (MaybeF f) Source # | |
Defined in Control.Applicative.ListF | |
Functor f => Alt (MaybeF f) Source # | |
HBind MaybeF Source # | |
Inject MaybeF Source # | |
HFunctor MaybeF Source # | |
Eq (f a) => Eq (MaybeF f a) Source # | |
(Typeable f, Typeable a, Data (f a)) => Data (MaybeF f a) Source # | |
Defined in Control.Applicative.ListF gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MaybeF f a -> c (MaybeF f a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (MaybeF f a) # toConstr :: MaybeF f a -> Constr # dataTypeOf :: MaybeF f a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (MaybeF f a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (MaybeF f a)) # gmapT :: (forall b. Data b => b -> b) -> MaybeF f a -> MaybeF f a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MaybeF f a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MaybeF f a -> r # gmapQ :: (forall d. Data d => d -> u) -> MaybeF f a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> MaybeF f a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a) # | |
Ord (f a) => Ord (MaybeF f a) Source # | |
Read (f a) => Read (MaybeF f a) Source # | |
Show (f a) => Show (MaybeF f a) Source # | |
Generic (MaybeF f a) Source # | |
Semigroup (MaybeF f a) Source # | Picks the first |
Monoid (MaybeF f a) Source # | |
type C MaybeF Source # | |
Defined in Data.HFunctor.Interpret | |
type Rep (MaybeF f a) Source # | |
Defined in Control.Applicative.ListF |
mapMaybeF :: (Maybe (f a) -> Maybe (g b)) -> MaybeF f a -> MaybeF g b Source #
Map a function over the inside of a MaybeF
.
MapF
A map of f a
s, indexed by keys of type k
. It can be useful for
represeting a product of many different values of type f a
, each "at"
a different k
location.
Can be considered a combination of EnvT
and
ListF
, in a way --- a
is like a MapF
k f a
with unique (and ordered)
keys.ListF
(EnvT
k f) a
One use case might be to extend a schema with many "options", indexed by some string.
For example, if you had a command line argument parser for a single command
data Command a
Then you can represent a command line argument parser for multiple named commands with
type Commands =MapF
String
Command
See NEMapF
for a non-empty variant, if you want to enforce that your
bag has at least one f a
.
Instances
Monoid k => Interpret (MapF k) Source # | |
Monoid k => Inject (MapF k :: (Type -> Type) -> Type -> Type) Source # | Injects into a singleton map at |
HFunctor (MapF k :: (Type -> Type) -> Type -> Type) Source # | |
Functor f => Functor (MapF k f) Source # | |
Foldable f => Foldable (MapF k f) Source # | |
Defined in Control.Applicative.ListF fold :: Monoid m => MapF k f m -> m # foldMap :: Monoid m => (a -> m) -> MapF k f a -> m # foldr :: (a -> b -> b) -> b -> MapF k f a -> b # foldr' :: (a -> b -> b) -> b -> MapF k f a -> b # foldl :: (b -> a -> b) -> b -> MapF k f a -> b # foldl' :: (b -> a -> b) -> b -> MapF k f a -> b # foldr1 :: (a -> a -> a) -> MapF k f a -> a # foldl1 :: (a -> a -> a) -> MapF k f a -> a # elem :: Eq a => a -> MapF k f a -> Bool # maximum :: Ord a => MapF k f a -> a # minimum :: Ord a => MapF k f a -> a # | |
Traversable f => Traversable (MapF k f) Source # | |
Defined in Control.Applicative.ListF | |
(Eq k, Eq1 f) => Eq1 (MapF k f) Source # | |
(Ord k, Ord1 f) => Ord1 (MapF k f) Source # | |
Defined in Control.Applicative.ListF | |
(Ord k, Read k, Read1 f) => Read1 (MapF k f) Source # | |
Defined in Control.Applicative.ListF | |
(Show k, Show1 f) => Show1 (MapF k f) Source # | |
(Monoid k, Pointed f) => Pointed (MapF k f) Source # | |
Defined in Control.Applicative.ListF | |
(Functor f, Ord k) => Plus (MapF k f) Source # | |
Defined in Control.Applicative.ListF | |
(Functor f, Ord k) => Alt (MapF k f) Source # | Left-biased union |
(Eq k, Eq (f a)) => Eq (MapF k f a) Source # | |
(Typeable f, Typeable a, Data k, Data (f a), Ord k) => Data (MapF k f a) Source # | |
Defined in Control.Applicative.ListF gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MapF k f a -> c (MapF k f a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (MapF k f a) # toConstr :: MapF k f a -> Constr # dataTypeOf :: MapF k f a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (MapF k f a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (MapF k f a)) # gmapT :: (forall b. Data b => b -> b) -> MapF k f a -> MapF k f a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MapF k f a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MapF k f a -> r # gmapQ :: (forall d. Data d => d -> u) -> MapF k f a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> MapF k f a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a) # | |
(Ord k, Ord (f a)) => Ord (MapF k f a) Source # | |
(Ord k, Read k, Read (f a)) => Read (MapF k f a) Source # | |
(Show k, Show (f a)) => Show (MapF k f a) Source # | |
Generic (MapF k f a) Source # | |
(Ord k, Alt f) => Semigroup (MapF k f a) Source # | A union, combining matching keys with |
(Ord k, Alt f) => Monoid (MapF k f a) Source # | |
type C (MapF k) Source # | |
Defined in Data.HFunctor.Interpret | |
type Rep (MapF k f a) Source # | |
Defined in Control.Applicative.ListF |
A non-empty map of f a
s, indexed by keys of type k
. It can be
useful for represeting a product of many different values of type f a
,
each "at" a different k
location, where you need to have at least one
f a
at all times.
Can be considered a combination of EnvT
and
NonEmptyF
, in a way --- an
is like a NEMapF
k f a
with unique (and ordered)
keys.NonEmptyF
(EnvT
k f) a
See MapF
for some use cases.
Instances
Monoid k => Interpret (NEMapF k) Source # | |
Monoid k => Inject (NEMapF k :: (Type -> Type) -> Type -> Type) Source # | Injects into a singleton map at |
HFunctor (NEMapF k :: (Type -> Type) -> Type -> Type) Source # | |
Functor f => Functor (NEMapF k f) Source # | |
Foldable f => Foldable (NEMapF k f) Source # | |
Defined in Control.Applicative.ListF fold :: Monoid m => NEMapF k f m -> m # foldMap :: Monoid m => (a -> m) -> NEMapF k f a -> m # foldr :: (a -> b -> b) -> b -> NEMapF k f a -> b # foldr' :: (a -> b -> b) -> b -> NEMapF k f a -> b # foldl :: (b -> a -> b) -> b -> NEMapF k f a -> b # foldl' :: (b -> a -> b) -> b -> NEMapF k f a -> b # foldr1 :: (a -> a -> a) -> NEMapF k f a -> a # foldl1 :: (a -> a -> a) -> NEMapF k f a -> a # toList :: NEMapF k f a -> [a] # null :: NEMapF k f a -> Bool # length :: NEMapF k f a -> Int # elem :: Eq a => a -> NEMapF k f a -> Bool # maximum :: Ord a => NEMapF k f a -> a # minimum :: Ord a => NEMapF k f a -> a # | |
Traversable f => Traversable (NEMapF k f) Source # | |
Defined in Control.Applicative.ListF | |
(Eq k, Eq1 f) => Eq1 (NEMapF k f) Source # | |
(Ord k, Ord1 f) => Ord1 (NEMapF k f) Source # | |
Defined in Control.Applicative.ListF | |
(Ord k, Read k, Read1 f) => Read1 (NEMapF k f) Source # | |
Defined in Control.Applicative.ListF | |
(Show k, Show1 f) => Show1 (NEMapF k f) Source # | |
Foldable1 f => Foldable1 (NEMapF k f) Source # | |
(Monoid k, Pointed f) => Pointed (NEMapF k f) Source # | |
Defined in Control.Applicative.ListF | |
Traversable1 f => Traversable1 (NEMapF k f) Source # | |
(Functor f, Ord k) => Alt (NEMapF k f) Source # | Left-biased union |
(Eq k, Eq (f a)) => Eq (NEMapF k f a) Source # | |
(Typeable f, Typeable a, Data k, Data (f a), Ord k) => Data (NEMapF k f a) Source # | |
Defined in Control.Applicative.ListF gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NEMapF k f a -> c (NEMapF k f a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (NEMapF k f a) # toConstr :: NEMapF k f a -> Constr # dataTypeOf :: NEMapF k f a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (NEMapF k f a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (NEMapF k f a)) # gmapT :: (forall b. Data b => b -> b) -> NEMapF k f a -> NEMapF k f a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NEMapF k f a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NEMapF k f a -> r # gmapQ :: (forall d. Data d => d -> u) -> NEMapF k f a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> NEMapF k f a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a) # | |
(Ord k, Ord (f a)) => Ord (NEMapF k f a) Source # | |
Defined in Control.Applicative.ListF | |
(Ord k, Read k, Read (f a)) => Read (NEMapF k f a) Source # | |
(Show k, Show (f a)) => Show (NEMapF k f a) Source # | |
Generic (NEMapF k f a) Source # | |
(Ord k, Alt f) => Semigroup (NEMapF k f a) Source # | A union, combining matching keys with |
type C (NEMapF k) Source # | |
Defined in Data.HFunctor.Interpret | |
type Rep (NEMapF k f a) Source # | |
Defined in Control.Applicative.ListF |