{-# LANGUAGE CPP #-}
module Data.HList.TIP
(module Data.HList.TIPtuple,
module Data.HList.TIP) where
import Data.HList.HListPrelude
import Data.HList.FakePrelude
import Data.HList.HList
import Data.HList.Record
import Data.HList.HTypeIndexed ()
import Data.HList.TIPtuple
import Data.List (intercalate)
import Data.Array (Ix)
import Data.Semigroup (Semigroup)
#if __GLASGOW_HASKELL__ > 710
import Data.Coerce
#endif
import LensDefs
newtype TIP (l :: [*]) = TIP{forall (l :: [*]). TIP l -> HList l
unTIP:: HList l}
deriving instance Semigroup (HList a) => Semigroup (TIP a)
deriving instance Monoid (HList a) => Monoid (TIP a)
deriving instance Eq (HList a) => Eq (TIP a)
deriving instance (Ord (HList r)) => Ord (TIP r)
deriving instance (Ix (HList r)) => Ix (TIP r)
deriving instance (Bounded (HList r)) => Bounded (TIP r)
instance HMapOut (HShow `HComp` HUntag) l String => Show (TIP l) where
showsPrec :: Int -> TIP l -> ShowS
showsPrec Int
_ (TIP HList l
l) = (String
"TIPH[" forall a. [a] -> [a] -> [a]
++)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. [a] -> [[a]] -> [a]
intercalate String
"," (forall f e (l :: [*]). HMapOut f l e => f -> HList l -> [e]
hMapOut (HShow
HShow forall g f. g -> f -> HComp g f
`HComp` HUntag
HUntag) HList l
l) forall a. [a] -> [a] -> [a]
++)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char
']' forall a. a -> [a] -> [a]
:)
mkTIP :: HTypeIndexed l => HList l -> TIP l
mkTIP :: forall (l :: [*]). HTypeIndexed l => HList l -> TIP l
mkTIP = forall (l :: [*]). HList l -> TIP l
TIP
emptyTIP :: TIP '[]
emptyTIP :: TIP '[]
emptyTIP = forall (l :: [*]). HTypeIndexed l => HList l -> TIP l
mkTIP HList '[]
HNil
class (HAllTaggedEq l, HRLabelSet l) => HTypeIndexed (l :: [*])
instance (HAllTaggedEq l, HRLabelSet l) => HTypeIndexed l
class HAllTaggedEq (l :: [*])
instance HAllTaggedEq '[]
instance (HAllTaggedEq l, tee ~ Tagged e e') => HAllTaggedEq (tee ': l)
instance (HRLabelSet (Tagged e e ': l), HTypeIndexed l) => HExtend e (TIP l)
where
type HExtendR e (TIP l) = TIP (Tagged e e ': l)
e
e .*. :: e -> TIP l -> HExtendR e (TIP l)
.*. TIP HList l
l = forall (l :: [*]). HTypeIndexed l => HList l -> TIP l
mkTIP (forall x (xs :: [*]). x -> HList xs -> HList (x : xs)
HCons (forall {k} (s :: k) b. b -> Tagged s b
Tagged e
e) HList l
l)
instance (e ~ e', HasField e (Record l) e') => HasField e (TIP l) e' where
hLookupByLabel :: Label e -> TIP l -> e'
hLookupByLabel Label e
lab (TIP HList l
l) = forall k (l :: k) r v. HasField l r v => Label l -> r -> v
hLookupByLabel Label e
lab (forall (r :: [*]). HList r -> Record r
Record HList l
l)
instance (tee ~ Tagged e e) => HOccurs e (TIP '[tee]) where
hOccurs :: TIP '[tee] -> e
hOccurs (TIP (HCons (Tagged e
e) HList '[]
_)) = e
e
instance HasField e (Record (x ': y ': l)) e
=> HOccurs e (TIP (x ': y ': l)) where
hOccurs :: TIP (x : y : l) -> e
hOccurs (TIP HList (x : y : l)
l) = forall (r :: [*]). HList r -> Record r
Record HList (x : y : l)
l forall {k} (l :: k) r v. HasField l r v => r -> Label l -> v
.!. (forall {k} (l :: k). Label l
Label :: Label e)
instance (HAppend (HList l) (HList l'), HTypeIndexed (HAppendListR l l'))
=> HAppend (TIP l) (TIP l')
where
hAppend :: TIP l -> TIP l' -> HAppendR (TIP l) (TIP l')
hAppend (TIP HList l
l) (TIP HList l'
l') = forall (l :: [*]). HTypeIndexed l => HList l -> TIP l
mkTIP (forall l1 l2. HAppend l1 l2 => l1 -> l2 -> HAppendR l1 l2
hAppend HList l
l HList l'
l')
type instance HAppendR (TIP l) (TIP l') = TIP (HAppendListR l l')
onRecord :: (Record r -> Record l) -> TIP r -> TIP l
onRecord Record r -> Record l
f (TIP HList r
l) = let Record HList l
l' = Record r -> Record l
f (forall (r :: [*]). HList r -> Record r
Record HList r
l) in forall (l :: [*]). HTypeIndexed l => HList l -> TIP l
mkTIP HList l
l'
instance (HDeleteAtLabel Record e v v',
HTypeIndexed v')
=> HDeleteAtLabel TIP e v v' where
hDeleteAtLabel :: Label e -> TIP v -> TIP v'
hDeleteAtLabel Label e
e TIP v
v = forall {l :: [*]} {r :: [*]}.
(HAllTaggedEq l, HLabelSet (LabelsOf l), HAllTaggedLV l) =>
(Record r -> Record l) -> TIP r -> TIP l
onRecord (forall k (r :: [*] -> *) (l :: k) (v :: [*]) (v' :: [*]).
HDeleteAtLabel r l v v' =>
Label l -> r v -> r v'
hDeleteAtLabel Label e
e) TIP v
v
tipyUpdate :: v -> record r -> record r
tipyUpdate v
e record r
t = forall {k} (record :: [*] -> *) (l :: k) v (r :: [*]).
HTPupdateAtLabel record l v r =>
Label l -> v -> record r -> record r
hTPupdateAtLabel (forall e. e -> Label e
fromValue v
e) v
e record r
t
where fromValue :: e -> Label e
fromValue :: forall e. e -> Label e
fromValue e
_ = forall {k} (l :: k). Label l
Label
instance (HUpdateAtLabel Record e' e r r',
HTypeIndexed r',
e ~ e') => HUpdateAtLabel TIP e' e r r' where
hUpdateAtLabel :: SameLength r r' => Label e' -> e -> TIP r -> TIP r'
hUpdateAtLabel Label e'
l e
e TIP r
r = forall {l :: [*]} {r :: [*]}.
(HAllTaggedEq l, HLabelSet (LabelsOf l), HAllTaggedLV l) =>
(Record r -> Record l) -> TIP r -> TIP l
onRecord (forall k (record :: [*] -> *) (l :: k) v (r :: [*]) (r' :: [*]).
(HUpdateAtLabel record l v r r', SameLength r r') =>
Label l -> v -> record r -> record r'
hUpdateAtLabel Label e'
l e
e) TIP r
r
tipyProject :: proxy ls -> TIP r -> TIP l
tipyProject proxy ls
ps TIP r
t = forall {l :: [*]} {r :: [*]}.
(HAllTaggedEq l, HLabelSet (LabelsOf l), HAllTaggedLV l) =>
(Record r -> Record l) -> TIP r -> TIP l
onRecord (forall (a :: [*]) (ls :: [*]) (t :: [*]) (b :: [*])
(proxy :: [*] -> *).
(HRLabelSet a, H2ProjectByLabels ls t a b) =>
proxy ls -> Record t -> Record a
hProjectByLabels proxy ls
ps) TIP r
t
#if __GLASGOW_HASKELL__ < 707
tipyLens' x = isSimple tipyLens x
#else
tipyLens' :: (a -> f a) -> TIP t -> f (TIP t)
tipyLens' a -> f a
f TIP t
s = forall {k1} {k2} optic (p :: k1 -> k2 -> *) (a :: k1)
(f :: k1 -> k2) (s :: k1).
(optic ~ (p a (f a) -> p s (f s))) =>
optic -> optic
isSimple (forall {k} (x :: k) (r :: [*] -> *) (s :: [*]) (t :: [*]) a b.
HLens x r s t a b =>
Label x
-> forall (f :: * -> *). Functor f => (a -> f b) -> r s -> f (r t)
hLens Label a
x) a -> f a
f (forall (a :: [*]). TIP a -> TIP a
asTIP TIP t
s)
where
x :: Label a
x = forall a (f :: * -> *). (a -> f a) -> Label a
getA a -> f a
f
getA :: (a -> f a) -> Label a
getA :: forall a (f :: * -> *). (a -> f a) -> Label a
getA a -> f a
_ = forall {k} (l :: k). Label l
Label
asTIP :: TIP a -> TIP a
asTIP :: forall (a :: [*]). TIP a -> TIP a
asTIP = forall a. a -> a
id
#endif
tipyLens :: (a -> f a)
-> TIP (Tagged x x : xs)
-> f (TIP (HAppendListR l1 (Tagged a a : xs)))
tipyLens a -> f a
f (TIP HList (Tagged x x : xs)
s) =
case forall (n :: HNat) (xsys :: [*]) (xs :: [*]) (ys :: [*]).
HSplitAt n xsys xs ys =>
Proxy n -> HList xsys -> (HList xs, HList ys)
hSplitAt (forall {k} a (s :: [*]) (n :: HNat) (f :: k -> *) (b :: k).
HFind (Label a) (LabelsOf s) n =>
HList s -> (a -> f b) -> Proxy n
getN HList (Tagged x x : xs)
s a -> f a
f) (forall x (xs :: [*]).
HList (Tagged x x : xs) -> HList (Tagged x x : xs)
ghc8fix1 HList (Tagged x x : xs)
s) of
(HList l1
x, ta :: Tagged a a
ta@(Tagged a
a) `HCons` HList xs
ys)
| () <- forall a. Tagged a a -> ()
ghc8fix2 Tagged a a
ta ->
let mkt :: a -> TIP (HAppendListR l1 (Tagged a a : xs))
mkt a
b = forall (l :: [*]). HTypeIndexed l => HList l -> TIP l
mkTIP (HList l1
x forall (l1 :: [*]) (l2 :: [*]).
HAppendList l1 l2 =>
HList l1 -> HList l2 -> HList (HAppendListR l1 l2)
`hAppendList` (forall a. a -> Tagged a a
tagSelf a
b forall x (xs :: [*]). x -> HList xs -> HList (x : xs)
`HCons` HList xs
ys))
in a -> TIP (HAppendListR l1 (Tagged a a : xs))
mkt forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
f a
a
where
getN :: HFind (Label a) (LabelsOf s) n => HList s -> (a -> f b) -> Proxy n
getN :: forall {k} a (s :: [*]) (n :: HNat) (f :: k -> *) (b :: k).
HFind (Label a) (LabelsOf s) n =>
HList s -> (a -> f b) -> Proxy n
getN HList s
_ a -> f b
_ = forall {k} (t :: k). Proxy t
Proxy
ghc8fix1 :: HList (Tagged x x ': xs) -> HList (Tagged x x ': xs)
ghc8fix1 :: forall x (xs :: [*]).
HList (Tagged x x : xs) -> HList (Tagged x x : xs)
ghc8fix1 = forall a. a -> a
id
ghc8fix2 :: Tagged a a -> ()
ghc8fix2 :: forall a. Tagged a a -> ()
ghc8fix2 Tagged a a
_ = ()
tipyProject2 :: proxy ls -> TIP r -> (TIP l, TIP l)
tipyProject2 proxy ls
ps (TIP HList r
l) = (forall (l :: [*]). HTypeIndexed l => HList l -> TIP l
mkTIP HList l
l',forall (l :: [*]). HTypeIndexed l => HList l -> TIP l
mkTIP HList l
l'')
where
(HList l
l',HList l
l'') = forall (ls :: [*]) (r :: [*]) (rin :: [*]) (rout :: [*])
(proxy :: [*] -> *).
H2ProjectByLabels ls r rin rout =>
proxy ls -> HList r -> (HList rin, HList rout)
h2projectByLabels proxy ls
ps HList r
l
instance SubType (TIP l) (TIP '[])
instance (HOccurs e (TIP l1), SubType (TIP l1) (TIP l2))
=> SubType (TIP l1) (TIP (e ': l2))
class SameLength a ta => TagUntagFD a ta | a -> ta, ta -> a where
hTagSelf :: HList a -> HList ta
hUntagSelf :: HList ta -> HList a
instance TagUntagFD '[] '[] where
hTagSelf :: HList '[] -> HList '[]
hTagSelf HList '[]
_ = HList '[]
HNil
hUntagSelf :: HList '[] -> HList '[]
hUntagSelf HList '[]
_ = HList '[]
HNil
instance (TagUntagFD xs ys, txx ~ Tagged x x)
=> TagUntagFD (x ': xs) (txx ': ys) where
hTagSelf :: HList (x : xs) -> HList (txx : ys)
hTagSelf (HCons x
x HList xs
xs) = forall {k} (s :: k) b. b -> Tagged s b
Tagged x
x forall x (xs :: [*]). x -> HList xs -> HList (x : xs)
`HCons` forall (a :: [*]) (ta :: [*]).
TagUntagFD a ta =>
HList a -> HList ta
hTagSelf HList xs
xs
hUntagSelf :: HList (txx : ys) -> HList (x : xs)
hUntagSelf (HCons (Tagged x
x) HList ys
xs) = x
x forall x (xs :: [*]). x -> HList xs -> HList (x : xs)
`HCons` forall (a :: [*]) (ta :: [*]).
TagUntagFD a ta =>
HList ta -> HList a
hUntagSelf HList ys
xs
type TagUntag xs = TagUntagFD xs (TagR xs)
type UntagTag xs = (TagR (UntagR xs) ~ xs, TagUntagFD (UntagR xs) xs)
type family TagR (a :: [*]) :: [*]
type family UntagR (ta :: [*]) :: [*]
type instance TagR '[] = '[]
type instance UntagR '[] = '[]
type instance TagR (x ': xs) = Tagged x x ': TagR xs
type instance UntagR (Tagged y y ': ys) = y ': UntagR ys
type family Untag1 (x :: *) :: *
type instance Untag1 (Tagged k x) = x
tipHList :: p (HList a) (f (HList a)) -> p (TIP ta) (f (TIP l))
tipHList p (HList a) (f (HList a))
x = forall (p :: * -> * -> *) (f :: * -> *) s a b t.
(Profunctor p, Functor f) =>
(s -> a) -> (b -> t) -> p a (f b) -> p s (f t)
iso (\(TIP HList ta
a) -> forall (a :: [*]) (ta :: [*]).
TagUntagFD a ta =>
HList ta -> HList a
hUntagSelf HList ta
a) (forall (l :: [*]). HList l -> TIP l
TIP forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (a :: [*]) (ta :: [*]).
TagUntagFD a ta =>
HList a -> HList ta
hTagSelf) p (HList a) (f (HList a))
x
tipHList' :: p (HList a) (f (HList a)) -> p (TIP l) (f (TIP l))
tipHList' p (HList a) (f (HList a))
x = forall {k1} {k2} optic (p :: k1 -> k2 -> *) (a :: k1)
(f :: k1 -> k2) (s :: k1).
(optic ~ (p a (f a) -> p s (f s))) =>
optic -> optic
isSimple forall {p :: * -> * -> *} {f :: * -> *} {a :: [*]} {ta :: [*]}
{a :: [*]} {l :: [*]}.
(Profunctor p, Functor f, TagUntagFD a ta, TagUntagFD a l) =>
p (HList a) (f (HList a)) -> p (TIP ta) (f (TIP l))
tipHList p (HList a) (f (HList a))
x
tipRecord :: p (Record r) (f (Record l)) -> p (TIP r) (f (TIP l))
tipRecord p (Record r) (f (Record l))
x = forall (p :: * -> * -> *) (f :: * -> *) b t a s.
(Profunctor p, Functor f, Coercible b t, Coercible a s) =>
(s -> a) -> (b -> t) -> p a (f b) -> p s (f t)
isoNewtype (\(TIP HList r
a) -> forall (r :: [*]). HList r -> Record r
Record HList r
a) (\(Record HList l
b) -> forall (l :: [*]). HList l -> TIP l
TIP HList l
b) p (Record r) (f (Record l))
x
tipRecord' :: p (Record l) (f (Record l)) -> p (TIP l) (f (TIP l))
tipRecord' p (Record l) (f (Record l))
x = forall {k1} {k2} optic (p :: k1 -> k2 -> *) (a :: k1)
(f :: k1 -> k2) (s :: k1).
(optic ~ (p a (f a) -> p s (f s))) =>
optic -> optic
isSimple forall {p :: * -> * -> *} {f :: * -> *} {r :: [*]} {l :: [*]}.
(Profunctor p, Functor f) =>
p (Record r) (f (Record l)) -> p (TIP r) (f (TIP l))
tipRecord p (Record l) (f (Record l))
x
#if __GLASGOW_HASKELL__ < 800
instance (HZipList (UntagR x) (UntagR y) (UntagR xy),
UntagTag x, UntagTag y, UntagTag xy,
SameLengths [x,y,xy],
HTypeIndexed x, HTypeIndexed y,
HUnzip TIP x y xy
) => HZip TIP x y xy where
hZip = hZipTIP
instance (HZipList (UntagR x) (UntagR y) (UntagR xy),
UntagTag x, UntagTag y, UntagTag xy,
HTypeIndexed x, HTypeIndexed y,
SameLengths [x,y,xy]) => HUnzip TIP x y xy where
hUnzip = hUnzipTIP
#else
instance (HZipList xL yL xyL,
lty ~ (HList xyL -> (HList xL,HList yL)),
Coercible lty (TIP xy -> (TIP x, TIP y)),
UntagR x ~ xL, TagR xL ~ x,
UntagR y ~ yL, TagR yL ~ y,
UntagR xy ~ xyL, TagR xyL ~ xy,
SameLengths '[x,y,xy],
UntagTag x, UntagTag y, UntagTag xy
) => HUnzip TIP x y xy where
hUnzip :: TIP xy -> (TIP x, TIP y)
hUnzip = coerce :: forall a b. Coercible a b => a -> b
coerce (forall (x :: [*]) (y :: [*]) (l :: [*]).
HZipList x y l =>
HList l -> (HList x, HList y)
hUnzipList :: lty)
instance (HUnzip TIP x y xy,
HZipList xL yL xyL,
lty ~ (HList xL -> HList yL -> HList xyL),
Coercible lty (TIP x -> TIP y -> TIP xy) ,
UntagR x ~ xL,
UntagR y ~ yL,
UntagR xy ~ xyL,
UntagTag x, UntagTag y, UntagTag xy
) => HZip TIP x y xy where
hZip :: TIP x -> TIP y -> TIP xy
hZip = coerce :: forall a b. Coercible a b => a -> b
coerce (forall (x :: [*]) (y :: [*]) (l :: [*]).
HZipList x y l =>
HList x -> HList y -> HList l
hZipList :: lty)
#endif
hZipTIP :: TIP ta -> TIP ta -> TIP l
hZipTIP (TIP HList ta
x) (TIP HList ta
y) = forall (l :: [*]). HList l -> TIP l
TIP (forall (a :: [*]) (ta :: [*]).
TagUntagFD a ta =>
HList a -> HList ta
hTagSelf (forall (x :: [*]) (y :: [*]) (l :: [*]).
HZipList x y l =>
HList x -> HList y -> HList l
hZipList (forall (a :: [*]) (ta :: [*]).
TagUntagFD a ta =>
HList ta -> HList a
hUntagSelf HList ta
x) (forall (a :: [*]) (ta :: [*]).
TagUntagFD a ta =>
HList ta -> HList a
hUntagSelf HList ta
y)))
hUnzipTIP :: TIP ta -> (TIP l, TIP l)
hUnzipTIP (TIP HList ta
xy) = case forall (x :: [*]) (y :: [*]) (l :: [*]).
HZipList x y l =>
HList l -> (HList x, HList y)
hUnzipList (forall (a :: [*]) (ta :: [*]).
TagUntagFD a ta =>
HList ta -> HList a
hUntagSelf HList ta
xy) of
(HList a
x,HList a
y) -> (forall (l :: [*]). HTypeIndexed l => HList l -> TIP l
mkTIP (forall (a :: [*]) (ta :: [*]).
TagUntagFD a ta =>
HList a -> HList ta
hTagSelf HList a
x), forall (l :: [*]). HTypeIndexed l => HList l -> TIP l
mkTIP (forall (a :: [*]) (ta :: [*]).
TagUntagFD a ta =>
HList a -> HList ta
hTagSelf HList a
y))
class TransTIP op db where
ttip :: op -> TIP db -> TIP db
instance (HMember (Tagged op op) db b,
Arity op n,
TransTIP1 b n op db)
=> TransTIP op db where
ttip :: op -> TIP db -> TIP db
ttip = forall (b :: Bool) (n :: HNat) op (db :: [*]).
TransTIP1 b n op db =>
Proxy b -> Proxy n -> op -> TIP db -> TIP db
ttip1 (forall {k} (t :: k). Proxy t
Proxy ::Proxy b) (forall {k} (t :: k). Proxy t
Proxy :: Proxy n)
class TransTIP1 (b :: Bool) (n :: HNat) op db where
ttip1 :: Proxy b -> Proxy n -> op -> TIP db -> TIP db
instance HTPupdateAtLabel TIP op op db
=> TransTIP1 True n op db where
ttip1 :: Proxy 'True -> Proxy n -> op -> TIP db -> TIP db
ttip1 Proxy 'True
_ Proxy n
_ = forall {record :: [*] -> *} {v} {r :: [*]}.
(HUpdateAtLabel record v v r r, SameLength' r r) =>
v -> record r -> record r
tipyUpdate
instance (HMember (Tagged arg arg) db b,
TransTIP2 b arg op db)
=> TransTIP1 False (HSucc n) (arg -> op) db where
ttip1 :: Proxy 'False -> Proxy ('HSucc n) -> (arg -> op) -> TIP db -> TIP db
ttip1 Proxy 'False
_ Proxy ('HSucc n)
_ = forall (b :: Bool) arg op (db :: [*]).
TransTIP2 b arg op db =>
Proxy b -> (arg -> op) -> TIP db -> TIP db
ttip2 (forall {k} (t :: k). Proxy t
Proxy :: Proxy b)
instance Fail (FieldNotFound notfun (TIP db))
=> TransTIP1 False HZero notfun db where
ttip1 :: Proxy 'False -> Proxy 'HZero -> notfun -> TIP db -> TIP db
ttip1 = forall a. HasCallStack => String -> a
error String
"TransTIP1 Fail failed"
class TransTIP2 (b :: Bool) arg op db where
ttip2 :: Proxy b -> (arg -> op) -> TIP db -> TIP db
instance (HOccurs arg (TIP db),
TransTIP op db)
=> TransTIP2 True arg op db where
ttip2 :: Proxy 'True -> (arg -> op) -> TIP db -> TIP db
ttip2 Proxy 'True
_ arg -> op
f TIP db
db = forall op (db :: [*]). TransTIP op db => op -> TIP db -> TIP db
ttip (arg -> op
f (forall e l. HOccurs e l => l -> e
hOccurs TIP db
db)) TIP db
db
instance Fail (FieldNotFound arg (TIP db))
=> TransTIP2 False arg op db where
ttip2 :: Proxy 'False -> (arg -> op) -> TIP db -> TIP db
ttip2 = forall a. HasCallStack => String -> a
error String
"TransTIP2 Fail failed"
class Monad m => TransTIPM m op db where
ttipM :: op -> TIP db -> m (TIP db)
instance (Monad m, HMember (Tagged op op) db b,
Arity (m' op) n,
TransTIPM1 b n m (m' op) db)
=> TransTIPM m (m' op) db where
ttipM :: m' op -> TIP db -> m (TIP db)
ttipM = forall (b :: Bool) (n :: HNat) (m :: * -> *) op (db :: [*]).
TransTIPM1 b n m op db =>
Proxy b -> Proxy n -> op -> TIP db -> m (TIP db)
ttipM1 (forall {k} (t :: k). Proxy t
Proxy :: Proxy b) (forall {k} (t :: k). Proxy t
Proxy :: Proxy n)
class Monad m => TransTIPM1 (b :: Bool) (n :: HNat) m op db where
ttipM1 :: Proxy b -> Proxy n -> op -> TIP db -> m (TIP db)
instance (Monad m, m ~ m', HTPupdateAtLabel TIP op op db)
=> TransTIPM1 True n m (m' op) db where
ttipM1 :: Proxy 'True -> Proxy n -> m' op -> TIP db -> m (TIP db)
ttipM1 Proxy 'True
_ Proxy n
_ m' op
op TIP db
db = do
op
op' <- m' op
op
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall {record :: [*] -> *} {v} {r :: [*]}.
(HUpdateAtLabel record v v r r, SameLength' r r) =>
v -> record r -> record r
tipyUpdate op
op' TIP db
db
instance (Fail (FieldNotFound op (TIP db)), Monad m)
=> TransTIPM1 False HZero m op db where
ttipM1 :: Proxy 'False -> Proxy 'HZero -> op -> TIP db -> m (TIP db)
ttipM1 Proxy 'False
_ Proxy 'HZero
_ = forall a. HasCallStack => String -> a
error String
"TransTIPM1 Fail failed"
instance (Monad m,
HMember (Tagged arg arg) db b,
TransTIPM2 b m arg op db)
=> TransTIPM1 False (HSucc n) m (arg-> op) db where
ttipM1 :: Proxy 'False
-> Proxy ('HSucc n) -> (arg -> op) -> TIP db -> m (TIP db)
ttipM1 Proxy 'False
_ Proxy ('HSucc n)
_ = forall (b :: Bool) (m :: * -> *) arg op (db :: [*]).
TransTIPM2 b m arg op db =>
Proxy b -> (arg -> op) -> TIP db -> m (TIP db)
ttipM2 (forall {k} (t :: k). Proxy t
Proxy :: Proxy b)
class TransTIPM2 (b :: Bool) m arg op db where
ttipM2 :: Proxy b -> (arg -> op) -> TIP db -> m (TIP db)
instance (HOccurs arg (TIP db), TransTIPM m op db)
=> TransTIPM2 True m arg op db where
ttipM2 :: Proxy 'True -> (arg -> op) -> TIP db -> m (TIP db)
ttipM2 Proxy 'True
_ arg -> op
f TIP db
db = forall (m :: * -> *) op (db :: [*]).
TransTIPM m op db =>
op -> TIP db -> m (TIP db)
ttipM (arg -> op
f (forall e l. HOccurs e l => l -> e
hOccurs TIP db
db)) TIP db
db
instance Fail (FieldNotFound op (TIP db))
=> TransTIPM2 False m arg op db where
ttipM2 :: Proxy 'False -> (arg -> op) -> TIP db -> m (TIP db)
ttipM2 Proxy 'False
_ arg -> op
_ = forall a. HasCallStack => String -> a
error String
"TransTIPM1 Fail failed"
(Char, Bool)
_ = forall {t1} {r :: [*] -> *} {v1 :: [*]} {v2 :: [*]} {t2}
{v3 :: [*]} {v'1 :: [*]} {v'2 :: [*]}.
(HOccurs t1 (r v1), HOccurs t1 (r v2), HOccurs t2 (r v2),
HOccurs t2 (r v3), HDeleteAtLabel r t1 v1 v'1,
HDeleteAtLabel r t1 v2 v3, HDeleteAtLabel r t2 v2 v1,
HDeleteAtLabel r t2 v3 v'2) =>
r v2 -> (t2, t1)
tipyTuple ( Char
'1' forall e l. HExtend e l => e -> l -> HExtendR e l
.*. Bool
True forall e l. HExtend e l => e -> l -> HExtendR e l
.*. TIP '[]
emptyTIP ) :: (Char, Bool)
(Bool, Char)
_ = forall {t1} {r :: [*] -> *} {v1 :: [*]} {v2 :: [*]} {t2}
{v3 :: [*]} {v'1 :: [*]} {v'2 :: [*]}.
(HOccurs t1 (r v1), HOccurs t1 (r v2), HOccurs t2 (r v2),
HOccurs t2 (r v3), HDeleteAtLabel r t1 v1 v'1,
HDeleteAtLabel r t1 v2 v3, HDeleteAtLabel r t2 v2 v1,
HDeleteAtLabel r t2 v3 v'2) =>
r v2 -> (t2, t1)
tipyTuple ( Char
'1' forall e l. HExtend e l => e -> l -> HExtendR e l
.*. Bool
True forall e l. HExtend e l => e -> l -> HExtendR e l
.*. TIP '[]
emptyTIP ) :: (Bool, Char)