{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}
module Flay
( Flay
, Flayable(flay)
, Flayable1
, flay1
, gflay
, GFlay
, All
, Trivial
, trivialize
, trivial
, trivial1
, trivial'
, collect
, collect1
, collect'
, zip
, zip1
, unsafeZip
, terminal
, Terminal
, GTerminal
, Pump
, GPump
, pump
, dump
, Fields
, GFields
, FieldsF
, GFieldsF
, Dict(Dict)
) where
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.State (StateT(StateT), runStateT)
import Control.Monad.Trans.Maybe (MaybeT(MaybeT), runMaybeT)
import Data.Constraint (Dict(Dict))
import Data.Dynamic (Dynamic, toDyn, fromDynamic)
import Data.Functor.Product (Product(Pair))
import Data.Functor.Const (Const(Const, getConst))
import Data.Kind
import Data.Typeable (Typeable)
import qualified GHC.Generics as G
import Prelude hiding (zip)
import Unsafe.Coerce (unsafeCoerce)
type Flay (c :: k -> Constraint) s t (f :: k -> Type) (g :: k -> Type)
= forall m. Applicative m
=> (forall a. Dict (c a) -> f a -> m (g a)) -> s -> m t
class Flayable (c :: k -> Constraint) s t (f :: k -> Type) (g :: k -> Type)
| s -> f, t -> g, s g -> t, t f -> s where
flay :: Flay c s t f g
default flay :: GFlay c s t f g => Flay c s t f g
flay = (forall (a :: k). Dict (c a) -> f a -> m (g a)) -> s -> m t
forall k (c :: k -> Constraint) s t (f :: k -> *) (g :: k -> *).
GFlay c s t f g =>
Flay c s t f g
Flay c s t f g
gflay
{-# INLINE flay #-}
instance {-# OVERLAPPABLE #-}
GFlay c (r f) (r g) f g
=> Flayable c (r f) (r g) f g where
flay :: Flay c (r f) (r g) f g
flay = (forall (a :: k). Dict (c a) -> f a -> m (g a)) -> r f -> m (r g)
forall k (c :: k -> Constraint) s t (f :: k -> *) (g :: k -> *).
GFlay c s t f g =>
Flay c s t f g
Flay c (r f) (r g) f g
gflay
{-# INLINE flay #-}
type family Flayable1 (c :: k -> Constraint) (r :: (k -> Type) -> Type) :: Constraint where
Flayable1 c r = Flayable1_ c r
class Flayable1K c r (Skolem (Flayable1K c r))
=> Flayable1_ (c :: k -> Constraint) (r :: (k -> Type) -> Type)
instance Flayable1K c r (Skolem (Flayable1K c r))
=> Flayable1_ c r
class Flayable c (r F) (r G) F G
=> Flayable1K (c :: k -> Constraint) (r :: (k -> Type) -> Type) (x :: Type)
instance Flayable c (r F) (r G) F G
=> Flayable1K c r x
type family Skolem (p :: k -> Constraint) :: k where
flay1 :: forall c r f g. Flayable1 c r => Flay c (r f) (r g) f g
{-# INLINE flay1 #-}
flay1 :: forall {k} (c :: k -> Constraint) (r :: (k -> *) -> *)
(f :: k -> *) (g :: k -> *).
Flayable1 c r =>
Flay c (r f) (r g) f g
flay1 =
let flFG :: (forall (a :: k). Dict (c a) -> F a -> m (G a)) -> r F -> m (r G)
flFG = (forall (a :: k). Dict (c a) -> F a -> m (G a)) -> r F -> m (r G)
forall k (c :: k -> Constraint) s t (f :: k -> *) (g :: k -> *).
Flayable c s t f g =>
Flay c s t f g
forall {m :: * -> *}.
Applicative m =>
(forall (a :: k). Dict (c a) -> F a -> m (G a)) -> r F -> m (r G)
flay :: Flay c (r F) (r G) F G
in \(Dict (c Any) -> f Any -> m (g Any)
h0 :: Dict (c a0) -> f a0 -> m (g a0)) (r f
rf :: r f) ->
m (r G) -> m (r g)
forall a b. a -> b
unsafeCoerce ((forall (a :: k). Dict (c a) -> F a -> m (G a)) -> r F -> m (r G)
flFG ((Dict (c Any) -> f Any -> m (g Any))
-> Dict (c a1) -> F a1 -> m (G a1)
forall a b. a -> b
unsafeCoerce Dict (c Any) -> f Any -> m (g Any)
h0 :: Dict (c a1) -> F a1 -> m (G a1))
(r f -> r F
forall a b. a -> b
unsafeCoerce r f
rf :: r F)
:: m (r G))
class Trivial (a :: k)
instance Trivial a
trivialize :: forall c s t f g. Flay c s t f g -> Flay Trivial s t f g
{-# INLINE trivialize #-}
trivialize :: forall {k} (c :: k -> Constraint) s t (f :: k -> *) (g :: k -> *).
Flay c s t f g -> Flay Trivial s t f g
trivialize Flay c s t f g
fl0 = \forall (a :: k). Dict (Trivial a) -> f a -> m (g a)
h s
s ->
(forall (a :: k). Dict (c a) -> f a -> m (g a)) -> s -> m t
Flay c s t f g
fl0 (\(Dict (c a)
Dict :: Dict (c a)) (f a
fa :: f a) -> Dict (Trivial a) -> f a -> m (g a)
forall (a :: k). Dict (Trivial a) -> f a -> m (g a)
h (Dict (Trivial a)
forall (a :: Constraint). a => Dict a
Dict :: Dict (Trivial a)) f a
fa) s
s
trivial'
:: forall m c s t f g
. Applicative m
=> Flay c s t f g
-> (forall a. Trivial a => f a -> m (g a))
-> s
-> m t
trivial' :: forall {k} (m :: * -> *) (c :: k -> Constraint) s t (f :: k -> *)
(g :: k -> *).
Applicative m =>
Flay c s t f g
-> (forall (a :: k). Trivial a => f a -> m (g a)) -> s -> m t
trivial' Flay c s t f g
fl = \forall (a :: k). Trivial a => f a -> m (g a)
h -> \s
s -> Flay c s t f g -> Flay Trivial s t f g
forall {k} (c :: k -> Constraint) s t (f :: k -> *) (g :: k -> *).
Flay c s t f g -> Flay Trivial s t f g
trivialize (forall (a :: k). Dict (c a) -> f a -> m (g a)) -> s -> m t
Flay c s t f g
fl (\Dict (Trivial a)
Dict f a
fa -> f a -> m (g a)
forall (a :: k). Trivial a => f a -> m (g a)
h f a
fa) s
s
{-# INLINE trivial' #-}
trivial
:: forall m s t f g
. (Applicative m, Flayable Trivial s t f g)
=> (forall a. Trivial a => f a -> m (g a))
-> s
-> m t
trivial :: forall {k} (m :: * -> *) s t (f :: k -> *) (g :: k -> *).
(Applicative m, Flayable Trivial s t f g) =>
(forall (a :: k). Trivial a => f a -> m (g a)) -> s -> m t
trivial = Flay Trivial s t f g
-> (forall (a :: k). Trivial a => f a -> m (g a)) -> s -> m t
forall {k} (m :: * -> *) (c :: k -> Constraint) s t (f :: k -> *)
(g :: k -> *).
Applicative m =>
Flay c s t f g
-> (forall (a :: k). Trivial a => f a -> m (g a)) -> s -> m t
trivial' ((forall (a :: k). Dict (Trivial a) -> f a -> m (g a)) -> s -> m t
forall k (c :: k -> Constraint) s t (f :: k -> *) (g :: k -> *).
Flayable c s t f g =>
Flay c s t f g
Flay Trivial s t f g
flay :: Flay Trivial s t f g)
{-# INLINE trivial #-}
trivial1
:: forall m f g r
. (Applicative m, Flayable1 Trivial r)
=> (forall a. Trivial a => f a -> m (g a))
-> (r f)
-> m (r g)
trivial1 :: forall {k} (m :: * -> *) (f :: k -> *) (g :: k -> *)
(r :: (k -> *) -> *).
(Applicative m, Flayable1 Trivial r) =>
(forall (a :: k). Trivial a => f a -> m (g a)) -> r f -> m (r g)
trivial1 = Flay Trivial (r f) (r g) f g
-> (forall (a :: k). Trivial a => f a -> m (g a)) -> r f -> m (r g)
forall {k} (m :: * -> *) (c :: k -> Constraint) s t (f :: k -> *)
(g :: k -> *).
Applicative m =>
Flay c s t f g
-> (forall (a :: k). Trivial a => f a -> m (g a)) -> s -> m t
trivial' ((forall (a :: k). Dict (Trivial a) -> f a -> m (g a))
-> r f -> m (r g)
forall {k} (c :: k -> Constraint) (r :: (k -> *) -> *)
(f :: k -> *) (g :: k -> *).
Flayable1 c r =>
Flay c (r f) (r g) f g
Flay Trivial (r f) (r g) f g
flay1 :: Flay Trivial (r f) (r g) f g)
{-# INLINE trivial1 #-}
type GFlay (c :: k -> Constraint) s t (f :: k -> Type) (g :: k -> Type)
= (GFlay' c (G.Rep s) (G.Rep t) f g, G.Generic s, G.Generic t)
gflay :: GFlay c s t f g => Flay (c :: k -> Constraint) s t (f :: k -> Type) (g :: k -> Type)
gflay :: forall k (c :: k -> Constraint) s t (f :: k -> *) (g :: k -> *).
GFlay c s t f g =>
Flay c s t f g
gflay = \forall (a :: k). Dict (c a) -> f a -> m (g a)
h s
s -> Rep t Any -> t
forall a x. Generic a => Rep a x -> a
forall x. Rep t x -> t
G.to (Rep t Any -> t) -> m (Rep t Any) -> m t
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (a :: k). Dict (c a) -> f a -> m (g a))
-> Rep s Any -> m (Rep t Any)
forall {k} k (c :: k -> Constraint) (s :: k -> *) (t :: k -> *)
(f :: k -> *) (g :: k -> *) (p :: k).
GFlay' c s t f g =>
Flay c (s p) (t p) f g
forall p. Flay c (Rep s p) (Rep t p) f g
gflay' Dict (c a) -> f a -> m (g a)
forall (a :: k). Dict (c a) -> f a -> m (g a)
h (s -> Rep s Any
forall x. s -> Rep s x
forall a x. Generic a => a -> Rep a x
G.from s
s)
{-# INLINE gflay #-}
class GFlay' (c :: k -> Constraint) s t (f :: k -> Type) (g :: k -> Type) where
gflay' :: Flay c (s p) (t p) f g
instance GFlay' c G.V1 G.V1 f g where
gflay' :: forall (p :: k). Flay c (V1 p) (V1 p) f g
gflay' forall (a :: k). Dict (c a) -> f a -> m (g a)
_ V1 p
_ = m (V1 p)
forall a. HasCallStack => a
undefined
{-# INLINE gflay' #-}
instance GFlay' c G.U1 G.U1 f g where
gflay' :: forall (p :: k). Flay c (U1 p) (U1 p) f g
gflay' forall (a :: k). Dict (c a) -> f a -> m (g a)
_ U1 p
_ = U1 p -> m (U1 p)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure U1 p
forall k (p :: k). U1 p
G.U1
{-# INLINE gflay' #-}
instance c a => GFlay' c (G.K1 r (f a)) (G.K1 r (g a)) f g where
gflay' :: forall (p :: k). Flay c (K1 r (f a) p) (K1 r (g a) p) f g
gflay' forall (a :: k). Dict (c a) -> f a -> m (g a)
h (G.K1 f a
fa) = g a -> K1 r (g a) p
forall k i c (p :: k). c -> K1 i c p
G.K1 (g a -> K1 r (g a) p) -> m (g a) -> m (K1 r (g a) p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dict (c a) -> f a -> m (g a)
forall (a :: k). Dict (c a) -> f a -> m (g a)
h Dict (c a)
forall (a :: Constraint). a => Dict a
Dict f a
fa
{-# INLINE gflay' #-}
instance (GFlay' c s t f g)
=> GFlay' c (G.M1 i j s) (G.M1 i j t) f g where
gflay' :: forall (p :: k). Flay c (M1 i j s p) (M1 i j t p) f g
gflay' forall (a :: k). Dict (c a) -> f a -> m (g a)
h (G.M1 s p
sp) = t p -> M1 i j t p
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
G.M1 (t p -> M1 i j t p) -> m (t p) -> m (M1 i j t p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (a :: k). Dict (c a) -> f a -> m (g a)) -> s p -> m (t p)
forall (p :: k). Flay c (s p) (t p) f g
forall {k} k (c :: k -> Constraint) (s :: k -> *) (t :: k -> *)
(f :: k -> *) (g :: k -> *) (p :: k).
GFlay' c s t f g =>
Flay c (s p) (t p) f g
gflay' Dict (c a) -> f a -> m (g a)
forall (a :: k). Dict (c a) -> f a -> m (g a)
h s p
sp
{-# INLINE gflay' #-}
instance (GFlay' c sl tl f g, GFlay' c sr tr f g)
=> GFlay' c (sl G.:*: sr) (tl G.:*: tr) f g where
gflay' :: forall (p :: k). Flay c ((:*:) sl sr p) ((:*:) tl tr p) f g
gflay' forall (a :: k). Dict (c a) -> f a -> m (g a)
h (sl p
slp G.:*: sr p
srp) = tl p -> tr p -> (:*:) tl tr p
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
(G.:*:) (tl p -> tr p -> (:*:) tl tr p)
-> m (tl p) -> m (tr p -> (:*:) tl tr p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (a :: k). Dict (c a) -> f a -> m (g a)) -> sl p -> m (tl p)
forall (p :: k). Flay c (sl p) (tl p) f g
forall {k} k (c :: k -> Constraint) (s :: k -> *) (t :: k -> *)
(f :: k -> *) (g :: k -> *) (p :: k).
GFlay' c s t f g =>
Flay c (s p) (t p) f g
gflay' Dict (c a) -> f a -> m (g a)
forall (a :: k). Dict (c a) -> f a -> m (g a)
h sl p
slp m (tr p -> (:*:) tl tr p) -> m (tr p) -> m ((:*:) tl tr p)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (forall (a :: k). Dict (c a) -> f a -> m (g a)) -> sr p -> m (tr p)
forall (p :: k). Flay c (sr p) (tr p) f g
forall {k} k (c :: k -> Constraint) (s :: k -> *) (t :: k -> *)
(f :: k -> *) (g :: k -> *) (p :: k).
GFlay' c s t f g =>
Flay c (s p) (t p) f g
gflay' Dict (c a) -> f a -> m (g a)
forall (a :: k). Dict (c a) -> f a -> m (g a)
h sr p
srp
{-# INLINE gflay' #-}
instance (GFlay' c sl tl f g, GFlay' c sr tr f g)
=> GFlay' c (sl G.:+: sr) (tl G.:+: tr) f g where
gflay' :: forall (p :: k). Flay c ((:+:) sl sr p) ((:+:) tl tr p) f g
gflay' forall (a :: k). Dict (c a) -> f a -> m (g a)
h (:+:) sl sr p
x = case (:+:) sl sr p
x of
G.L1 sl p
slp -> tl p -> (:+:) tl tr p
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
G.L1 (tl p -> (:+:) tl tr p) -> m (tl p) -> m ((:+:) tl tr p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (a :: k). Dict (c a) -> f a -> m (g a)) -> sl p -> m (tl p)
forall (p :: k). Flay c (sl p) (tl p) f g
forall {k} k (c :: k -> Constraint) (s :: k -> *) (t :: k -> *)
(f :: k -> *) (g :: k -> *) (p :: k).
GFlay' c s t f g =>
Flay c (s p) (t p) f g
gflay' Dict (c a) -> f a -> m (g a)
forall (a :: k). Dict (c a) -> f a -> m (g a)
h sl p
slp
G.R1 sr p
srp -> tr p -> (:+:) tl tr p
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
G.R1 (tr p -> (:+:) tl tr p) -> m (tr p) -> m ((:+:) tl tr p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (a :: k). Dict (c a) -> f a -> m (g a)) -> sr p -> m (tr p)
forall (p :: k). Flay c (sr p) (tr p) f g
forall {k} k (c :: k -> Constraint) (s :: k -> *) (t :: k -> *)
(f :: k -> *) (g :: k -> *) (p :: k).
GFlay' c s t f g =>
Flay c (s p) (t p) f g
gflay' Dict (c a) -> f a -> m (g a)
forall (a :: k). Dict (c a) -> f a -> m (g a)
h sr p
srp
{-# INLINE gflay' #-}
collect'
:: Monoid b
=> Flay c s t f (Const ())
-> (forall a. Dict (c a) -> f a -> b)
-> s
-> b
collect' :: forall {k} b (c :: k -> Constraint) s t (f :: k -> *).
Monoid b =>
Flay c s t f (Const ())
-> (forall (a :: k). Dict (c a) -> f a -> b) -> s -> b
collect' Flay c s t f (Const ())
fl = \forall (a :: k). Dict (c a) -> f a -> b
k -> \s
s -> Const b t -> b
forall {k} a (b :: k). Const a b -> a
getConst ((forall (a :: k). Dict (c a) -> f a -> Const b (Const () a))
-> s -> Const b t
Flay c s t f (Const ())
fl (\Dict (c a)
d f a
fa -> b -> Const b (Const () a)
forall {k} a (b :: k). a -> Const a b
Const (Dict (c a) -> f a -> b
forall (a :: k). Dict (c a) -> f a -> b
k Dict (c a)
d f a
fa)) s
s)
{-# INLINE collect' #-}
collect
:: (Monoid b, Flayable c s t f (Const ()))
=> (forall a. Dict (c a) -> f a -> b)
-> s
-> b
collect :: forall {k} b (c :: k -> Constraint) s t (f :: k -> *).
(Monoid b, Flayable c s t f (Const ())) =>
(forall (a :: k). Dict (c a) -> f a -> b) -> s -> b
collect = Flay c s t f (Const ())
-> (forall (a :: k). Dict (c a) -> f a -> b) -> s -> b
forall {k} b (c :: k -> Constraint) s t (f :: k -> *).
Monoid b =>
Flay c s t f (Const ())
-> (forall (a :: k). Dict (c a) -> f a -> b) -> s -> b
collect' (forall (a :: k). Dict (c a) -> f a -> m (Const () a)) -> s -> m t
forall k (c :: k -> Constraint) s t (f :: k -> *) (g :: k -> *).
Flayable c s t f g =>
Flay c s t f g
Flay c s t f (Const ())
flay
{-# INLINE collect #-}
collect1
:: (Monoid b, Flayable1 c r)
=> (forall a. Dict (c a) -> f a -> b)
-> r f
-> b
collect1 :: forall {k} b (c :: k -> Constraint) (r :: (k -> *) -> *)
(f :: k -> *).
(Monoid b, Flayable1 c r) =>
(forall (a :: k). Dict (c a) -> f a -> b) -> r f -> b
collect1 = Flay c (r f) (r (Const ())) f (Const ())
-> (forall (a :: k). Dict (c a) -> f a -> b) -> r f -> b
forall {k} b (c :: k -> Constraint) s t (f :: k -> *).
Monoid b =>
Flay c s t f (Const ())
-> (forall (a :: k). Dict (c a) -> f a -> b) -> s -> b
collect' (forall (a :: k). Dict (c a) -> f a -> m (Const () a))
-> r f -> m (r (Const ()))
forall {k} (c :: k -> Constraint) (r :: (k -> *) -> *)
(f :: k -> *) (g :: k -> *).
Flayable1 c r =>
Flay c (r f) (r g) f g
Flay c (r f) (r (Const ())) f (Const ())
flay1
{-# INLINE collect1 #-}
class Terminal a where
terminal :: a
instance Terminal () where
terminal :: ()
terminal = ()
{-# INLINE terminal #-}
instance {-# OVERLAPPABLE #-} (G.Generic a, GTerminal (G.Rep a)) => Terminal a where
terminal :: a
terminal = Rep a Any -> a
forall a x. Generic a => Rep a x -> a
forall x. Rep a x -> a
G.to Rep a Any
forall p. Rep a p
forall (f :: * -> *) p. GTerminal f => f p
gterminal
{-# INLINE terminal #-}
instance Terminal (Const () a) where
terminal :: Const () a
terminal = () -> Const () a
forall {k} a (b :: k). a -> Const a b
Const ()
{-# INLINE terminal #-}
class GTerminal (f :: Type -> Type) where
gterminal :: f p
instance GTerminal G.U1 where
gterminal :: forall p. U1 p
gterminal = U1 p
forall k (p :: k). U1 p
G.U1
{-# INLINE gterminal #-}
instance Terminal x => GTerminal (G.K1 i x) where
gterminal :: forall p. K1 i x p
gterminal = x -> K1 i x p
forall k i c (p :: k). c -> K1 i c p
G.K1 x
forall a. Terminal a => a
terminal
{-# INLINE gterminal #-}
instance GTerminal f => GTerminal (G.M1 i c f) where
gterminal :: forall p. M1 i c f p
gterminal = f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
G.M1 f p
forall p. f p
forall (f :: * -> *) p. GTerminal f => f p
gterminal
{-# INLINE gterminal #-}
instance (GTerminal l, GTerminal r) => GTerminal (l G.:*: r) where
gterminal :: forall p. (:*:) l r p
gterminal = l p
forall p. l p
forall (f :: * -> *) p. GTerminal f => f p
gterminal l p -> r p -> (:*:) l r p
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
G.:*: r p
forall p. r p
forall (f :: * -> *) p. GTerminal f => f p
gterminal
{-# INLINE gterminal #-}
zip1
:: forall c s f g h m
. (Monad m, Typeable f, Flayable1 c s, Flayable1 Typeable s)
=> (forall x. Dict (c x) -> f x -> g x -> m (h x))
-> s f
-> s g
-> m (Maybe (s h))
zip1 :: forall {k} (c :: k -> Constraint) (s :: (k -> *) -> *)
(f :: k -> *) (g :: k -> *) (h :: k -> *) (m :: * -> *).
(Monad m, Typeable f, Flayable1 c s, Flayable1 Typeable s) =>
(forall (x :: k). Dict (c x) -> f x -> g x -> m (h x))
-> s f -> s g -> m (Maybe (s h))
zip1 forall (x :: k). Dict (c x) -> f x -> g x -> m (h x)
h = Flay Typeable (s f) (s (Const ())) f (Const ())
-> Flay Typeable (s g) (s (Product f g)) g (Product f g)
-> Flay c (s (Product f g)) (s h) (Product f g) h
-> (forall (x :: k). Dict (c x) -> f x -> g x -> m (h x))
-> s f
-> s g
-> m (Maybe (s h))
forall {k} (c :: k -> Constraint) s1 s2 t1 t2 t3 (f :: k -> *)
(g :: k -> *) (h :: k -> *) (m :: * -> *).
(Monad m, Typeable f) =>
Flay Typeable s1 t1 f (Const ())
-> Flay Typeable s2 t2 g (Product f g)
-> Flay c t2 t3 (Product f g) h
-> (forall (x :: k). Dict (c x) -> f x -> g x -> m (h x))
-> s1
-> s2
-> m (Maybe t3)
unsafeZip (forall (a :: k). Dict (Typeable a) -> f a -> m (Const () a))
-> s f -> m (s (Const ()))
forall {k} (c :: k -> Constraint) (r :: (k -> *) -> *)
(f :: k -> *) (g :: k -> *).
Flayable1 c r =>
Flay c (r f) (r g) f g
Flay Typeable (s f) (s (Const ())) f (Const ())
flay1 (forall (a :: k). Dict (Typeable a) -> g a -> m (Product f g a))
-> s g -> m (s (Product f g))
forall {k} (c :: k -> Constraint) (r :: (k -> *) -> *)
(f :: k -> *) (g :: k -> *).
Flayable1 c r =>
Flay c (r f) (r g) f g
Flay Typeable (s g) (s (Product f g)) g (Product f g)
flay1 (forall (a :: k). Dict (c a) -> Product f g a -> m (h a))
-> s (Product f g) -> m (s h)
forall {k} (c :: k -> Constraint) (r :: (k -> *) -> *)
(f :: k -> *) (g :: k -> *).
Flayable1 c r =>
Flay c (r f) (r g) f g
Flay c (s (Product f g)) (s h) (Product f g) h
flay1 Dict (c x) -> f x -> g x -> m (h x)
forall (x :: k). Dict (c x) -> f x -> g x -> m (h x)
h
{-# INLINABLE zip1 #-}
zip
:: forall c s1 s2 t1 t2 t3 f g h m
. ( Monad m
, Typeable f
, Flayable Typeable s1 t1 f (Const ())
, Flayable Typeable s2 t2 g (Product f g)
, Flayable c t2 t3 (Product f g) h )
=> (forall x. Dict (c x) -> f x -> g x -> m (h x))
-> s1
-> s2
-> m (Maybe t3)
zip :: forall {k} (c :: k -> Constraint) s1 s2 t1 t2 t3 (f :: k -> *)
(g :: k -> *) (h :: k -> *) (m :: * -> *).
(Monad m, Typeable f, Flayable Typeable s1 t1 f (Const ()),
Flayable Typeable s2 t2 g (Product f g),
Flayable c t2 t3 (Product f g) h) =>
(forall (x :: k). Dict (c x) -> f x -> g x -> m (h x))
-> s1 -> s2 -> m (Maybe t3)
zip forall (x :: k). Dict (c x) -> f x -> g x -> m (h x)
h = Flay Typeable s1 t1 f (Const ())
-> Flay Typeable s2 t2 g (Product f g)
-> Flay c t2 t3 (Product f g) h
-> (forall (x :: k). Dict (c x) -> f x -> g x -> m (h x))
-> s1
-> s2
-> m (Maybe t3)
forall {k} (c :: k -> Constraint) s1 s2 t1 t2 t3 (f :: k -> *)
(g :: k -> *) (h :: k -> *) (m :: * -> *).
(Monad m, Typeable f) =>
Flay Typeable s1 t1 f (Const ())
-> Flay Typeable s2 t2 g (Product f g)
-> Flay c t2 t3 (Product f g) h
-> (forall (x :: k). Dict (c x) -> f x -> g x -> m (h x))
-> s1
-> s2
-> m (Maybe t3)
unsafeZip (forall (a :: k). Dict (Typeable a) -> f a -> m (Const () a))
-> s1 -> m t1
forall k (c :: k -> Constraint) s t (f :: k -> *) (g :: k -> *).
Flayable c s t f g =>
Flay c s t f g
Flay Typeable s1 t1 f (Const ())
flay (forall (a :: k). Dict (Typeable a) -> g a -> m (Product f g a))
-> s2 -> m t2
forall k (c :: k -> Constraint) s t (f :: k -> *) (g :: k -> *).
Flayable c s t f g =>
Flay c s t f g
Flay Typeable s2 t2 g (Product f g)
flay (forall (a :: k). Dict (c a) -> Product f g a -> m (h a))
-> t2 -> m t3
forall k (c :: k -> Constraint) s t (f :: k -> *) (g :: k -> *).
Flayable c s t f g =>
Flay c s t f g
Flay c t2 t3 (Product f g) h
flay Dict (c x) -> f x -> g x -> m (h x)
forall (x :: k). Dict (c x) -> f x -> g x -> m (h x)
h
{-# INLINABLE zip #-}
unsafeZip
:: forall c s1 s2 t1 t2 t3 f g h m
. (Monad m, Typeable f)
=> (Flay Typeable s1 t1 f (Const ()))
-> (Flay Typeable s2 t2 g (Product f g))
-> (Flay c t2 t3 (Product f g) h)
-> (forall x. Dict (c x) -> f x -> g x -> m (h x))
-> s1
-> s2
-> m (Maybe t3)
unsafeZip :: forall {k} (c :: k -> Constraint) s1 s2 t1 t2 t3 (f :: k -> *)
(g :: k -> *) (h :: k -> *) (m :: * -> *).
(Monad m, Typeable f) =>
Flay Typeable s1 t1 f (Const ())
-> Flay Typeable s2 t2 g (Product f g)
-> Flay c t2 t3 (Product f g) h
-> (forall (x :: k). Dict (c x) -> f x -> g x -> m (h x))
-> s1
-> s2
-> m (Maybe t3)
unsafeZip Flay Typeable s1 t1 f (Const ())
fl1 Flay Typeable s2 t2 g (Product f g)
fl2 Flay c t2 t3 (Product f g) h
fl3 forall (x :: k). Dict (c x) -> f x -> g x -> m (h x)
pair = \s1
s1 s2
s2 -> MaybeT m t3 -> m (Maybe t3)
forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
runMaybeT (MaybeT m t3 -> m (Maybe t3)) -> MaybeT m t3 -> m (Maybe t3)
forall a b. (a -> b) -> a -> b
$ do
(t2
t2, [Dynamic]
dyns) <- StateT [Dynamic] (MaybeT m) t2
-> [Dynamic] -> MaybeT m (t2, [Dynamic])
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT ((forall (a :: k).
Dict (Typeable a)
-> g a -> StateT [Dynamic] (MaybeT m) (Product f g a))
-> s2 -> StateT [Dynamic] (MaybeT m) t2
Flay Typeable s2 t2 g (Product f g)
fl2 Dict (Typeable a)
-> g a -> StateT [Dynamic] (MaybeT m) (Product f g a)
forall (a :: k).
Dict (Typeable a)
-> g a -> StateT [Dynamic] (MaybeT m) (Product f g a)
f2 s2
s2) (Flay Typeable s1 t1 f (Const ())
-> (forall (a :: k). Dict (Typeable a) -> f a -> [Dynamic])
-> s1
-> [Dynamic]
forall {k} b (c :: k -> Constraint) s t (f :: k -> *).
Monoid b =>
Flay c s t f (Const ())
-> (forall (a :: k). Dict (c a) -> f a -> b) -> s -> b
collect' (forall (a :: k). Dict (Typeable a) -> f a -> m (Const () a))
-> s1 -> m t1
Flay Typeable s1 t1 f (Const ())
fl1 Dict (Typeable a) -> f a -> [Dynamic]
forall (a :: k). Dict (Typeable a) -> f a -> [Dynamic]
f1 s1
s1)
case [Dynamic]
dyns of
[] -> m t3 -> MaybeT m t3
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift ((forall (a :: k). Dict (c a) -> Product f g a -> m (h a))
-> t2 -> m t3
Flay c t2 t3 (Product f g) h
fl3 Dict (c a) -> Product f g a -> m (h a)
forall (a :: k). Dict (c a) -> Product f g a -> m (h a)
f3 t2
t2)
[Dynamic]
_ -> m (Maybe t3) -> MaybeT m t3
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (Maybe t3 -> m (Maybe t3)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe t3
forall a. Maybe a
Nothing)
where
f1 :: Dict (Typeable a) -> f a -> [Dynamic]
f1 :: forall (a :: k). Dict (Typeable a) -> f a -> [Dynamic]
f1 = \Dict (Typeable a)
Dict !f a
fa -> [f a -> Dynamic
forall a. Typeable a => a -> Dynamic
toDyn f a
fa :: Dynamic]
f2 :: Dict (Typeable a) -> g a -> StateT [Dynamic] (MaybeT m) (Product f g a)
f2 :: forall (a :: k).
Dict (Typeable a)
-> g a -> StateT [Dynamic] (MaybeT m) (Product f g a)
f2 = \Dict (Typeable a)
Dict !g a
ga -> ([Dynamic] -> MaybeT m (Product f g a, [Dynamic]))
-> StateT [Dynamic] (MaybeT m) (Product f g a)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT (([Dynamic] -> MaybeT m (Product f g a, [Dynamic]))
-> StateT [Dynamic] (MaybeT m) (Product f g a))
-> ([Dynamic] -> MaybeT m (Product f g a, [Dynamic]))
-> StateT [Dynamic] (MaybeT m) (Product f g a)
forall a b. (a -> b) -> a -> b
$ \case
(Dynamic
x:[Dynamic]
xs) -> do !(f a
fa :: f a) <- m (Maybe (f a)) -> MaybeT m (f a)
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (Maybe (f a) -> m (Maybe (f a))
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Dynamic -> Maybe (f a)
forall a. Typeable a => Dynamic -> Maybe a
fromDynamic Dynamic
x))
(Product f g a, [Dynamic]) -> MaybeT m (Product f g a, [Dynamic])
forall a. a -> MaybeT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (f a -> g a -> Product f g a
forall {k} (f :: k -> *) (g :: k -> *) (a :: k).
f a -> g a -> Product f g a
Pair f a
fa g a
ga, [Dynamic]
xs)
[] -> [Char] -> MaybeT m (Product f g a, [Dynamic])
forall a. HasCallStack => [Char] -> a
error [Char]
"Flay.unsafeZip"
f3 :: Dict (c a) -> Product f g a -> m (h a)
f3 :: forall (a :: k). Dict (c a) -> Product f g a -> m (h a)
f3 = \Dict (c a)
Dict (Pair f a
fa g a
ga) -> Dict (c a) -> f a -> g a -> m (h a)
forall (x :: k). Dict (c x) -> f x -> g x -> m (h x)
pair Dict (c a)
forall (a :: Constraint). a => Dict a
Dict f a
fa g a
ga
data Pump s f = forall p. Pump !(GPumped (G.Rep s) f p)
instance
(GFlay' c (GPumped (G.Rep s) f) (GPumped (G.Rep s) g) f g)
=> Flayable c (Pump s f) (Pump s g) f g where
flay :: Flay c (Pump s f) (Pump s g) f g
flay forall a. Dict (c a) -> f a -> m (g a)
h (Pump GPumped (Rep s) f p
rep) = GPumped (Rep s) g p -> Pump s g
forall s (f :: * -> *) p. GPumped (Rep s) f p -> Pump s f
Pump (GPumped (Rep s) g p -> Pump s g)
-> m (GPumped (Rep s) g p) -> m (Pump s g)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. Dict (c a) -> f a -> m (g a))
-> GPumped (Rep s) f p -> m (GPumped (Rep s) g p)
forall {k} k (c :: k -> Constraint) (s :: k -> *) (t :: k -> *)
(f :: k -> *) (g :: k -> *) (p :: k).
GFlay' c s t f g =>
Flay c (s p) (t p) f g
forall p. Flay c (GPumped (Rep s) f p) (GPumped (Rep s) g p) f g
gflay' Dict (c a) -> f a -> m (g a)
forall a. Dict (c a) -> f a -> m (g a)
h GPumped (Rep s) f p
rep
{-# INLINE flay #-}
pump
:: GPump s f
=> (forall x. x -> f x)
-> s
-> Pump s f
pump :: forall s (f :: * -> *).
GPump s f =>
(forall x. x -> f x) -> s -> Pump s f
pump forall x. x -> f x
f = \s
s -> GPumped (Rep s) f Any -> Pump s f
forall s (f :: * -> *) p. GPumped (Rep s) f p -> Pump s f
Pump ((forall x. x -> f x) -> Rep s Any -> GPumped (Rep s) f Any
forall p. (forall x. x -> f x) -> Rep s p -> GPumped (Rep s) f p
forall k (s :: k -> *) (f :: * -> *) (p :: k).
GPump' s f =>
(forall a. a -> f a) -> s p -> GPumped s f p
gpump a -> f a
forall x. x -> f x
f (s -> Rep s Any
forall x. s -> Rep s x
forall a x. Generic a => a -> Rep a x
G.from s
s))
{-# INLINE pump #-}
dump
:: (GPump s f, Applicative m)
=> (forall a. f a -> m a)
-> Pump s f
-> m s
dump :: forall s (f :: * -> *) (m :: * -> *).
(GPump s f, Applicative m) =>
(forall a. f a -> m a) -> Pump s f -> m s
dump forall a. f a -> m a
f = \(Pump GPumped (Rep s) f p
rep) -> Rep s p -> s
forall a x. Generic a => Rep a x -> a
forall x. Rep s x -> s
G.to (Rep s p -> s) -> m (Rep s p) -> m s
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. f a -> m a) -> GPumped (Rep s) f p -> m (Rep s p)
forall k (s :: k -> *) (f :: * -> *) (m :: * -> *) (p :: k).
(GPump' s f, Applicative m) =>
(forall a. f a -> m a) -> GPumped s f p -> m (s p)
forall (m :: * -> *) p.
Applicative m =>
(forall a. f a -> m a) -> GPumped (Rep s) f p -> m (Rep s p)
gdump f a -> m a
forall a. f a -> m a
f GPumped (Rep s) f p
rep
{-# INLINE dump #-}
type GPump s f = (G.Generic s, GPump' (G.Rep s) f)
class GPump' (s :: k -> Type) (f :: Type -> Type) where
type GPumped s f :: k -> Type
gpump :: (forall a. a -> f a) -> s p -> GPumped s f p
gdump :: Applicative m => (forall a. f a -> m a) -> GPumped s f p -> m (s p)
instance GPump' G.V1 f where
type GPumped G.V1 f = G.V1
gpump :: forall (p :: k). (forall a. a -> f a) -> V1 p -> GPumped V1 f p
gpump forall a. a -> f a
_ V1 p
_ = V1 p
GPumped V1 f p
forall a. HasCallStack => a
undefined
gdump :: forall (m :: * -> *) (p :: k).
Applicative m =>
(forall a. f a -> m a) -> GPumped V1 f p -> m (V1 p)
gdump forall a. f a -> m a
_ GPumped V1 f p
_ = m (V1 p)
forall a. HasCallStack => a
undefined
instance GPump' G.U1 f where
type GPumped G.U1 f = G.U1
gpump :: forall (p :: k). (forall a. a -> f a) -> U1 p -> GPumped U1 f p
gpump forall a. a -> f a
_ U1 p
G.U1 = U1 p
GPumped U1 f p
forall k (p :: k). U1 p
G.U1
{-# INLINE gpump #-}
gdump :: forall (m :: * -> *) (p :: k).
Applicative m =>
(forall a. f a -> m a) -> GPumped U1 f p -> m (U1 p)
gdump forall a. f a -> m a
_ U1 p
GPumped U1 f p
G.U1 = U1 p -> m (U1 p)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure U1 p
forall k (p :: k). U1 p
G.U1
{-# INLINE gdump #-}
instance GPump' (G.K1 i c) f where
type GPumped (G.K1 i c) f = G.K1 i (f c)
gpump :: forall (p :: k).
(forall a. a -> f a) -> K1 i c p -> GPumped (K1 i c) f p
gpump forall a. a -> f a
f (G.K1 c
c) = f c -> K1 i (f c) p
forall k i c (p :: k). c -> K1 i c p
G.K1 (c -> f c
forall a. a -> f a
f c
c)
{-# INLINE gpump #-}
gdump :: forall (m :: * -> *) (p :: k).
Applicative m =>
(forall a. f a -> m a) -> GPumped (K1 i c) f p -> m (K1 i c p)
gdump forall a. f a -> m a
f (G.K1 f c
c) = c -> K1 i c p
forall k i c (p :: k). c -> K1 i c p
G.K1 (c -> K1 i c p) -> m c -> m (K1 i c p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f c -> m c
forall a. f a -> m a
f f c
c
{-# INLINE gdump #-}
instance GPump' s f => GPump' (G.M1 i j s) f where
type GPumped (G.M1 i j s) f = G.M1 i j (GPumped s f)
gpump :: forall (p :: k).
(forall a. a -> f a) -> M1 i j s p -> GPumped (M1 i j s) f p
gpump forall a. a -> f a
f (G.M1 s p
sp) = GPumped s f p -> M1 i j (GPumped s f) p
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
G.M1 ((forall a. a -> f a) -> s p -> GPumped s f p
forall (p :: k). (forall a. a -> f a) -> s p -> GPumped s f p
forall k (s :: k -> *) (f :: * -> *) (p :: k).
GPump' s f =>
(forall a. a -> f a) -> s p -> GPumped s f p
gpump a -> f a
forall a. a -> f a
f s p
sp)
{-# INLINE gpump #-}
gdump :: forall (m :: * -> *) (p :: k).
Applicative m =>
(forall a. f a -> m a) -> GPumped (M1 i j s) f p -> m (M1 i j s p)
gdump forall a. f a -> m a
f (G.M1 GPumped s f p
sp) = s p -> M1 i j s p
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
G.M1 (s p -> M1 i j s p) -> m (s p) -> m (M1 i j s p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. f a -> m a) -> GPumped s f p -> m (s p)
forall k (s :: k -> *) (f :: * -> *) (m :: * -> *) (p :: k).
(GPump' s f, Applicative m) =>
(forall a. f a -> m a) -> GPumped s f p -> m (s p)
forall (m :: * -> *) (p :: k).
Applicative m =>
(forall a. f a -> m a) -> GPumped s f p -> m (s p)
gdump f a -> m a
forall a. f a -> m a
f GPumped s f p
sp
{-# INLINE gdump #-}
instance (GPump' sl f, GPump' sr f) => GPump' (sl G.:*: sr) f where
type GPumped (sl G.:*: sr) f = GPumped sl f G.:*: GPumped sr f
gpump :: forall (p :: k).
(forall a. a -> f a) -> (:*:) sl sr p -> GPumped (sl :*: sr) f p
gpump forall a. a -> f a
f (sl p
slp G.:*: sr p
srp) = (forall a. a -> f a) -> sl p -> GPumped sl f p
forall (p :: k). (forall a. a -> f a) -> sl p -> GPumped sl f p
forall k (s :: k -> *) (f :: * -> *) (p :: k).
GPump' s f =>
(forall a. a -> f a) -> s p -> GPumped s f p
gpump a -> f a
forall a. a -> f a
f sl p
slp GPumped sl f p
-> GPumped sr f p -> (:*:) (GPumped sl f) (GPumped sr f) p
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
G.:*: (forall a. a -> f a) -> sr p -> GPumped sr f p
forall (p :: k). (forall a. a -> f a) -> sr p -> GPumped sr f p
forall k (s :: k -> *) (f :: * -> *) (p :: k).
GPump' s f =>
(forall a. a -> f a) -> s p -> GPumped s f p
gpump a -> f a
forall a. a -> f a
f sr p
srp
{-# INLINE gpump #-}
gdump :: forall (m :: * -> *) (p :: k).
Applicative m =>
(forall a. f a -> m a)
-> GPumped (sl :*: sr) f p -> m ((:*:) sl sr p)
gdump forall a. f a -> m a
f (GPumped sl f p
slp G.:*: GPumped sr f p
srp) = sl p -> sr p -> (:*:) sl sr p
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
(G.:*:) (sl p -> sr p -> (:*:) sl sr p)
-> m (sl p) -> m (sr p -> (:*:) sl sr p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. f a -> m a) -> GPumped sl f p -> m (sl p)
forall k (s :: k -> *) (f :: * -> *) (m :: * -> *) (p :: k).
(GPump' s f, Applicative m) =>
(forall a. f a -> m a) -> GPumped s f p -> m (s p)
forall (m :: * -> *) (p :: k).
Applicative m =>
(forall a. f a -> m a) -> GPumped sl f p -> m (sl p)
gdump f a -> m a
forall a. f a -> m a
f GPumped sl f p
slp m (sr p -> (:*:) sl sr p) -> m (sr p) -> m ((:*:) sl sr p)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (forall a. f a -> m a) -> GPumped sr f p -> m (sr p)
forall k (s :: k -> *) (f :: * -> *) (m :: * -> *) (p :: k).
(GPump' s f, Applicative m) =>
(forall a. f a -> m a) -> GPumped s f p -> m (s p)
forall (m :: * -> *) (p :: k).
Applicative m =>
(forall a. f a -> m a) -> GPumped sr f p -> m (sr p)
gdump f a -> m a
forall a. f a -> m a
f GPumped sr f p
srp
{-# INLINE gdump #-}
instance (GPump' sl f, GPump' sr f) => GPump' (sl G.:+: sr) f where
type GPumped (sl G.:+: sr) f = GPumped sl f G.:+: GPumped sr f
gpump :: forall (p :: k).
(forall a. a -> f a) -> (:+:) sl sr p -> GPumped (sl :+: sr) f p
gpump forall a. a -> f a
f (G.L1 sl p
slp) = GPumped sl f p -> (:+:) (GPumped sl f) (GPumped sr f) p
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
G.L1 ((forall a. a -> f a) -> sl p -> GPumped sl f p
forall (p :: k). (forall a. a -> f a) -> sl p -> GPumped sl f p
forall k (s :: k -> *) (f :: * -> *) (p :: k).
GPump' s f =>
(forall a. a -> f a) -> s p -> GPumped s f p
gpump a -> f a
forall a. a -> f a
f sl p
slp)
gpump forall a. a -> f a
f (G.R1 sr p
srp) = GPumped sr f p -> (:+:) (GPumped sl f) (GPumped sr f) p
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
G.R1 ((forall a. a -> f a) -> sr p -> GPumped sr f p
forall (p :: k). (forall a. a -> f a) -> sr p -> GPumped sr f p
forall k (s :: k -> *) (f :: * -> *) (p :: k).
GPump' s f =>
(forall a. a -> f a) -> s p -> GPumped s f p
gpump a -> f a
forall a. a -> f a
f sr p
srp)
{-# INLINE gpump #-}
gdump :: forall (m :: * -> *) (p :: k).
Applicative m =>
(forall a. f a -> m a)
-> GPumped (sl :+: sr) f p -> m ((:+:) sl sr p)
gdump forall a. f a -> m a
f (G.L1 GPumped sl f p
slp) = sl p -> (:+:) sl sr p
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
G.L1 (sl p -> (:+:) sl sr p) -> m (sl p) -> m ((:+:) sl sr p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. f a -> m a) -> GPumped sl f p -> m (sl p)
forall k (s :: k -> *) (f :: * -> *) (m :: * -> *) (p :: k).
(GPump' s f, Applicative m) =>
(forall a. f a -> m a) -> GPumped s f p -> m (s p)
forall (m :: * -> *) (p :: k).
Applicative m =>
(forall a. f a -> m a) -> GPumped sl f p -> m (sl p)
gdump f a -> m a
forall a. f a -> m a
f GPumped sl f p
slp
gdump forall a. f a -> m a
f (G.R1 GPumped sr f p
srp) = sr p -> (:+:) sl sr p
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
G.R1 (sr p -> (:+:) sl sr p) -> m (sr p) -> m ((:+:) sl sr p)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. f a -> m a) -> GPumped sr f p -> m (sr p)
forall k (s :: k -> *) (f :: * -> *) (m :: * -> *) (p :: k).
(GPump' s f, Applicative m) =>
(forall a. f a -> m a) -> GPumped s f p -> m (s p)
forall (m :: * -> *) (p :: k).
Applicative m =>
(forall a. f a -> m a) -> GPumped sr f p -> m (sr p)
gdump f a -> m a
forall a. f a -> m a
f GPumped sr f p
srp
{-# INLINE gdump #-}
type family All (cs :: [k -> Constraint]) (x :: k) :: Constraint where
All (c ': cs) x = (c x, All cs x)
All '[] _ = ()
type Fields c s = GFields c (G.Rep s)
type family GFields (c :: kc -> Constraint) (s :: ks -> Type) :: Constraint where
GFields _ G.V1 = ()
GFields _ G.U1 = ()
GFields c (G.K1 _ a) = (c a)
GFields c (G.M1 _ _ s) = GFields c s
GFields c (sl G.:*: sr) = (GFields c sl, GFields c sr)
GFields c (sl G.:+: sr) = (GFields c sl, GFields c sr)
type family FieldsF (c :: k -> Constraint) (r :: (k -> Type) -> Type) :: Constraint where
FieldsF c r = FieldsF_ c r
class GFieldsF c (G.Rep (r F)) F => FieldsF_ c r
instance GFieldsF c (G.Rep (r F)) F => FieldsF_ c r
type family GFieldsF (c :: k -> Constraint) (s :: ks -> Type) (f :: k -> Type) :: Constraint where
GFieldsF _ G.V1 _ = ()
GFieldsF _ G.U1 _ = ()
GFieldsF c (G.K1 _ (f a)) f = (c a)
GFieldsF c (G.K1 _ _) f = ()
GFieldsF c (G.M1 _ _ s) f = GFieldsF c s f
GFieldsF c (sl G.:*: sr) f = (GFieldsF c sl f, GFieldsF c sr f)
GFieldsF c (sl G.:+: sr) f = (GFieldsF c sl f, GFieldsF c sr f)
data F (a :: k)
data G (a :: k)