module Data.Functor.Combinator (
type (~>)
, type (<~>)
, HFunctor(..)
, Inject(..)
, Interpret(..)
, forI
, iget, icollect, icollect1
, iapply, ifanout, ifanout1
, getI, collectI
, injectMap, injectContramap
, AltConst(..)
, HTraversable(..), hsequence, hfoldMap, htoList
, HTraversable1(..), hsequence1, hfoldMap1, htoNonEmpty
, HBifunctor(..)
, Associative(..)
, SemigroupIn(..)
, biget, biapply
, (!*!)
, (!+!)
, (!$!)
, Tensor(..)
, MonoidIn(..)
, nilLB, consLB
, inL, inR
, outL, outR
, Coyoneda(..)
, ListF(..)
, NonEmptyF(..)
, MaybeF(..)
, MapF(..)
, NEMapF(..)
, Ap
, Ap1(..)
, Alt
, Free
, Free1
, Lift
, Step(..)
, Steps(..)
, ProxyF(..)
, ConstF(..)
, EnvT(..)
, ReaderT(..)
, Flagged(..)
, IdentityT(..)
, Void2
, Final(..)
, FreeOf(..)
, ComposeT(..)
, Day(..)
, (:*:)(..), prodOutL, prodOutR
, (:+:)(..), V1
, These1(..)
, Night(..), Not(..), refuted
, Comp(Comp, unComp)
, LeftF(..)
, RightF(..)
, HLift(..)
, HFree(..)
, generalize
, absorb
, dsum
, dsum1
, concludeN
, decideN
) where
import Control.Alternative.Free
import Control.Applicative.Free
import Control.Applicative.Lift
import Control.Applicative.ListF
import Control.Applicative.Step
import Control.Comonad.Trans.Env
import Control.Monad.Freer.Church
import Control.Monad.Trans.Compose
import Control.Monad.Trans.Identity
import Control.Monad.Trans.Reader
import Control.Natural
import Control.Natural.IsoF
import Data.Functor.Apply.Free
import Data.Functor.Contravariant
import Data.Functor.Contravariant.Conclude
import Data.Functor.Contravariant.Decide
import Data.Functor.Contravariant.Divise
import Data.Functor.Contravariant.Divisible
import Data.Functor.Coyoneda
import Data.Functor.Day
import Data.Functor.Invariant.Night
import Data.Functor.These
import Data.HBifunctor
import Data.HBifunctor.Associative
import Data.HBifunctor.Tensor
import Data.HFunctor
import Data.HFunctor.Final
import Data.HFunctor.HTraversable
import Data.HFunctor.Internal
import Data.HFunctor.Interpret
import GHC.Generics
import qualified Data.SOP as SOP
dsum
:: (Foldable t, Divisible f)
=> t (f a)
-> f a
dsum :: forall (t :: * -> *) (f :: * -> *) a.
(Foldable t, Divisible f) =>
t (f a) -> f a
dsum = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall (f :: * -> *) a b c.
Divisible f =>
(a -> (b, c)) -> f b -> f c -> f a
divide (\a
x -> (a
x,a
x))) forall (f :: * -> *) a. Divisible f => f a
conquer
concludeN
:: Conclude f
=> SOP.NP f as
-> f (SOP.NS SOP.I as)
concludeN :: forall (f :: * -> *) (as :: [*]).
Conclude f =>
NP f as -> f (NS I as)
concludeN = \case
NP f as
SOP.Nil -> forall (f :: * -> *) a. Conclude f => (a -> Void) -> f a
conclude (\case {})
f x
x SOP.:* NP f xs
xs -> forall (f :: * -> *) a b c.
Decide f =>
(a -> Either b c) -> f b -> f c -> f a
decide
(\case SOP.Z I x
y -> forall a b. a -> Either a b
Left (forall a. I a -> a
SOP.unI I x
y); SOP.S NS I xs
ys -> forall a b. b -> Either a b
Right NS I xs
ys)
f x
x
(forall (f :: * -> *) (as :: [*]).
Conclude f =>
NP f as -> f (NS I as)
concludeN NP f xs
xs)
decideN
:: Decide f
=> SOP.NP f (a ': as)
-> f (SOP.NS SOP.I (a ': as))
decideN :: forall (f :: * -> *) a (as :: [*]).
Decide f =>
NP f (a : as) -> f (NS I (a : as))
decideN = \case
f x
x SOP.:* NP f xs
xs -> case NP f xs
xs of
NP f xs
SOP.Nil -> forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap (forall a. I a -> a
SOP.unI forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (f :: k -> *) (x :: k). NS f '[x] -> f x
SOP.unZ) f x
x
f x
_ SOP.:* NP f xs
_ -> forall (f :: * -> *) a b c.
Decide f =>
(a -> Either b c) -> f b -> f c -> f a
decide
(\case SOP.Z I x
z -> forall a b. a -> Either a b
Left (forall a. I a -> a
SOP.unI I x
z); SOP.S NS I xs
zs -> forall a b. b -> Either a b
Right NS I xs
zs)
f x
x
(forall (f :: * -> *) a (as :: [*]).
Decide f =>
NP f (a : as) -> f (NS I (a : as))
decideN NP f xs
xs)