{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE Safe #-}
module Control.Applicative.Trans.Free
(
ApT(..)
, ApF(..)
, liftApT
, liftApO
, runApT
, runApF
, runApT_
, hoistApT
, hoistApF
, transApT
, transApF
, joinApT
, Ap
, runAp
, runAp_
, retractAp
, Alt
, runAlt
) where
import Control.Applicative
import Control.Monad (liftM)
import Data.Functor.Apply
import Data.Functor.Identity
data ApF f g a where
Pure :: a -> ApF f g a
Ap :: f a -> ApT f g (a -> b) -> ApF f g b
newtype ApT f g a = ApT { forall (f :: * -> *) (g :: * -> *) a. ApT f g a -> g (ApF f g a)
getApT :: g (ApF f g a) }
instance Functor g => Functor (ApF f g) where
fmap :: forall a b. (a -> b) -> ApF f g a -> ApF f g b
fmap a -> b
f (Pure a
a) = b -> ApF f g b
forall a (f :: * -> *) (g :: * -> *). a -> ApF f g a
Pure (a -> b
f a
a)
fmap a -> b
f (Ap f a
x ApT f g (a -> a)
g) = f a
x f a -> ApT f g (a -> b) -> ApF f g b
forall (f :: * -> *) a (g :: * -> *) b.
f a -> ApT f g (a -> b) -> ApF f g b
`Ap` ((a -> a) -> a -> b) -> ApT f g (a -> a) -> ApT f g (a -> b)
forall a b. (a -> b) -> ApT f g a -> ApT f g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a -> b
f (a -> b) -> (a -> a) -> a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) ApT f g (a -> a)
g
instance Functor g => Functor (ApT f g) where
fmap :: forall a b. (a -> b) -> ApT f g a -> ApT f g b
fmap a -> b
f (ApT g (ApF f g a)
g) = g (ApF f g b) -> ApT f g b
forall (f :: * -> *) (g :: * -> *) a. g (ApF f g a) -> ApT f g a
ApT ((a -> b) -> ApF f g a -> ApF f g b
forall a b. (a -> b) -> ApF f g a -> ApF f g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (ApF f g a -> ApF f g b) -> g (ApF f g a) -> g (ApF f g b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> g (ApF f g a)
g)
instance Applicative g => Applicative (ApF f g) where
pure :: forall a. a -> ApF f g a
pure = a -> ApF f g a
forall a (f :: * -> *) (g :: * -> *). a -> ApF f g a
Pure
{-# INLINE pure #-}
Pure a -> b
f <*> :: forall a b. ApF f g (a -> b) -> ApF f g a -> ApF f g b
<*> ApF f g a
y = (a -> b) -> ApF f g a -> ApF f g b
forall a b. (a -> b) -> ApF f g a -> ApF f g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f ApF f g a
y
ApF f g (a -> b)
y <*> Pure a
a = ((a -> b) -> b) -> ApF f g (a -> b) -> ApF f g b
forall a b. (a -> b) -> ApF f g a -> ApF f g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> a -> b
forall a b. (a -> b) -> a -> b
$ a
a) ApF f g (a -> b)
y
Ap f a
a ApT f g (a -> a -> b)
f <*> ApF f g a
b = f a
a f a -> ApT f g (a -> b) -> ApF f g b
forall (f :: * -> *) a (g :: * -> *) b.
f a -> ApT f g (a -> b) -> ApF f g b
`Ap` ((a -> a -> b) -> a -> a -> b
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((a -> a -> b) -> a -> a -> b)
-> ApT f g (a -> a -> b) -> ApT f g (a -> a -> b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ApT f g (a -> a -> b)
f ApT f g (a -> a -> b) -> ApT f g a -> ApT f g (a -> b)
forall a b. ApT f g (a -> b) -> ApT f g a -> ApT f g b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> g (ApF f g a) -> ApT f g a
forall (f :: * -> *) (g :: * -> *) a. g (ApF f g a) -> ApT f g a
ApT (ApF f g a -> g (ApF f g a)
forall a. a -> g a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ApF f g a
b))
{-# INLINE (<*>) #-}
instance Applicative g => Applicative (ApT f g) where
pure :: forall a. a -> ApT f g a
pure = g (ApF f g a) -> ApT f g a
forall (f :: * -> *) (g :: * -> *) a. g (ApF f g a) -> ApT f g a
ApT (g (ApF f g a) -> ApT f g a)
-> (a -> g (ApF f g a)) -> a -> ApT f g a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ApF f g a -> g (ApF f g a)
forall a. a -> g a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ApF f g a -> g (ApF f g a))
-> (a -> ApF f g a) -> a -> g (ApF f g a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> ApF f g a
forall a. a -> ApF f g a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE pure #-}
ApT g (ApF f g (a -> b))
xs <*> :: forall a b. ApT f g (a -> b) -> ApT f g a -> ApT f g b
<*> ApT g (ApF f g a)
ys = g (ApF f g b) -> ApT f g b
forall (f :: * -> *) (g :: * -> *) a. g (ApF f g a) -> ApT f g a
ApT (ApF f g (a -> b) -> ApF f g a -> ApF f g b
forall a b. ApF f g (a -> b) -> ApF f g a -> ApF f g b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
(<*>) (ApF f g (a -> b) -> ApF f g a -> ApF f g b)
-> g (ApF f g (a -> b)) -> g (ApF f g a -> ApF f g b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> g (ApF f g (a -> b))
xs g (ApF f g a -> ApF f g b) -> g (ApF f g a) -> g (ApF f g b)
forall a b. g (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> g (ApF f g a)
ys)
{-# INLINE (<*>) #-}
instance Applicative g => Apply (ApF f g) where
<.> :: forall a b. ApF f g (a -> b) -> ApF f g a -> ApF f g b
(<.>) = ApF f g (a -> b) -> ApF f g a -> ApF f g b
forall a b. ApF f g (a -> b) -> ApF f g a -> ApF f g b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
(<*>)
{-# INLINE (<.>) #-}
instance Applicative g => Apply (ApT f g) where
<.> :: forall a b. ApT f g (a -> b) -> ApT f g a -> ApT f g b
(<.>) = ApT f g (a -> b) -> ApT f g a -> ApT f g b
forall a b. ApT f g (a -> b) -> ApT f g a -> ApT f g b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
(<*>)
{-# INLINE (<.>) #-}
instance Alternative g => Alternative (ApT f g) where
empty :: forall a. ApT f g a
empty = g (ApF f g a) -> ApT f g a
forall (f :: * -> *) (g :: * -> *) a. g (ApF f g a) -> ApT f g a
ApT g (ApF f g a)
forall a. g a
forall (f :: * -> *) a. Alternative f => f a
empty
{-# INLINE empty #-}
ApT g (ApF f g a)
g <|> :: forall a. ApT f g a -> ApT f g a -> ApT f g a
<|> ApT g (ApF f g a)
h = g (ApF f g a) -> ApT f g a
forall (f :: * -> *) (g :: * -> *) a. g (ApF f g a) -> ApT f g a
ApT (g (ApF f g a)
g g (ApF f g a) -> g (ApF f g a) -> g (ApF f g a)
forall a. g a -> g a -> g a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> g (ApF f g a)
h)
{-# INLINE (<|>) #-}
liftApT :: Applicative g => f a -> ApT f g a
liftApT :: forall (g :: * -> *) (f :: * -> *) a.
Applicative g =>
f a -> ApT f g a
liftApT f a
x = g (ApF f g a) -> ApT f g a
forall (f :: * -> *) (g :: * -> *) a. g (ApF f g a) -> ApT f g a
ApT (ApF f g a -> g (ApF f g a)
forall a. a -> g a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (f a -> ApT f g (a -> a) -> ApF f g a
forall (f :: * -> *) a (g :: * -> *) b.
f a -> ApT f g (a -> b) -> ApF f g b
Ap f a
x ((a -> a) -> ApT f g (a -> a)
forall a. a -> ApT f g a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a -> a
forall a. a -> a
id)))
liftApO :: Functor g => g a -> ApT f g a
liftApO :: forall (g :: * -> *) a (f :: * -> *). Functor g => g a -> ApT f g a
liftApO g a
g = g (ApF f g a) -> ApT f g a
forall (f :: * -> *) (g :: * -> *) a. g (ApF f g a) -> ApT f g a
ApT (a -> ApF f g a
forall a (f :: * -> *) (g :: * -> *). a -> ApF f g a
Pure (a -> ApF f g a) -> g a -> g (ApF f g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> g a
g)
runApF :: (Applicative h, Functor g) => (forall a. f a -> h a) -> (forall a. g (h a) -> h a) -> ApF f g b -> h b
runApF :: forall (h :: * -> *) (g :: * -> *) (f :: * -> *) b.
(Applicative h, Functor g) =>
(forall a. f a -> h a)
-> (forall a. g (h a) -> h a) -> ApF f g b -> h b
runApF forall a. f a -> h a
_ forall a. g (h a) -> h a
_ (Pure b
x) = b -> h b
forall a. a -> h a
forall (f :: * -> *) a. Applicative f => a -> f a
pure b
x
runApF forall a. f a -> h a
f forall a. g (h a) -> h a
g (Ap f a
x ApT f g (a -> b)
y) = f a -> h a
forall a. f a -> h a
f f a
x h a -> h (a -> b) -> h b
forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b
<**> (forall a. f a -> h a)
-> (forall a. g (h a) -> h a) -> ApT f g (a -> b) -> h (a -> b)
forall (h :: * -> *) (g :: * -> *) (f :: * -> *) b.
(Applicative h, Functor g) =>
(forall a. f a -> h a)
-> (forall a. g (h a) -> h a) -> ApT f g b -> h b
runApT f a -> h a
forall a. f a -> h a
f g (h a) -> h a
forall a. g (h a) -> h a
g ApT f g (a -> b)
y
runApT :: (Applicative h, Functor g) => (forall a. f a -> h a) -> (forall a. g (h a) -> h a) -> ApT f g b -> h b
runApT :: forall (h :: * -> *) (g :: * -> *) (f :: * -> *) b.
(Applicative h, Functor g) =>
(forall a. f a -> h a)
-> (forall a. g (h a) -> h a) -> ApT f g b -> h b
runApT forall a. f a -> h a
f forall a. g (h a) -> h a
g (ApT g (ApF f g b)
a) = g (h b) -> h b
forall a. g (h a) -> h a
g ((forall a. f a -> h a)
-> (forall a. g (h a) -> h a) -> ApF f g b -> h b
forall (h :: * -> *) (g :: * -> *) (f :: * -> *) b.
(Applicative h, Functor g) =>
(forall a. f a -> h a)
-> (forall a. g (h a) -> h a) -> ApF f g b -> h b
runApF f a -> h a
forall a. f a -> h a
f g (h a) -> h a
forall a. g (h a) -> h a
g (ApF f g b -> h b) -> g (ApF f g b) -> g (h b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> g (ApF f g b)
a)
runApT_ :: (Functor g, Monoid m) => (forall a. f a -> m) -> (g m -> m) -> ApT f g b -> m
runApT_ :: forall (g :: * -> *) m (f :: * -> *) b.
(Functor g, Monoid m) =>
(forall a. f a -> m) -> (g m -> m) -> ApT f g b -> m
runApT_ forall a. f a -> m
f g m -> m
g = Const m b -> m
forall {k} a (b :: k). Const a b -> a
getConst (Const m b -> m) -> (ApT f g b -> Const m b) -> ApT f g b -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. f a -> Const m a)
-> (forall a. g (Const m a) -> Const m a) -> ApT f g b -> Const m b
forall (h :: * -> *) (g :: * -> *) (f :: * -> *) b.
(Applicative h, Functor g) =>
(forall a. f a -> h a)
-> (forall a. g (h a) -> h a) -> ApT f g b -> h b
runApT (m -> Const m a
forall {k} a (b :: k). a -> Const a b
Const (m -> Const m a) -> (f a -> m) -> f a -> Const m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> m
forall a. f a -> m
f) (m -> Const m a
forall {k} a (b :: k). a -> Const a b
Const (m -> Const m a)
-> (g (Const m a) -> m) -> g (Const m a) -> Const m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g m -> m
g (g m -> m) -> (g (Const m a) -> g m) -> g (Const m a) -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Const m a -> m) -> g (Const m a) -> g m
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Const m a -> m
forall {k} a (b :: k). Const a b -> a
getConst)
hoistApF :: Functor g => (forall a. f a -> f' a) -> ApF f g b -> ApF f' g b
hoistApF :: forall (g :: * -> *) (f :: * -> *) (f' :: * -> *) b.
Functor g =>
(forall a. f a -> f' a) -> ApF f g b -> ApF f' g b
hoistApF forall a. f a -> f' a
_ (Pure b
x) = b -> ApF f' g b
forall a (f :: * -> *) (g :: * -> *). a -> ApF f g a
Pure b
x
hoistApF forall a. f a -> f' a
f (Ap f a
x ApT f g (a -> b)
y) = f a -> f' a
forall a. f a -> f' a
f f a
x f' a -> ApT f' g (a -> b) -> ApF f' g b
forall (f :: * -> *) a (g :: * -> *) b.
f a -> ApT f g (a -> b) -> ApF f g b
`Ap` (forall a. f a -> f' a) -> ApT f g (a -> b) -> ApT f' g (a -> b)
forall (g :: * -> *) (f :: * -> *) (f' :: * -> *) b.
Functor g =>
(forall a. f a -> f' a) -> ApT f g b -> ApT f' g b
hoistApT f a -> f' a
forall a. f a -> f' a
f ApT f g (a -> b)
y
hoistApT :: Functor g => (forall a. f a -> f' a) -> ApT f g b -> ApT f' g b
hoistApT :: forall (g :: * -> *) (f :: * -> *) (f' :: * -> *) b.
Functor g =>
(forall a. f a -> f' a) -> ApT f g b -> ApT f' g b
hoistApT forall a. f a -> f' a
f (ApT g (ApF f g b)
g) = g (ApF f' g b) -> ApT f' g b
forall (f :: * -> *) (g :: * -> *) a. g (ApF f g a) -> ApT f g a
ApT ((forall a. f a -> f' a) -> ApF f g b -> ApF f' g b
forall (g :: * -> *) (f :: * -> *) (f' :: * -> *) b.
Functor g =>
(forall a. f a -> f' a) -> ApF f g b -> ApF f' g b
hoistApF f a -> f' a
forall a. f a -> f' a
f (ApF f g b -> ApF f' g b) -> g (ApF f g b) -> g (ApF f' g b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> g (ApF f g b)
g)
transApF :: Functor g => (forall a. g a -> g' a) -> ApF f g b -> ApF f g' b
transApF :: forall (g :: * -> *) (g' :: * -> *) (f :: * -> *) b.
Functor g =>
(forall a. g a -> g' a) -> ApF f g b -> ApF f g' b
transApF forall a. g a -> g' a
_ (Pure b
x) = b -> ApF f g' b
forall a (f :: * -> *) (g :: * -> *). a -> ApF f g a
Pure b
x
transApF forall a. g a -> g' a
f (Ap f a
x ApT f g (a -> b)
y) = f a
x f a -> ApT f g' (a -> b) -> ApF f g' b
forall (f :: * -> *) a (g :: * -> *) b.
f a -> ApT f g (a -> b) -> ApF f g b
`Ap` (forall a. g a -> g' a) -> ApT f g (a -> b) -> ApT f g' (a -> b)
forall (g :: * -> *) (g' :: * -> *) (f :: * -> *) b.
Functor g =>
(forall a. g a -> g' a) -> ApT f g b -> ApT f g' b
transApT g a -> g' a
forall a. g a -> g' a
f ApT f g (a -> b)
y
transApT :: Functor g => (forall a. g a -> g' a) -> ApT f g b -> ApT f g' b
transApT :: forall (g :: * -> *) (g' :: * -> *) (f :: * -> *) b.
Functor g =>
(forall a. g a -> g' a) -> ApT f g b -> ApT f g' b
transApT forall a. g a -> g' a
f (ApT g (ApF f g b)
g) = g' (ApF f g' b) -> ApT f g' b
forall (f :: * -> *) (g :: * -> *) a. g (ApF f g a) -> ApT f g a
ApT (g' (ApF f g' b) -> ApT f g' b) -> g' (ApF f g' b) -> ApT f g' b
forall a b. (a -> b) -> a -> b
$ g (ApF f g' b) -> g' (ApF f g' b)
forall a. g a -> g' a
f ((forall a. g a -> g' a) -> ApF f g b -> ApF f g' b
forall (g :: * -> *) (g' :: * -> *) (f :: * -> *) b.
Functor g =>
(forall a. g a -> g' a) -> ApF f g b -> ApF f g' b
transApF g a -> g' a
forall a. g a -> g' a
f (ApF f g b -> ApF f g' b) -> g (ApF f g b) -> g (ApF f g' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> g (ApF f g b)
g)
joinApT :: Monad m => ApT f m a -> m (Ap f a)
joinApT :: forall (m :: * -> *) (f :: * -> *) a.
Monad m =>
ApT f m a -> m (Ap f a)
joinApT (ApT m (ApF f m a)
m) = m (ApF f m a)
m m (ApF f m a) -> (ApF f m a -> m (Ap f a)) -> m (Ap f a)
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ApF f m a -> m (Ap f a)
forall {m :: * -> *} {f :: * -> *} {a}.
Monad m =>
ApF f m a -> m (ApT f Identity a)
joinApF
where
joinApF :: ApF f m a -> m (ApT f Identity a)
joinApF (Pure a
x) = ApT f Identity a -> m (ApT f Identity a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> ApT f Identity a
forall a. a -> ApT f Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
x)
joinApF (Ap f a
x ApT f m (a -> a)
y) = (f a -> ApT f Identity a
forall (g :: * -> *) (f :: * -> *) a.
Applicative g =>
f a -> ApT f g a
liftApT f a
x ApT f Identity a -> ApT f Identity (a -> a) -> ApT f Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b
<**>) (ApT f Identity (a -> a) -> ApT f Identity a)
-> m (ApT f Identity (a -> a)) -> m (ApT f Identity a)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` ApT f m (a -> a) -> m (ApT f Identity (a -> a))
forall (m :: * -> *) (f :: * -> *) a.
Monad m =>
ApT f m a -> m (Ap f a)
joinApT ApT f m (a -> a)
y
type Ap f = ApT f Identity
runAp :: Applicative g => (forall x. f x -> g x) -> Ap f a -> g a
runAp :: forall (g :: * -> *) (f :: * -> *) a.
Applicative g =>
(forall x. f x -> g x) -> Ap f a -> g a
runAp forall x. f x -> g x
f = (forall x. f x -> g x)
-> (forall a. Identity (g a) -> g a) -> ApT f Identity a -> g a
forall (h :: * -> *) (g :: * -> *) (f :: * -> *) b.
(Applicative h, Functor g) =>
(forall a. f a -> h a)
-> (forall a. g (h a) -> h a) -> ApT f g b -> h b
runApT f a -> g a
forall x. f x -> g x
f Identity (g a) -> g a
forall a. Identity a -> a
forall a. Identity (g a) -> g a
runIdentity
runAp_ :: Monoid m => (forall x. f x -> m) -> Ap f a -> m
runAp_ :: forall m (f :: * -> *) a.
Monoid m =>
(forall x. f x -> m) -> Ap f a -> m
runAp_ forall x. f x -> m
f = (forall x. f x -> m) -> (Identity m -> m) -> ApT f Identity a -> m
forall (g :: * -> *) m (f :: * -> *) b.
(Functor g, Monoid m) =>
(forall a. f a -> m) -> (g m -> m) -> ApT f g b -> m
runApT_ f a -> m
forall x. f x -> m
f Identity m -> m
forall a. Identity a -> a
runIdentity
retractAp :: Applicative f => Ap f a -> f a
retractAp :: forall (f :: * -> *) a. Applicative f => Ap f a -> f a
retractAp = (forall x. f x -> f x) -> Ap f a -> f a
forall (g :: * -> *) (f :: * -> *) a.
Applicative g =>
(forall x. f x -> g x) -> Ap f a -> g a
runAp f x -> f x
forall a. a -> a
forall x. f x -> f x
id
type Alt f = ApT f []
runAlt :: (Alternative g, Foldable t) => (forall x. f x -> g x) -> ApT f t a -> g a
runAlt :: forall (g :: * -> *) (t :: * -> *) (f :: * -> *) a.
(Alternative g, Foldable t) =>
(forall x. f x -> g x) -> ApT f t a -> g a
runAlt forall x. f x -> g x
f (ApT t (ApF f t a)
xs) = (ApF f t a -> g a -> g a) -> g a -> t (ApF f t a) -> g a
forall a b. (a -> b -> b) -> b -> t a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\ApF f t a
x g a
acc -> ApF f t a -> g a
h ApF f t a
x g a -> g a -> g a
forall a. g a -> g a -> g a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> g a
acc) g a
forall a. g a
forall (f :: * -> *) a. Alternative f => f a
empty t (ApF f t a)
xs
where
h :: ApF f t a -> g a
h (Pure a
x) = a -> g a
forall a. a -> g a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
x
h (Ap f a
x ApT f t (a -> a)
g) = f a -> g a
forall x. f x -> g x
f f a
x g a -> g (a -> a) -> g a
forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b
<**> (forall x. f x -> g x) -> ApT f t (a -> a) -> g (a -> a)
forall (g :: * -> *) (t :: * -> *) (f :: * -> *) a.
(Alternative g, Foldable t) =>
(forall x. f x -> g x) -> ApT f t a -> g a
runAlt f x -> g x
forall x. f x -> g x
f ApT f t (a -> a)
g