functor-combinators-0.4.1.2: Tools for functor combinator-based program design
Copyright(c) Justin Le 2019
LicenseBSD3
Maintainerjustin@jle.im
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.HFunctor.Interpret

Contents

Description

This module provides tools for working with unary functor combinators that represent interpretable schemas.

These are types t that take a functor f and return a new functor t f, enhancing f with new structure and abilities.

For these, we have:

inject :: f a -> t f a

which lets you "lift" an f a into its transformed version, and also:

interpret
    :: C t g
    => (forall x. f a -> g a)
    -> t f a
    -> g a

that lets you "interpret" a t f a into a context g a, essentially "running" the computaiton that it encodes. The context is required to have a typeclass constraints that reflects what is "required" to be able to run a functor combinator.

Every single instance provides different tools. Check out the instance list for a nice list of useful combinators, or also the README for a high-level rundown.

See Data.Functor.Tensor for binary functor combinators that mix together two or more different functors.

Synopsis

Documentation

class Inject t => Interpret t f where Source #

An Interpret lets us move in and out of the "enhanced" Functor (t f) and the functor it enhances (f). An instance Interpret t f means we have t f a -> f a.

For example, Free f is f enhanced with monadic structure. We get:

inject    :: f a -> Free f a
interpret :: Monad m => (forall x. f x -> m x) -> Free f a -> m a

inject will let us use our f inside the enhanced Free f. interpret will let us "extract" the f from a Free f if we can give an interpreting function that interprets f into some target Monad.

We enforce that:

interpret id . inject == id
-- or
retract . inject == id

That is, if we lift a value into our structure, then immediately interpret it out as itself, it should lave the value unchanged.

Note that instances of this class are intended to be written with t as a fixed type constructor, and f to be allowed to vary freely:

instance Monad f => Interpret Free f

Any other sort of instance and it's easy to run into problems with type inference. If you want to write an instance that's "polymorphic" on tensor choice, use the WrapHF newtype wrapper over a type variable, where the second argument also uses a type constructor:

instance Interpret (WrapHF t) (MyFunctor t)

This will prevent problems with overloaded instances.

Minimal complete definition

retract | interpret

Methods

retract :: t f ~> f Source #

Remove the f out of the enhanced t f structure, provided that f satisfies the necessary constraints. If it doesn't, it needs to be properly interpreted out.

interpret :: (g ~> f) -> t g ~> f Source #

Given an "interpeting function" from f to g, interpret the f out of the t f into a final context g.

Instances

Instances details
Alternative f => Interpret Alt (f :: Type -> Type) Source #

A free Alternative

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Alt f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Alt g ~> f Source #

Applicative f => Interpret Ap (f :: Type -> Type) Source #

A free Applicative

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Ap f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Ap g ~> f Source #

Applicative f => Interpret Ap (f :: Type -> Type) Source #

A free Applicative

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Ap f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Ap g ~> f Source #

Applicative f => Interpret Ap (f :: Type -> Type) Source #

A free Applicative

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Ap f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Ap g ~> f Source #

Monad f => Interpret Free (f :: Type -> Type) Source #

A free Monad

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Free f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Free g ~> f Source #

Bind f => Interpret Free1 (f :: Type -> Type) Source #

A free Bind

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Free1 f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Free1 g ~> f Source #

Apply f => Interpret Ap1 (f :: Type -> Type) Source # 
Instance details

Defined in Data.Functor.Apply.Free

Methods

retract :: Ap1 f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Ap1 g ~> f Source #

Conclude f => Interpret Dec (f :: Type -> Type) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

retract :: Dec f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Dec g ~> f Source #

Decide f => Interpret Dec1 (f :: Type -> Type) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

retract :: Dec1 f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Dec1 g ~> f Source #

Divisible f => Interpret Div (f :: Type -> Type) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

retract :: Div f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Div g ~> f Source #

Divise f => Interpret Div1 (f :: Type -> Type) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

retract :: Div1 f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Div1 g ~> f Source #

Inplus f => Interpret DecAlt (f :: Type -> TYPE LiftedRep) Source #

A free Inplus

Instance details

Defined in Data.HFunctor.Chain.Internal

Methods

retract :: DecAlt f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> DecAlt g ~> f Source #

Inalt f => Interpret DecAlt1 (f :: Type -> TYPE LiftedRep) Source #

A free Inalt

Instance details

Defined in Data.HFunctor.Chain.Internal

Methods

retract :: DecAlt1 f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> DecAlt1 g ~> f Source #

Contravariant f => Interpret Coyoneda (f :: Type -> Type) Source #

A free Contravariant

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Coyoneda f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Coyoneda g ~> f Source #

Functor f => Interpret Coyoneda (f :: Type -> Type) Source #

A free Functor

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Coyoneda f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Coyoneda g ~> f Source #

Pointed f => Interpret MaybeApply (f :: Type -> Type) Source #

A free Pointed

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: MaybeApply f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> MaybeApply g ~> f Source #

Interpret WrappedApplicative (f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: WrappedApplicative f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> WrappedApplicative g ~> f Source #

Pointed f => Interpret Lift (f :: Type -> Type) Source #

A free Pointed

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Lift f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Lift g ~> f Source #

Monoid e => Interpret (EnvT e :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) Source #

This ignores the environment, so interpret /= hbind

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: EnvT e f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> EnvT e g ~> f Source #

Plus f => Interpret (ListF :: (Type -> Type) -> Type -> TYPE LiftedRep) (f :: Type -> Type) Source #

A free Plus

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: ListF f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> ListF g ~> f Source #

Plus f => Interpret (MaybeF :: (Type -> Type) -> Type -> TYPE LiftedRep) (f :: Type -> Type) Source #

Technically, f is over-constrained: we only need zero :: f a, but we don't really have that typeclass in any standard hierarchies. We use Plus here instead, but we never use <!>. This would only go wrong in situations where your type supports zero but not <!>, like instances of MonadFail without MonadPlus.

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: MaybeF f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> MaybeF g ~> f Source #

Alt f => Interpret (NonEmptyF :: (Type -> Type) -> Type -> TYPE LiftedRep) (f :: Type -> Type) Source #

A free Alt

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: NonEmptyF f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> NonEmptyF g ~> f Source #

Alt f => Interpret (Steps :: (Type -> TYPE LiftedRep) -> Type -> TYPE LiftedRep) (f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Steps f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Steps g ~> f Source #

Monoid a => Interpret (Post a :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Route

Methods

retract :: Post a f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Post a g ~> f Source #

Interpret t f => Interpret (PostT t :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) Source #

Since: 0.3.4.2

Instance details

Defined in Data.HFunctor.Route

Methods

retract :: PostT t f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> PostT t g ~> f Source #

a ~ Void => Interpret (Pre a :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Route

Methods

retract :: Pre a f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Pre a g ~> f Source #

Interpret t f => Interpret (PreT t :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Route

Methods

retract :: PreT t f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> PreT t g ~> f Source #

Plus f => Interpret (These1 g :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) Source #

Technically, f is over-constrained: we only need zero :: f a, but we don't really have that typeclass in any standard hierarchies. We use Plus here instead, but we never use <!>. This would only go wrong in situations where your type supports zero but not <!>, like instances of MonadFail without MonadPlus.

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: These1 g f ~> f Source #

interpret :: forall (g0 :: k -> Type). (g0 ~> f) -> These1 g g0 ~> f Source #

MonadReader r f => Interpret (ReaderT r :: (Type -> Type) -> Type -> TYPE LiftedRep) (f :: Type -> Type) Source #

A free MonadReader, but only when applied to a Monad.

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: ReaderT r f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> ReaderT r g ~> f Source #

Interpret (Flagged :: (k -> Type) -> k -> Type) (f :: k -> Type) Source #

Equivalent to instance for EnvT Any and HLift IdentityT.

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Flagged f ~> f Source #

interpret :: forall (g :: k0 -> Type). (g ~> f) -> Flagged g ~> f Source #

Interpret (Step :: (k -> Type) -> k -> Type) (f :: k -> Type) Source #

Equivalent to instance for EnvT (Sum Natural).

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Step f ~> f Source #

interpret :: forall (g :: k0 -> Type). (g ~> f) -> Step g ~> f Source #

Interpret (Backwards :: (k -> Type) -> k -> Type) (f :: k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Backwards f ~> f Source #

interpret :: forall (g :: k0 -> Type). (g ~> f) -> Backwards g ~> f Source #

Interpret (IdentityT :: (k -> Type) -> k -> Type) (f :: k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: IdentityT f ~> f Source #

interpret :: forall (g :: k0 -> Type). (g ~> f) -> IdentityT g ~> f Source #

Interpret (Reverse :: (k -> Type) -> k -> Type) (f :: k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Reverse f ~> f Source #

interpret :: forall (g :: k0 -> Type). (g ~> f) -> Reverse g ~> f Source #

Plus g => Interpret (Product g :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Product g f ~> f Source #

interpret :: forall (g0 :: k -> Type). (g0 ~> f) -> Product g g0 ~> f Source #

Plus f => Interpret (Sum g :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) Source #

Technically, f is over-constrained: we only need zero :: f a, but we don't really have that typeclass in any standard hierarchies. We use Plus here instead, but we never use <!>. This would only go wrong in situations where your type supports zero but not <!>, like instances of MonadFail without MonadPlus.

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: Sum g f ~> f Source #

interpret :: forall (g0 :: k -> Type). (g0 ~> f) -> Sum g g0 ~> f Source #

Plus g => Interpret ((:*:) g :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: (g :*: f) ~> f Source #

interpret :: forall (g0 :: k -> Type). (g0 ~> f) -> (g :*: g0) ~> f Source #

Plus f => Interpret ((:+:) g :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) Source #

Technically, f is over-constrained: we only need zero :: f a, but we don't really have that typeclass in any standard hierarchies. We use Plus here instead, but we never use <!>. This would only go wrong in situations where your type supports zero but not <!>, like instances of MonadFail without MonadPlus.

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: (g :+: f) ~> f Source #

interpret :: forall (g0 :: k -> Type). (g0 ~> f) -> (g :+: g0) ~> f Source #

(Monoid k, Plus f) => Interpret (MapF k :: (Type -> Type) -> Type -> TYPE LiftedRep) (f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: MapF k f ~> f Source #

interpret :: forall (g :: k0 -> Type). (g ~> f) -> MapF k g ~> f Source #

(Monoid k, Alt f) => Interpret (NEMapF k :: (Type -> TYPE LiftedRep) -> Type -> TYPE LiftedRep) (f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: NEMapF k f ~> f Source #

interpret :: forall (g :: k0 -> Type). (g ~> f) -> NEMapF k g ~> f Source #

SemigroupIn t f => Interpret (Chain1 t :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Chain

Methods

retract :: Chain1 t f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Chain1 t g ~> f Source #

(Interpret s f, Interpret t f) => Interpret (ComposeT s t :: (Type -> Type) -> Type -> TYPE LiftedRep) (f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: ComposeT s t f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> ComposeT s t g ~> f Source #

Interpret t f => Interpret (HFree t :: (k -> Type) -> k -> Type) (f :: k -> Type) Source #

Never uses inject

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: HFree t f ~> f Source #

interpret :: forall (g :: k0 -> Type). (g ~> f) -> HFree t g ~> f Source #

Interpret t f => Interpret (HLift t :: (k -> Type) -> k -> Type) (f :: k -> Type) Source #

Never uses inject

Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: HLift t f ~> f Source #

interpret :: forall (g :: k0 -> Type). (g ~> f) -> HLift t g ~> f Source #

c f => Interpret (Final c :: (k -> Type) -> k -> TYPE LiftedRep) (f :: k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Final

Methods

retract :: Final c f ~> f Source #

interpret :: forall (g :: k0 -> Type). (g ~> f) -> Final c g ~> f Source #

Interpret (M1 i c :: (k -> Type) -> k -> Type) (f :: k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

retract :: M1 i c f ~> f Source #

interpret :: forall (g :: k0 -> Type). (g ~> f) -> M1 i c g ~> f Source #

Interpret (RightF g :: (k2 -> Type) -> k2 -> Type) (f :: k2 -> Type) Source # 
Instance details

Defined in Data.HBifunctor

Methods

retract :: RightF g f ~> f Source #

interpret :: forall (g0 :: k -> Type). (g0 ~> f) -> RightF g g0 ~> f Source #

MonoidIn t i f => Interpret (Chain t i :: (Type -> Type) -> Type -> Type) (f :: Type -> Type) Source #

We can collapse and interpret an Chain t i if we have Tensor t.

Instance details

Defined in Data.HFunctor.Chain

Methods

retract :: Chain t i f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Chain t i g ~> f Source #

Inplicative f => Interpret DivAp (f :: Type -> TYPE LiftedRep) Source #

A free Inplicative

Instance details

Defined in Data.Functor.Invariant.Inplicative.Free

Methods

retract :: DivAp f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> DivAp g ~> f Source #

Inply f => Interpret DivAp1 (f :: Type -> TYPE LiftedRep) Source #

A free Inply

Instance details

Defined in Data.Functor.Invariant.Inplicative.Free

Methods

retract :: DivAp1 f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> DivAp1 g ~> f Source #

forI :: Interpret t f => t g a -> (g ~> f) -> f a Source #

A convenient flipped version of interpret.

Utilities

iget :: Interpret t (AltConst b) => (forall x. f x -> b) -> t f a -> b Source #

Useful wrapper over interpret to allow you to directly extract a value b out of the t f a, if you can convert f x into b.

Note that depending on the constraints on f in Interpret t f, you may have extra constraints on b.

For some constraints (like Monad), this will not be usable.

-- get the length of the Map String in the Step.
icollect length
     :: Step (Map String) Bool
     -> Int

Note that in many cases, you can also use hfoldMap and hfoldMap1.

Since: 0.3.1.0

icollect :: (forall m. Monoid m => Interpret t (AltConst m)) => (forall x. f x -> b) -> t f a -> [b] Source #

Useful wrapper over iget to allow you to collect a b from all instances of f inside a t f a.

Will work if there is an instance of Interpret t (AltConst m) if Monoid m, which will be the case if the constraint on the target functor is Functor, Apply, Applicative, Alt, Plus, Decide, Divisible, Decide, Conclude, or unconstrained.

-- get the lengths of all Map Strings in the Ap.
icollect length
     :: Ap (Map String) Bool
     -> [Int]

Note that in many cases, you can also use htoList.

Since: 0.3.1.0

icollect1 :: (forall m. Semigroup m => Interpret t (AltConst m)) => (forall x. f x -> b) -> t f a -> NonEmpty b Source #

Useful wrapper over iget to allow you to collect a b from all instances of f inside a t f a, into a non-empty collection of bs.

Will work if there is an instance of Interpret t (AltConst m) if Semigroup m, which will be the case if the constraint on the target functor is Functor, Apply, Alt, Divise, Decide, or unconstrained.

-- get the lengths of all Map Strings in the Ap.
icollect1 length
     :: Ap1 (Map String) Bool
     -> NonEmpty Int

Note that in many cases, you can also use htoNonEmpty.

Since: 0.3.1.0

itraverse :: (Functor h, Interpret t (Comp h (t g))) => (forall x. f x -> h (g x)) -> t f a -> h (t g a) Source #

Useful wrapper over interpret to allow you to do an "effectful" hmap.

This can be useful in some situations, but if you want to do this, it's probably better to just use htraverse, which is a more principled system for effectful hmapping.

Since: 0.3.6.0

iapply :: Interpret t (Op b) => (forall x. f x -> x -> b) -> t f a -> a -> b Source #

Useful wrapper over interpret to allow you to directly consume a value of type a with a t f a to create a b. Do this by supplying the method by which each component f x can consume an x. This works for contravariant functor combinators, where t f a can be interpreted as a consumer of as.

Note that depending on the constraints on f in Interpret t f, you may have extra constraints on b.

  • If f is unconstrained, Decide, or Conclude, there are no constraints on b. This will be the case for combinators like contravariant Coyoneda, Dec, Dec1.
  • If f must be Divise, b needs to be an instance of Semigroup. This will be the case for combinators like Div1.
  • If f is Divisible, b needs to be an instance of Monoid. This will be the case for combinators like Div.

For any Functor or Invariant constraint, this is not usable.

Since: 0.3.2.0

ifanout :: (forall m. Monoid m => Interpret t (Op m)) => (forall x. f x -> x -> b) -> t f a -> a -> [b] Source #

Useful wrapper over interpret to allow you to directly consume a value of type a with a t f a to create a b, and create a list of all the bs created by all the fs. Do this by supplying the method by which each component f x can consume an x. This works for contravariant functor combinators, where t f a can be interpreted as a consumer of as.

Will work if there is an instance of Interpret t (Op m) if Monoid m, which will be the case if the constraint on the target functor is Contravariant, Decide, Conclude, Divise, Divisible, or unconstrained.

Note that this is really only useful outside of iapply for Div and Div1, where a Div f which is a collection of many different fs consuming types of different values. You can use this with Dec and Dec1 and the contravarient Coyoneda as well, but those would always just give you a singleton list, so you might as well use iapply. This is really only here for completion alongside icollect, or if you define your own custom functor combinators.

ifanout1 :: (forall m. Semigroup m => Interpret t (Op m)) => (forall x. f x -> x -> b) -> t f a -> a -> NonEmpty b Source #

Useful wrapper over interpret to allow you to directly consume a value of type a with a t f a to create a b, and create a list of all the bs created by all the fs. Do this by supplying the method by which each component f x can consume an x. This works for contravariant functor combinators, where t f a can be interpreted as a consumer of as.

Will work if there is an instance of Interpret t (Op m) if Monoid m, which will be the case if the constraint on the target functor is Contravariant, Decide, Divise, or unconstrained.

Note that this is really only useful outside of iapply and ifanout for Div1, where a Div1 f which is a collection of many different fs consuming types of different values. You can use this with Dec and Dec1 and the contravarient Coyoneda as well, but those would always just give you a singleton list, so you might as well use iapply. This is really only here for completion alongside icollect1, or if you define your own custom functor combinators.

getI :: Interpret t (AltConst b) => (forall x. f x -> b) -> t f a -> b Source #

Deprecated: Use iget instead

(Deprecated) Old name for getI; will be removed in a future version.

collectI :: (forall m. Monoid m => Interpret t (AltConst m)) => (forall x. f x -> b) -> t f a -> [b] Source #

Deprecated: Use icollect instead

(Deprecated) Old name for icollect; will be removed in a future version.

newtype AltConst w a Source #

A version of Const that supports Alt, Plus, Decide, and Conclude instances. It does this by avoiding having an Alternative or Decidable instance, which causes all sorts of problems with the interactions between Alternative/Applicative and Decidable/Divisible.

Since: 0.3.1.0

Constructors

AltConst 

Fields

Instances

Instances details
Foldable (AltConst w :: TYPE LiftedRep -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

fold :: Monoid m => AltConst w m -> m #

foldMap :: Monoid m => (a -> m) -> AltConst w a -> m #

foldMap' :: Monoid m => (a -> m) -> AltConst w a -> m #

foldr :: (a -> b -> b) -> b -> AltConst w a -> b #

foldr' :: (a -> b -> b) -> b -> AltConst w a -> b #

foldl :: (b -> a -> b) -> b -> AltConst w a -> b #

foldl' :: (b -> a -> b) -> b -> AltConst w a -> b #

foldr1 :: (a -> a -> a) -> AltConst w a -> a #

foldl1 :: (a -> a -> a) -> AltConst w a -> a #

toList :: AltConst w a -> [a] #

null :: AltConst w a -> Bool #

length :: AltConst w a -> Int #

elem :: Eq a => a -> AltConst w a -> Bool #

maximum :: Ord a => AltConst w a -> a #

minimum :: Ord a => AltConst w a -> a #

sum :: Num a => AltConst w a -> a #

product :: Num a => AltConst w a -> a #

Eq w => Eq1 (AltConst w :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

liftEq :: (a -> b -> Bool) -> AltConst w a -> AltConst w b -> Bool #

Ord w => Ord1 (AltConst w :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

liftCompare :: (a -> b -> Ordering) -> AltConst w a -> AltConst w b -> Ordering #

Show w => Show1 (AltConst w :: TYPE LiftedRep -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> AltConst w a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [AltConst w a] -> ShowS #

Contravariant (AltConst w :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

contramap :: (a' -> a) -> AltConst w a -> AltConst w a' #

(>$) :: b -> AltConst w b -> AltConst w a #

Traversable (AltConst w :: TYPE LiftedRep -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

traverse :: Applicative f => (a -> f b) -> AltConst w a -> f (AltConst w b) #

sequenceA :: Applicative f => AltConst w (f a) -> f (AltConst w a) #

mapM :: Monad m => (a -> m b) -> AltConst w a -> m (AltConst w b) #

sequence :: Monad m => AltConst w (m a) -> m (AltConst w a) #

Monoid w => Applicative (AltConst w :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

pure :: a -> AltConst w a #

(<*>) :: AltConst w (a -> b) -> AltConst w a -> AltConst w b #

liftA2 :: (a -> b -> c) -> AltConst w a -> AltConst w b -> AltConst w c #

(*>) :: AltConst w a -> AltConst w b -> AltConst w b #

(<*) :: AltConst w a -> AltConst w b -> AltConst w a #

Functor (AltConst w :: TYPE LiftedRep -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

fmap :: (a -> b) -> AltConst w a -> AltConst w b #

(<$) :: a -> AltConst w b -> AltConst w a #

Monoid w => Divisible (AltConst w :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

divide :: (a -> (b, c)) -> AltConst w b -> AltConst w c -> AltConst w a #

conquer :: AltConst w a #

Monoid w => Conclude (AltConst w :: Type -> Type) Source #

Unlike for Const, this is possible because there is no Decidable instance to complicate things.

Instance details

Defined in Data.HFunctor.Interpret

Methods

conclude :: (a -> Void) -> AltConst w a Source #

Semigroup w => Decide (AltConst w :: Type -> Type) Source #

Unlike for Const, this is possible because there is no Decidable instance to complicate things.

Instance details

Defined in Data.HFunctor.Interpret

Methods

decide :: (a -> Either b c) -> AltConst w b -> AltConst w c -> AltConst w a Source #

Semigroup w => Divise (AltConst w :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

divise :: (a -> (b, c)) -> AltConst w b -> AltConst w c -> AltConst w a Source #

divised :: AltConst w a -> AltConst w b -> AltConst w (a, b) Source #

Invariant (AltConst w :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

invmap :: (a -> b) -> (b -> a) -> AltConst w a -> AltConst w b #

Semigroup w => Alt (AltConst w :: Type -> Type) Source #

Unlike for Const, this is possible because there is no Alternative instance to complicate things.

Instance details

Defined in Data.HFunctor.Interpret

Methods

(<!>) :: AltConst w a -> AltConst w a -> AltConst w a #

some :: Applicative (AltConst w) => AltConst w a -> AltConst w [a] #

many :: Applicative (AltConst w) => AltConst w a -> AltConst w [a] #

Semigroup w => Apply (AltConst w :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

(<.>) :: AltConst w (a -> b) -> AltConst w a -> AltConst w b #

(.>) :: AltConst w a -> AltConst w b -> AltConst w b #

(<.) :: AltConst w a -> AltConst w b -> AltConst w a #

liftF2 :: (a -> b -> c) -> AltConst w a -> AltConst w b -> AltConst w c #

Monoid w => Plus (AltConst w :: Type -> Type) Source #

Unlike for Const, this is possible because there is no Alternative instance to complicate things.

Instance details

Defined in Data.HFunctor.Interpret

Methods

zero :: AltConst w a #

(Typeable a, Typeable k, Data w) => Data (AltConst w a) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AltConst w a -> c (AltConst w a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (AltConst w a) #

toConstr :: AltConst w a -> Constr #

dataTypeOf :: AltConst w a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (AltConst w a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (AltConst w a)) #

gmapT :: (forall b. Data b => b -> b) -> AltConst w a -> AltConst w a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AltConst w a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AltConst w a -> r #

gmapQ :: (forall d. Data d => d -> u) -> AltConst w a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> AltConst w a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> AltConst w a -> m (AltConst w a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AltConst w a -> m (AltConst w a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AltConst w a -> m (AltConst w a) #

Generic (AltConst w a) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Associated Types

type Rep (AltConst w a) :: Type -> Type #

Methods

from :: AltConst w a -> Rep (AltConst w a) x #

to :: Rep (AltConst w a) x -> AltConst w a #

Show w => Show (AltConst w a) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

showsPrec :: Int -> AltConst w a -> ShowS #

show :: AltConst w a -> String #

showList :: [AltConst w a] -> ShowS #

Eq w => Eq (AltConst w a) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

(==) :: AltConst w a -> AltConst w a -> Bool #

(/=) :: AltConst w a -> AltConst w a -> Bool #

Ord w => Ord (AltConst w a) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

compare :: AltConst w a -> AltConst w a -> Ordering #

(<) :: AltConst w a -> AltConst w a -> Bool #

(<=) :: AltConst w a -> AltConst w a -> Bool #

(>) :: AltConst w a -> AltConst w a -> Bool #

(>=) :: AltConst w a -> AltConst w a -> Bool #

max :: AltConst w a -> AltConst w a -> AltConst w a #

min :: AltConst w a -> AltConst w a -> AltConst w a #

type Rep (AltConst w a) Source # 
Instance details

Defined in Data.HFunctor.Interpret

type Rep (AltConst w a) = D1 ('MetaData "AltConst" "Data.HFunctor.Interpret" "functor-combinators-0.4.1.2-6f83RuY9ReR1ECoC76WHzJ" 'True) (C1 ('MetaCons "AltConst" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAltConst") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 w)))

class (c a, d a) => AndC c d a Source #

A constraint on a for both c a and d a. Requiring AndC Show Eq a is the same as requiring (Show a, Eq a).

Instances

Instances details
(c a, d a) => AndC (c :: k -> Constraint) (d :: k -> Constraint) (a :: k) Source # 
Instance details

Defined in Data.HFunctor.Interpret

newtype WrapHF t f a Source #

A newtype wrapper meant to be used to define polymorphic Interpret instances. See documentation for Interpret for more information.

Please do not ever define an instance of Interpret "naked" on the second parameter:

instance Interpret (WrapHF t) f

As that would globally ruin everything using WrapHF.

Constructors

WrapHF 

Fields

Instances

Instances details
HFunctor t => HFunctor (WrapHF t :: (k -> Type) -> k1 -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

hmap :: forall (f :: k0 -> Type) (g :: k0 -> Type). (f ~> g) -> WrapHF t f ~> WrapHF t g Source #

HBind t => HBind (WrapHF t :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

hbind :: forall (f :: k0 -> Type) (g :: k0 -> Type). (f ~> WrapHF t g) -> WrapHF t f ~> WrapHF t g Source #

hjoin :: forall (f :: k0 -> Type). WrapHF t (WrapHF t f) ~> WrapHF t f Source #

Inject t => Inject (WrapHF t :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

inject :: forall (f :: k0 -> Type). f ~> WrapHF t f Source #

Foldable (t f) => Foldable (WrapHF t f) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

fold :: Monoid m => WrapHF t f m -> m #

foldMap :: Monoid m => (a -> m) -> WrapHF t f a -> m #

foldMap' :: Monoid m => (a -> m) -> WrapHF t f a -> m #

foldr :: (a -> b -> b) -> b -> WrapHF t f a -> b #

foldr' :: (a -> b -> b) -> b -> WrapHF t f a -> b #

foldl :: (b -> a -> b) -> b -> WrapHF t f a -> b #

foldl' :: (b -> a -> b) -> b -> WrapHF t f a -> b #

foldr1 :: (a -> a -> a) -> WrapHF t f a -> a #

foldl1 :: (a -> a -> a) -> WrapHF t f a -> a #

toList :: WrapHF t f a -> [a] #

null :: WrapHF t f a -> Bool #

length :: WrapHF t f a -> Int #

elem :: Eq a => a -> WrapHF t f a -> Bool #

maximum :: Ord a => WrapHF t f a -> a #

minimum :: Ord a => WrapHF t f a -> a #

sum :: Num a => WrapHF t f a -> a #

product :: Num a => WrapHF t f a -> a #

Eq1 (t f) => Eq1 (WrapHF t f) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

liftEq :: (a -> b -> Bool) -> WrapHF t f a -> WrapHF t f b -> Bool #

Ord1 (t f) => Ord1 (WrapHF t f) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

liftCompare :: (a -> b -> Ordering) -> WrapHF t f a -> WrapHF t f b -> Ordering #

Show1 (t f) => Show1 (WrapHF t f) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> WrapHF t f a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [WrapHF t f a] -> ShowS #

Traversable (t f) => Traversable (WrapHF t f) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

traverse :: Applicative f0 => (a -> f0 b) -> WrapHF t f a -> f0 (WrapHF t f b) #

sequenceA :: Applicative f0 => WrapHF t f (f0 a) -> f0 (WrapHF t f a) #

mapM :: Monad m => (a -> m b) -> WrapHF t f a -> m (WrapHF t f b) #

sequence :: Monad m => WrapHF t f (m a) -> m (WrapHF t f a) #

Functor (t f) => Functor (WrapHF t f) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

fmap :: (a -> b) -> WrapHF t f a -> WrapHF t f b #

(<$) :: a -> WrapHF t f b -> WrapHF t f a #

(Typeable f, Typeable a, Typeable t, Typeable k1, Typeable k2, Data (t f a)) => Data (WrapHF t f a) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> WrapHF t f a -> c (WrapHF t f a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (WrapHF t f a) #

toConstr :: WrapHF t f a -> Constr #

dataTypeOf :: WrapHF t f a -> DataType #

dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (WrapHF t f a)) #

dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (WrapHF t f a)) #

gmapT :: (forall b. Data b => b -> b) -> WrapHF t f a -> WrapHF t f a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> WrapHF t f a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> WrapHF t f a -> r #

gmapQ :: (forall d. Data d => d -> u) -> WrapHF t f a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> WrapHF t f a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> WrapHF t f a -> m (WrapHF t f a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> WrapHF t f a -> m (WrapHF t f a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> WrapHF t f a -> m (WrapHF t f a) #

Generic (WrapHF t f a) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Associated Types

type Rep (WrapHF t f a) :: Type -> Type #

Methods

from :: WrapHF t f a -> Rep (WrapHF t f a) x #

to :: Rep (WrapHF t f a) x -> WrapHF t f a #

Read (t f a) => Read (WrapHF t f a) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

readsPrec :: Int -> ReadS (WrapHF t f a) #

readList :: ReadS [WrapHF t f a] #

readPrec :: ReadPrec (WrapHF t f a) #

readListPrec :: ReadPrec [WrapHF t f a] #

Show (t f a) => Show (WrapHF t f a) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

showsPrec :: Int -> WrapHF t f a -> ShowS #

show :: WrapHF t f a -> String #

showList :: [WrapHF t f a] -> ShowS #

Eq (t f a) => Eq (WrapHF t f a) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

(==) :: WrapHF t f a -> WrapHF t f a -> Bool #

(/=) :: WrapHF t f a -> WrapHF t f a -> Bool #

Ord (t f a) => Ord (WrapHF t f a) Source # 
Instance details

Defined in Data.HFunctor.Interpret

Methods

compare :: WrapHF t f a -> WrapHF t f a -> Ordering #

(<) :: WrapHF t f a -> WrapHF t f a -> Bool #

(<=) :: WrapHF t f a -> WrapHF t f a -> Bool #

(>) :: WrapHF t f a -> WrapHF t f a -> Bool #

(>=) :: WrapHF t f a -> WrapHF t f a -> Bool #

max :: WrapHF t f a -> WrapHF t f a -> WrapHF t f a #

min :: WrapHF t f a -> WrapHF t f a -> WrapHF t f a #

type Rep (WrapHF t f a) Source # 
Instance details

Defined in Data.HFunctor.Interpret

type Rep (WrapHF t f a) = D1 ('MetaData "WrapHF" "Data.HFunctor.Interpret" "functor-combinators-0.4.1.2-6f83RuY9ReR1ECoC76WHzJ" 'True) (C1 ('MetaCons "WrapHF" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapHF") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (t f a))))