Safe Haskell | None |
---|---|
Language | Haskell98 |
Documentation
class (Applicative f, Applicative g) => Idiom tag f g where Source #
An Idiom
captures an "applicative homomorphism" between two
applicatives, indexed by a tag
.
An appliative homomorphism is a polymorphic function between two
applicative functors that preserves the Applicative
structure.
idiom (pure a) = pure a idiom (liftA2 (·) as bs) = liftA2 (·) (idiom as) (idiom bs)
Based on: Abstracting with Applicatives.
Instances
The identity applicative morphism.
idiom :: f ~> f idiom = id
Instances
(Applicative f, f ~ g) => Idiom Id f g Source # | |
Defined in Generic.Applicative.Idiom |
The initial applicative morphism.
It turns Identity
into any Applicative
functor.
idiom :: Identity ~> f idiom (Identity a) = pure a
The terminal applicative morphism.
It turns any applicative into
, or Const
mProxy
idiom :: f ~> Const m idiom _ = Const mempty idiom :: f ~> Proxy idiom _ = Proxy
Instances
This applicative morphism composes a functor on the _inside_.
idiom :: f ~> Compose f inner idiom = Compose . fmap pure
Instances
(Applicative f, Applicative inner, comp ~ Compose f inner) => Idiom Inner f comp Source # | |
Defined in Generic.Applicative.Idiom |
This applicative morphism composes a functor on the _outside_.
idiom :: f ~> Compose outer f idiom = Compose . pure
Instances
(Applicative outer, Applicative f, comp ~ Compose outer f) => Idiom Outer f comp Source # | |
Defined in Generic.Applicative.Idiom |
This applicative morphism duplicates a functor any number of times.
idiom :: f ~> f idiom = id idiom :: f ~> Product f f idiom as = Pair as as idiom :: f ~> Product f (Product f f) idiom as = Pair as (Pair as as)
Instances
(Applicative f, Applicative g, IdiomDup (CheckIdiomDup g) f g) => Idiom Dup f g Source # | |
Defined in Generic.Applicative.Idiom |
An applicative functor for constructing a product.
idiom :: f ~> Product g h idiom as = Pair (idiom as) (idiom as)
The applicative functor that gets the first component of a product.
idiom :: Product f g ~> f idiom (Pair as _) = as
Instances
(Applicative f, Applicative g) => Idiom Fst (Product f g) f Source # | |