@@ -1,1021 +0,0 @@
1−{-# language AllowAmbiguousTypes #-}
2−{-# language DataKinds #-}
3−{-# language DisambiguateRecordFields #-}
4−{-# language DefaultSignatures #-}
5−{-# language FlexibleContexts #-}
6−{-# language FlexibleInstances #-}
8−{-# language MultiParamTypeClasses #-}
9−{-# language ScopedTypeVariables #-}
10−{-# language StandaloneKindSignatures #-}
11−{-# language TypeApplications #-}
12−{-# language TypeFamilies #-}
13−{-# language TypeOperators #-}
14−{-# language UndecidableInstances #-}
15−{-# language ViewPatterns #-}
17−{-# options_ghc -fno-warn-orphans #-}
19−module Rel8.Schema.Generic
25−import Data.Bifunctor ( bimap )
26−import Data.Kind ( Constraint, Type )
27−import Data.List.NonEmpty ( NonEmpty )
29− ( Generic, Rep, from, to
30− , (:*:)( (:*:) ), K1( K1 ), M1( M1 )
34−import GHC.TypeLits ( Symbol )
38−import Rel8.Kind.Necessity
39− ( SNecessity( SRequired, SOptional )
40− , KnownNecessity, necessitySing
42−import Rel8.Schema.Context
43− ( Aggregation( Aggregation )
45− , Insertion( RequiredInsert, OptionalInsert )
49−import Rel8.Schema.Context.Label ( Labelable, labeler, unlabeler )
50−import Rel8.Schema.Context.Nullify ( Nullifiable )
51−import Rel8.Schema.Context.Result
52− ( fromHEitherTable, toHEitherTable
53− , fromHListTable, toHListTable
54− , fromHMaybeTable, toHMaybeTable
55− , fromHNonEmptyTable, toHNonEmptyTable
56− , fromHTheseTable, toHTheseTable
58−import Rel8.Schema.Field ( Field )
59−import Rel8.Schema.HTable ( HTable )
60−import Rel8.Schema.HTable.Context ( H, HKTable )
61−import Rel8.Schema.HTable.Either ( HEitherTable )
62−import Rel8.Schema.HTable.Identity ( HIdentity(..) )
63−import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel )
64−import Rel8.Schema.HTable.List ( HListTable )
65−import Rel8.Schema.HTable.Maybe ( HMaybeTable )
66−import Rel8.Schema.HTable.NonEmpty ( HNonEmptyTable )
67−import Rel8.Schema.HTable.Pair ( HPair(..) )
68−import Rel8.Schema.HTable.Quartet ( HQuartet(..) )
69−import Rel8.Schema.HTable.Quintet ( HQuintet(..) )
70−import Rel8.Schema.HTable.These ( HTheseTable )
71−import Rel8.Schema.HTable.Trio ( HTrio(..) )
72−import Rel8.Schema.HTable.Vectorize ( hrelabel )
73−import Rel8.Schema.Spec ( Spec( Spec ), KTable )
74−import qualified Rel8.Schema.Spec as Kind ( Context )
75−import Rel8.Schema.Structure
76− ( IsStructure, Shape(..), Shape1, Shape2
80− ( Table, Columns, Context, fromColumns, toColumns
82−import Rel8.Table.Either ( EitherTable )
83−import Rel8.Table.Lifted
84− ( fromColumns1, toColumns1
85− , fromColumns2, toColumns2
87−import Rel8.Table.List ( ListTable )
88−import Rel8.Table.Maybe ( MaybeTable(..) )
89−import Rel8.Table.NonEmpty ( NonEmptyTable )
90−import Rel8.Table.These ( TheseTable )
93−import Data.These ( These )
96−instance (Rel8able t, TableHelper (IsSpecialContext context) context) =>
97− Table context (t context)
99− type Columns (t context) = GRep t
100− type Context (t context) = context
101− fromColumns = gfromColumns
102− toColumns = gtoColumns
105−type TableHelper :: Bool -> Kind.Context -> Constraint
106−class IsSpecialContext context ~ isSpecialContext =>
107− TableHelper isSpecialContext context
109− gfromColumns :: Rel8able t => GRep t (H context) -> t context
110− gtoColumns :: Rel8able t => t context -> GRep t (H context)
113−instance TableHelper 'True Aggregation where
114− gfromColumns = fromAggregationColumns
115− gtoColumns = toAggregationColumns
118−instance TableHelper 'True DB where
119− gfromColumns = fromDBColumns
120− gtoColumns = toDBColumns
123−instance TableHelper 'True Insertion where
124− gfromColumns = fromInsertionColumns
125− gtoColumns = toInsertionColumns
128−instance TableHelper 'True Result where
129− gfromColumns = fromResultColumns
130− gtoColumns = toResultColumns
133−instance (IsSpecialContext context ~ 'False, Labelable context, Nullifiable context) =>
134− TableHelper 'False context
136− gfromColumns = fromUnspecialColumns
137− gtoColumns = toUnspecialColumns
140−type Rel8able :: KTable -> Constraint
141−class HTable (GRep t) => Rel8able t where
142− type GRep t :: HKTable
144− fromAggregationColumns :: GRep t (H Aggregation) -> t Aggregation
145− toAggregationColumns :: t Aggregation -> GRep t (H Aggregation)
147− fromDBColumns :: GRep t (H DB) -> t DB
148− toDBColumns :: t DB -> GRep t (H DB)
150− fromInsertionColumns :: GRep t (H Insertion) -> t Insertion
151− toInsertionColumns :: t Insertion -> GRep t (H Insertion)
153− fromResultColumns :: GRep t (H Result) -> t Result
154− toResultColumns :: t Result -> GRep t (H Result)
156− fromUnspecialColumns ::
157− ( IsSpecialContext context ~ 'False
158− , Labelable context, Nullifiable context
160− => GRep t (H context) -> t context
161− toUnspecialColumns ::
162− ( IsSpecialContext context ~ 'False
163− , Labelable context, Nullifiable context
165− => t context -> GRep t (H context)
167− type GRep t = GColumns (Rep (t Structure))
169− default fromAggregationColumns ::
170− ( Generic (t Aggregation)
171− , GColumns (Rep (t Structure)) ~ GRep t
172− , GRel8able Aggregation (Rep (t Structure)) (Rep (t Aggregation))
173− ) => GRep t (H Aggregation) -> t Aggregation
174− fromAggregationColumns = to . fromGColumns @_ @(Rep (t Structure))
176− default toAggregationColumns ::
177− ( Generic (t Aggregation)
178− , GColumns (Rep (t Structure)) ~ GRep t
179− , GRel8able Aggregation (Rep (t Structure)) (Rep (t Aggregation))
180− ) => t Aggregation -> GRep t (H Aggregation)
181− toAggregationColumns = toGColumns @_ @(Rep (t Structure)) . from
183− default fromDBColumns ::
185− , GColumns (Rep (t Structure)) ~ GRep t
186− , GRel8able DB (Rep (t Structure)) (Rep (t DB))
187− ) => GRep t (H DB) -> t DB
188− fromDBColumns = to . fromGColumns @_ @(Rep (t Structure))
190− default toDBColumns ::
192− , GColumns (Rep (t Structure)) ~ GRep t
193− , GRel8able DB (Rep (t Structure)) (Rep (t DB))
194− ) => t DB -> GRep t (H DB)
195− toDBColumns = toGColumns @_ @(Rep (t Structure)) . from
197− default fromInsertionColumns ::
198− ( Generic (t Insertion)
199− , GColumns (Rep (t Structure)) ~ GRep t
200− , GRel8able Insertion (Rep (t Structure)) (Rep (t Insertion))
201− ) => GRep t (H Insertion) -> t Insertion
202− fromInsertionColumns = to . fromGColumns @_ @(Rep (t Structure))
204− default toInsertionColumns ::
205− ( Generic (t Insertion)
206− , GColumns (Rep (t Structure)) ~ GRep t
207− , GRel8able Insertion (Rep (t Structure)) (Rep (t Insertion))
208− ) => t Insertion -> GRep t (H Insertion)
209− toInsertionColumns = toGColumns @_ @(Rep (t Structure)) . from
211− default fromResultColumns ::
212− ( Generic (t Result)
213− , GColumns (Rep (t Structure)) ~ GRep t
214− , GRel8able Result (Rep (t Structure)) (Rep (t Result))
215− ) => GRep t (H Result) -> t Result
216− fromResultColumns = to . fromGColumns @_ @(Rep (t Structure))
218− default toResultColumns ::
219− ( Generic (t Result)
220− , GColumns (Rep (t Structure)) ~ GRep t
221− , GRel8able Result (Rep (t Structure)) (Rep (t Result))
222− ) => t Result -> GRep t (H Result)
223− toResultColumns = toGColumns @_ @(Rep (t Structure)) . from
225− default fromUnspecialColumns ::
226− ( Generic (t context)
227− , GColumns (Rep (t Structure)) ~ GRep t
228− , GRel8able context (Rep (t Structure)) (Rep (t context))
229− ) => GRep t (H context) -> t context
230− fromUnspecialColumns = to . fromGColumns @_ @(Rep (t Structure))
232− default toUnspecialColumns ::
233− ( Generic (t context)
234− , GColumns (Rep (t Structure)) ~ GRep t
235− , GRel8able context (Rep (t Structure)) (Rep (t context))
236− ) => t context -> GRep t (H context)
237− toUnspecialColumns = toGColumns @_ @(Rep (t Structure)) . from
240−type GColumns :: (Type -> Type) -> HKTable
241−type family GColumns structure where
242− GColumns (M1 D _ structure) = GColumns structure
243− GColumns (M1 C _ structure) = GColumns structure
244− GColumns (a :*: b) = HPair (GColumns a) (GColumns b)
245− GColumns (M1 S ('MetaSel ('Just label) _ _ _) (K1 _ structure)) =
246− K1Columns label structure
249−type GRel8able :: Kind.Context -> (Type -> Type) -> (Type -> Type) -> Constraint
250−class GRel8able context structure rep where
251− fromGColumns :: GColumns structure (H context) -> rep x
252− toGColumns :: rep x -> GColumns structure (H context)
255−instance GRel8able context structure rep => GRel8able context (M1 D c structure) (M1 D c rep) where
256− fromGColumns = M1 . fromGColumns @context @structure @rep
257− toGColumns (M1 a) = toGColumns @context @structure @rep a
260−instance GRel8able context structure rep => GRel8able context (M1 C c structure) (M1 C c rep) where
261− fromGColumns = M1 . fromGColumns @context @structure @rep
262− toGColumns (M1 a) = toGColumns @context @structure @rep a
265−instance (GRel8able context structure1 rep1, GRel8able context structure2 rep2) =>
266− GRel8able context (structure1 :*: structure2) (rep1 :*: rep2)
268− fromGColumns (HPair a b) =
269− fromGColumns @context @structure1 @rep1 a :*:
270− fromGColumns @context @structure2 @rep2 b
271− toGColumns (a :*: b) =
273− (toGColumns @context @structure1 @rep1 a)
274− (toGColumns @context @structure2 @rep2 b)
278− ( K1Table label isSpecialContext context isStructure structure a
279− , meta ~ 'MetaSel ('Just label) _su _ss _ds
280− , structureK1 ~ K1 i structure
282− ) => GRel8able context (M1 S meta structureK1) (M1 S meta k1)
284− fromGColumns = M1 . K1 . fromK1Columns @label @_ @_ @_ @structure
285− toGColumns (M1 (K1 a)) = toK1Columns @label @_ @_ @_ @structure a
288−type K1Columns :: Symbol -> Type -> HKTable
289−type family K1Columns label structure where
290− K1Columns label (Shape1 'Column ('Spec '[] necessity nullability blueprint)) =
291− HIdentity ('Spec '[label] necessity nullability blueprint)
292− K1Columns _label (Shape1 'Column ('Spec (label ': labels) necessity nullability blueprint)) =
293− HIdentity ('Spec (label ': labels) necessity nullability blueprint)
294− K1Columns label (Shape2 'Either a b) =
295− HLabel label (HEitherTable (K1Columns "Left" a) (K1Columns "Right" b))
296− K1Columns label (Shape1 'List a) = HListTable (K1Columns label a)
297− K1Columns label (Shape1 'Maybe a) = HLabel label (HMaybeTable (K1Columns "Just" a))
298− K1Columns label (Shape1 'NonEmpty a) = HNonEmptyTable (K1Columns label a)
299− K1Columns label (Shape2 'These a b) =
300− HLabel label (HTheseTable (K1Columns "Here" a) (K1Columns "There" b))
301− K1Columns label (a, b) =
305− (K1Columns "snd" b))
306− K1Columns label (a, b, c) =
311− (K1Columns "trd" c))
312− K1Columns label (a, b, c, d) =
318− (K1Columns "frt" d))
319− K1Columns label (a, b, c, d, e) =
326− (K1Columns "fft" e))
327− K1Columns label a = HLabel label (Columns a)
330−type K1Table :: Symbol -> Bool -> Kind.Context -> Bool -> Type -> Type -> Constraint
332− ( isSpecialContext ~ IsSpecialContext context
333− , isStructure ~ IsStructure structure
334− ) => K1Table label isSpecialContext context isStructure structure a
336− fromK1Columns :: K1Columns label structure (H context) -> a
337− toK1Columns :: a -> K1Columns label structure (H context)
341− ( x ~ Field Aggregation '[] necessity db a
342− ) => K1Table label 'True Aggregation 'True (Shape1 'Column ('Spec '[] necessity db a)) x
344− fromK1Columns (HIdentity (Aggregation a)) = a
345− toK1Columns = HIdentity . Aggregation
346− {-# INLINABLE fromK1Columns #-}
347− {-# INLINABLE toK1Columns #-}
351− ( x ~ Field Aggregation (label ': labels) necessity db a
352− ) => K1Table _label 'True Aggregation 'True (Shape1 'Column ('Spec (label ': labels) necessity db a)) x
354− fromK1Columns (HIdentity (Aggregation a)) = a
355− toK1Columns = HIdentity . Aggregation
356− {-# INLINABLE fromK1Columns #-}
357− {-# INLINABLE toK1Columns #-}
361− ( x ~ Field DB '[] necessity db a
362− ) => K1Table label 'True DB 'True (Shape1 'Column ('Spec '[] necessity db a)) x
364− fromK1Columns (HIdentity (DB a)) = a
365− toK1Columns = HIdentity . DB
366− {-# INLINABLE fromK1Columns #-}
367− {-# INLINABLE toK1Columns #-}
371− ( x ~ Field DB (label ': labels) necessity db a
372− ) => K1Table _label 'True DB 'True (Shape1 'Column ('Spec (label ': labels) necessity db a)) x
374− fromK1Columns (HIdentity (DB a)) = a
375− toK1Columns = HIdentity . DB
376− {-# INLINABLE fromK1Columns #-}
377− {-# INLINABLE toK1Columns #-}
381− ( x ~ Field Insertion '[] necessity db a
382− , KnownNecessity necessity
383− ) => K1Table label 'True Insertion 'True (Shape1 'Column ('Spec '[] necessity db a)) x
385− fromK1Columns (HIdentity insert) = case insert of
386− RequiredInsert a -> a
387− OptionalInsert ma -> ma
388− toK1Columns a = HIdentity $ case necessitySing @necessity of
389− SRequired -> RequiredInsert a
390− SOptional -> OptionalInsert a
391− {-# INLINABLE fromK1Columns #-}
392− {-# INLINABLE toK1Columns #-}
396− ( x ~ Field Insertion (label ': labels) necessity db a
397− , KnownNecessity necessity
398− ) => K1Table _label 'True Insertion 'True (Shape1 'Column ('Spec (label ': labels) necessity db a)) x
400− fromK1Columns (HIdentity insert) = case insert of
401− RequiredInsert a -> a
402− OptionalInsert ma -> ma
403− toK1Columns a = HIdentity $ case necessitySing @necessity of
404− SRequired -> RequiredInsert a
405− SOptional -> OptionalInsert a
406− {-# INLINABLE fromK1Columns #-}
407− {-# INLINABLE toK1Columns #-}
411− ( x ~ Field Result '[] necessity db a
412− ) => K1Table label 'True Result 'True (Shape1 'Column ('Spec '[] necessity db a)) x
414− fromK1Columns (HIdentity (Result a)) = a
415− toK1Columns = HIdentity . Result
416− {-# INLINABLE fromK1Columns #-}
417− {-# INLINABLE toK1Columns #-}
421− ( x ~ Field Result (label ': labels) necessity db a
422− ) => K1Table _label 'True Result 'True (Shape1 'Column ('Spec (label ': labels) necessity db a)) x
424− fromK1Columns (HIdentity (Result a)) = a
425− toK1Columns = HIdentity . Result
426− {-# INLINABLE fromK1Columns #-}
427− {-# INLINABLE toK1Columns #-}
431− ( IsSpecialContext context ~ 'False
432− , x ~ context ('Spec (label ': labels) necessity db a)
433− ) => K1Table _label 'False context 'True (Shape1 'Column ('Spec (label ': labels) necessity db a)) x
435− fromK1Columns = unHIdentity
436− toK1Columns = HIdentity
437− {-# INLINABLE fromK1Columns #-}
438− {-# INLINABLE toK1Columns #-}
442− ( IsSpecialContext context ~ 'False
443− , x ~ context ('Spec '[] necessity db a)
445− ) => K1Table label 'False context 'True (Shape1 'Column ('Spec '[] necessity db a)) x
447− fromK1Columns = unlabeler . unHIdentity
448− toK1Columns = HIdentity . labeler
449− {-# INLINABLE fromK1Columns #-}
450− {-# INLINABLE toK1Columns #-}
454− ( HTable (K1Columns "Left" structure1)
455− , HTable (K1Columns "Right" structure2)
456− , K1Table "Left" 'True Aggregation (IsStructure structure1) structure1 a
457− , K1Table "Right" 'True Aggregation (IsStructure structure2) structure2 b
458− , e ~ EitherTable a b
459− ) => K1Table label 'True Aggregation 'True (Shape2 'Either structure1 structure2) e
463− (fromK1Columns @"Left" @_ @_ @_ @structure1)
464− (fromK1Columns @"Right" @_ @_ @_ @structure2) .
469− (toK1Columns @"Left" @_ @_ @_ @structure1)
470− (toK1Columns @"Right" @_ @_ @_ @structure2)
471− {-# INLINABLE fromK1Columns #-}
472− {-# INLINABLE toK1Columns #-}
476− ( HTable (K1Columns "Left" structure1)
477− , HTable (K1Columns "Right" structure2)
478− , K1Table "Left" 'True DB (IsStructure structure1) structure1 a
479− , K1Table "Right" 'True DB (IsStructure structure2) structure2 b
480− , e ~ EitherTable a b
481− ) => K1Table label 'True DB 'True (Shape2 'Either structure1 structure2) e
485− (fromK1Columns @"Left" @_ @_ @_ @structure1)
486− (fromK1Columns @"Right" @_ @_ @_ @structure2) .
491− (toK1Columns @"Left" @_ @_ @_ @structure1)
492− (toK1Columns @"Right" @_ @_ @_ @structure2)
493− {-# INLINABLE fromK1Columns #-}
494− {-# INLINABLE toK1Columns #-}
498− ( HTable (K1Columns "Left" structure1)
499− , HTable (K1Columns "Right" structure2)
500− , K1Table "Left" 'True Insertion (IsStructure structure1) structure1 a
501− , K1Table "Right" 'True Insertion (IsStructure structure2) structure2 b
502− , e ~ EitherTable a b
503− ) => K1Table label 'True Insertion 'True (Shape2 'Either structure1 structure2) e
507− (fromK1Columns @"Left" @_ @_ @_ @structure1)
508− (fromK1Columns @"Right" @_ @_ @_ @structure2) .
513− (toK1Columns @"Left" @_ @_ @_ @structure1)
514− (toK1Columns @"Right" @_ @_ @_ @structure2)
515− {-# INLINABLE fromK1Columns #-}
516− {-# INLINABLE toK1Columns #-}
520− ( HTable (K1Columns "Left" structure1)
521− , HTable (K1Columns "Right" structure2)
522− , K1Table "Left" 'True Result (IsStructure structure1) structure1 a
523− , K1Table "Right" 'True Result (IsStructure structure2) structure2 b
525− ) => K1Table label 'True Result 'True (Shape2 'Either structure1 structure2) e
529− (fromK1Columns @"Left" @_ @_ @_ @structure1)
530− (fromK1Columns @"Right" @_ @_ @_ @structure2)
532− . hunlabel unlabeler
537− (toK1Columns @"Left" @_ @_ @_ @structure1)
538− (toK1Columns @"Right" @_ @_ @_ @structure2)
539− {-# INLINABLE fromK1Columns #-}
540− {-# INLINABLE toK1Columns #-}
544− ( HTable (K1Columns "Left" structure1)
545− , HTable (K1Columns "Right" structure2)
546− , K1Table "Left" 'False context (IsStructure structure1) structure1 a
547− , K1Table "Right" 'False context (IsStructure structure2) structure2 b
548− , IsSpecialContext context ~ 'False
550− , Nullifiable context
551− , e ~ EitherTable a b
552− ) => K1Table label 'False context 'True (Shape2 'Either structure1 structure2) e
556− (fromK1Columns @"Left" @_ @_ @_ @structure1)
557− (fromK1Columns @"Right" @_ @_ @_ @structure2) .
562− (toK1Columns @"Left" @_ @_ @_ @structure1)
563− (toK1Columns @"Right" @_ @_ @_ @structure2)
564− {-# INLINABLE fromK1Columns #-}
565− {-# INLINABLE toK1Columns #-}
569− ( K1Table label 'True Aggregation (IsStructure structure) structure a
570− , Table Aggregation a
571− , K1Columns label structure ~ HLabel label (Columns a)
573− ) => K1Table label 'True Aggregation 'True (Shape1 'List structure) as
575− fromK1Columns = fromColumns . hrelabel (hunlabel unlabeler)
576− toK1Columns = hrelabel (hlabel labeler) . toColumns
577− {-# INLINABLE fromK1Columns #-}
578− {-# INLINABLE toK1Columns #-}
582− ( K1Table label 'True DB (IsStructure structure) structure a
584− , K1Columns label structure ~ HLabel label (Columns a)
586− ) => K1Table label 'True DB 'True (Shape1 'List structure) as
588− fromK1Columns = fromColumns . hrelabel (hunlabel unlabeler)
589− toK1Columns = hrelabel (hlabel labeler) . toColumns
590− {-# INLINABLE fromK1Columns #-}
591− {-# INLINABLE toK1Columns #-}
595− ( K1Table label 'True Insertion (IsStructure structure) structure a
597− , K1Columns label structure ~ HLabel label (Columns a)
599− ) => K1Table label 'True Insertion 'True (Shape1 'List structure) as
601− fromK1Columns = fromColumns . hrelabel (hunlabel unlabeler)
602− toK1Columns = hrelabel (hlabel labeler) . toColumns
603− {-# INLINABLE fromK1Columns #-}
604− {-# INLINABLE toK1Columns #-}
608− ( K1Table label 'True Result (IsStructure structure) structure a
609− , HTable (K1Columns label structure)
611− ) => K1Table label 'True Result 'True (Shape1 'List structure) as
613− fromK1Columns = fmap (fromK1Columns @label @'True @Result @_ @structure) . fromHListTable
614− toK1Columns = toHListTable . fmap (toK1Columns @label @'True @Result @_ @structure)
615− {-# INLINABLE fromK1Columns #-}
616− {-# INLINABLE toK1Columns #-}
620− ( K1Table label 'False context (IsStructure structure) structure a
621− , IsSpecialContext context ~ 'False
623− , K1Columns label structure ~ HLabel label (Columns a)
626− ) => K1Table label 'False context 'True (Shape1 'List structure) as
628− fromK1Columns = fromColumns . hrelabel (hunlabel unlabeler)
629− toK1Columns = hrelabel (hlabel labeler) . toColumns
630− {-# INLINABLE fromK1Columns #-}
631− {-# INLINABLE toK1Columns #-}
635− ( HTable (K1Columns "Just" structure)
636− , K1Table "Just" 'True Aggregation (IsStructure structure) structure a
638− ) => K1Table label 'True Aggregation 'True (Shape1 'Maybe structure) ma
641− fromColumns1 (fromK1Columns @"Just" @_ @_ @_ @structure) .
645− toColumns1 (toK1Columns @"Just" @_ @_ @_ @structure)
646− {-# INLINABLE fromK1Columns #-}
647− {-# INLINABLE toK1Columns #-}
651− ( HTable (K1Columns "Just" structure)
652− , K1Table "Just" 'True DB (IsStructure structure) structure a
654− ) => K1Table label 'True DB 'True (Shape1 'Maybe structure) ma
657− fromColumns1 (fromK1Columns @"Just" @_ @_ @_ @structure) .
661− toColumns1 (toK1Columns @"Just" @_ @_ @_ @structure)
662− {-# INLINABLE fromK1Columns #-}
663− {-# INLINABLE toK1Columns #-}
667− ( HTable (K1Columns "Just" structure)
668− , K1Table "Just" 'True Insertion (IsStructure structure) structure a
670− ) => K1Table label 'True Insertion 'True (Shape1 'Maybe structure) ma
673− fromColumns1 (fromK1Columns @"Just" @_ @_ @_ @structure) .
677− toColumns1 (toK1Columns @"Just" @_ @_ @_ @structure)
678− {-# INLINABLE fromK1Columns #-}
679− {-# INLINABLE toK1Columns #-}
683− ( HTable (K1Columns "Just" structure)
684− , K1Table "Just" 'True Result (IsStructure structure) structure a
686− ) => K1Table label 'True Result 'True (Shape1 'Maybe structure) ma
689− = fmap (fromK1Columns @"Just" @_ @_ @_ @structure)
691− . hunlabel unlabeler
695− . fmap (toK1Columns @"Just" @_ @_ @_ @structure)
696− {-# INLINABLE fromK1Columns #-}
697− {-# INLINABLE toK1Columns #-}
701− ( HTable (K1Columns "Just" structure)
702− , K1Table "Just" 'False context (IsStructure structure) structure a
703− , IsSpecialContext context ~ 'False
705− , Nullifiable context
707− ) => K1Table label 'False context 'True (Shape1 'Maybe structure) ma
710− fromColumns1 (fromK1Columns @"Just" @_ @_ @_ @structure) .
714− toColumns1 (toK1Columns @"Just" @_ @_ @_ @structure)
715− {-# INLINABLE fromK1Columns #-}
716− {-# INLINABLE toK1Columns #-}
720− ( K1Table label 'True Aggregation (IsStructure structure) structure a
721− , Table Aggregation a
722− , K1Columns label structure ~ HLabel label (Columns a)
723− , as ~ NonEmptyTable a
724− ) => K1Table label 'True Aggregation 'True (Shape1 'NonEmpty structure) as
726− fromK1Columns = fromColumns . hrelabel (hunlabel unlabeler)
727− toK1Columns = hrelabel (hlabel labeler) . toColumns
728− {-# INLINABLE fromK1Columns #-}
729− {-# INLINABLE toK1Columns #-}
733− ( K1Table label 'True DB (IsStructure structure) structure a
735− , K1Columns label structure ~ HLabel label (Columns a)
736− , as ~ NonEmptyTable a
737− ) => K1Table label 'True DB 'True (Shape1 'NonEmpty structure) as
739− fromK1Columns = fromColumns . hrelabel (hunlabel unlabeler)
740− toK1Columns = hrelabel (hlabel labeler) . toColumns
741− {-# INLINABLE fromK1Columns #-}
742− {-# INLINABLE toK1Columns #-}
746− ( K1Table label 'True Insertion (IsStructure structure) structure a
748− , K1Columns label structure ~ HLabel label (Columns a)
749− , as ~ NonEmptyTable a
750− ) => K1Table label 'True Insertion 'True (Shape1 'NonEmpty structure) as
752− fromK1Columns = fromColumns . hrelabel (hunlabel unlabeler)
753− toK1Columns = hrelabel (hlabel labeler) . toColumns
754− {-# INLINABLE fromK1Columns #-}
755− {-# INLINABLE toK1Columns #-}
759− ( K1Table label 'True Result (IsStructure structure) structure a
760− , HTable (K1Columns label structure)
762− ) => K1Table label 'True Result 'True (Shape1 'NonEmpty structure) as
764− fromK1Columns = fmap (fromK1Columns @label @'True @Result @_ @structure) . fromHNonEmptyTable
765− toK1Columns = toHNonEmptyTable . fmap (toK1Columns @label @'True @Result @_ @structure)
766− {-# INLINABLE fromK1Columns #-}
767− {-# INLINABLE toK1Columns #-}
771− ( K1Table label 'False context (IsStructure structure) structure a
772− , IsSpecialContext context ~ 'False
774− , K1Columns label structure ~ HLabel label (Columns a)
776− , as ~ NonEmptyTable a
777− ) => K1Table label 'False context 'True (Shape1 'NonEmpty structure) as
779− fromK1Columns = fromColumns . hrelabel (hunlabel unlabeler)
780− toK1Columns = hrelabel (hlabel labeler) . toColumns
781− {-# INLINABLE fromK1Columns #-}
782− {-# INLINABLE toK1Columns #-}
786− ( HTable (K1Columns "Here" structure1)
787− , HTable (K1Columns "There" structure2)
788− , K1Table "Here" 'True Aggregation (IsStructure structure1) structure1 a
789− , K1Table "There" 'True Aggregation (IsStructure structure2) structure2 b
790− , e ~ TheseTable a b
791− ) => K1Table label 'True Aggregation 'True (Shape2 'These structure1 structure2) e
795− (fromK1Columns @"Here" @_ @_ @_ @structure1)
796− (fromK1Columns @"There" @_ @_ @_ @structure2) .
801− (toK1Columns @"Here" @_ @_ @_ @structure1)
802− (toK1Columns @"There" @_ @_ @_ @structure2)
803− {-# INLINABLE fromK1Columns #-}
804− {-# INLINABLE toK1Columns #-}
808− ( HTable (K1Columns "Here" structure1)
809− , HTable (K1Columns "There" structure2)
810− , K1Table "Here" 'True DB (IsStructure structure1) structure1 a
811− , K1Table "There" 'True DB (IsStructure structure2) structure2 b
812− , e ~ TheseTable a b
813− ) => K1Table label 'True DB 'True (Shape2 'These structure1 structure2) e
817− (fromK1Columns @"Here" @_ @_ @_ @structure1)
818− (fromK1Columns @"There" @_ @_ @_ @structure2) .
823− (toK1Columns @"Here" @_ @_ @_ @structure1)
824− (toK1Columns @"There" @_ @_ @_ @structure2)
825− {-# INLINABLE fromK1Columns #-}
826− {-# INLINABLE toK1Columns #-}
830− ( HTable (K1Columns "Here" structure1)
831− , HTable (K1Columns "There" structure2)
832− , K1Table "Here" 'True Insertion (IsStructure structure1) structure1 a
833− , K1Table "There" 'True Insertion (IsStructure structure2) structure2 b
834− , e ~ TheseTable a b
835− ) => K1Table label 'True Insertion 'True (Shape2 'These structure1 structure2) e
839− (fromK1Columns @"Here" @_ @_ @_ @structure1)
840− (fromK1Columns @"There" @_ @_ @_ @structure2) .
845− (toK1Columns @"Here" @_ @_ @_ @structure1)
846− (toK1Columns @"There" @_ @_ @_ @structure2)
847− {-# INLINABLE fromK1Columns #-}
848− {-# INLINABLE toK1Columns #-}
852− ( HTable (K1Columns "Here" structure1)
853− , HTable (K1Columns "There" structure2)
854− , K1Table "Here" 'True Result (IsStructure structure1) structure1 a
855− , K1Table "There" 'True Result (IsStructure structure2) structure2 b
857− ) => K1Table label 'True Result 'True (Shape2 'These structure1 structure2) e
861− (fromK1Columns @"Here" @_ @_ @_ @structure1)
862− (fromK1Columns @"There" @_ @_ @_ @structure2)
864− . hunlabel unlabeler
869− (toK1Columns @"Here" @_ @_ @_ @structure1)
870− (toK1Columns @"There" @_ @_ @_ @structure2)
871− {-# INLINABLE fromK1Columns #-}
872− {-# INLINABLE toK1Columns #-}
876− ( HTable (K1Columns "Here" structure1)
877− , HTable (K1Columns "There" structure2)
878− , K1Table "Here" 'False context (IsStructure structure1) structure1 a
879− , K1Table "There" 'False context (IsStructure structure2) structure2 b
880− , IsSpecialContext context ~ 'False
882− , Nullifiable context
883− , e ~ TheseTable a b
884− ) => K1Table label 'False context 'True (Shape2 'These structure1 structure2) e
888− (fromK1Columns @"Here" @_ @_ @_ @structure1)
889− (fromK1Columns @"There" @_ @_ @_ @structure2) .
894− (toK1Columns @"Here" @_ @_ @_ @structure1)
895− (toK1Columns @"There" @_ @_ @_ @structure2)
896− {-# INLINABLE fromK1Columns #-}
897− {-# INLINABLE toK1Columns #-}
902− ( K1Table "fst" isSpecialContext context (IsStructure structure1) structure1 a1
903− , K1Table "snd" isSpecialContext context (IsStructure structure2) structure2 a2
904− , HTable (K1Columns "fst" structure1)
905− , HTable (K1Columns "snd" structure2)
908− ) => K1Table label isSpecialContext context 'True (structure1, structure2) a
910− fromK1Columns (hunlabel unlabeler -> (HPair a b)) =
911− ( fromK1Columns @"fst" @_ @_ @_ @structure1 a
912− , fromK1Columns @"snd" @_ @_ @_ @structure2 b
914− toK1Columns (a, b) = hlabel labeler $ HPair
915− { hfst = toK1Columns @"fst" @_ @_ @_ @structure1 a
916− , hsnd = toK1Columns @"snd" @_ @_ @_ @structure2 b
918− {-# INLINABLE fromK1Columns #-}
919− {-# INLINABLE toK1Columns #-}
923− ( K1Table "fst" isSpecialContext context (IsStructure structure1) structure1 a1
924− , K1Table "snd" isSpecialContext context (IsStructure structure2) structure2 a2
925− , K1Table "trd" isSpecialContext context (IsStructure structure3) structure3 a3
926− , HTable (K1Columns "fst" structure1)
927− , HTable (K1Columns "snd" structure2)
928− , HTable (K1Columns "trd" structure3)
931− ) => K1Table label isSpecialContext context 'True (structure1, structure2, structure3) a
933− fromK1Columns (hunlabel unlabeler -> (HTrio a b c)) =
934− ( fromK1Columns @"fst" @_ @_ @_ @structure1 a
935− , fromK1Columns @"snd" @_ @_ @_ @structure2 b
936− , fromK1Columns @"trd" @_ @_ @_ @structure3 c
938− toK1Columns (a, b, c) = hlabel labeler $ HTrio
939− { hfst = toK1Columns @"fst" @_ @_ @_ @structure1 a
940− , hsnd = toK1Columns @"snd" @_ @_ @_ @structure2 b
941− , htrd = toK1Columns @"trd" @_ @_ @_ @structure3 c
943− {-# INLINABLE fromK1Columns #-}
944− {-# INLINABLE toK1Columns #-}
948− ( K1Table "fst" isSpecialContext context (IsStructure structure1) structure1 a1
949− , K1Table "snd" isSpecialContext context (IsStructure structure2) structure2 a2
950− , K1Table "trd" isSpecialContext context (IsStructure structure3) structure3 a3
951− , K1Table "frt" isSpecialContext context (IsStructure structure3) structure4 a4
952− , HTable (K1Columns "fst" structure1)
953− , HTable (K1Columns "snd" structure2)
954− , HTable (K1Columns "trd" structure3)
955− , HTable (K1Columns "frt" structure4)
957− , a ~ (a1, a2, a3, a4)
958− ) => K1Table label isSpecialContext context 'True (structure1, structure2, structure3, structure4) a
960− fromK1Columns (hunlabel unlabeler -> (HQuartet a b c d)) =
961− ( fromK1Columns @"fst" @_ @_ @_ @structure1 a
962− , fromK1Columns @"snd" @_ @_ @_ @structure2 b
963− , fromK1Columns @"trd" @_ @_ @_ @structure3 c
964− , fromK1Columns @"frt" @_ @_ @_ @structure4 d
966− toK1Columns (a, b, c, d) = hlabel labeler $ HQuartet
967− { hfst = toK1Columns @"fst" @_ @_ @_ @structure1 a
968− , hsnd = toK1Columns @"snd" @_ @_ @_ @structure2 b
969− , htrd = toK1Columns @"trd" @_ @_ @_ @structure3 c
970− , hfrt = toK1Columns @"frt" @_ @_ @_ @structure4 d
972− {-# INLINABLE fromK1Columns #-}
973− {-# INLINABLE toK1Columns #-}
977− ( K1Table "fst" isSpecialContext context (IsStructure structure1) structure1 a1
978− , K1Table "snd" isSpecialContext context (IsStructure structure2) structure2 a2
979− , K1Table "trd" isSpecialContext context (IsStructure structure3) structure3 a3
980− , K1Table "frt" isSpecialContext context (IsStructure structure3) structure4 a4
981− , K1Table "fft" isSpecialContext context (IsStructure structure3) structure5 a5
982− , HTable (K1Columns "fst" structure1)
983− , HTable (K1Columns "snd" structure2)
984− , HTable (K1Columns "trd" structure3)
985− , HTable (K1Columns "frt" structure4)
986− , HTable (K1Columns "fft" structure5)
988− , a ~ (a1, a2, a3, a4, a5)
989− ) => K1Table label isSpecialContext context 'True (structure1, structure2, structure3, structure4, structure5) a
991− fromK1Columns (hunlabel unlabeler -> (HQuintet a b c d e)) =
992− ( fromK1Columns @"fst" @_ @_ @_ @structure1 a
993− , fromK1Columns @"snd" @_ @_ @_ @structure2 b
994− , fromK1Columns @"trd" @_ @_ @_ @structure3 c
995− , fromK1Columns @"frt" @_ @_ @_ @structure4 d
996− , fromK1Columns @"fft" @_ @_ @_ @structure5 e
998− toK1Columns (a, b, c, d, e) = hlabel labeler $ HQuintet
999− { hfst = toK1Columns @"fst" @_ @_ @_ @structure1 a
1000− , hsnd = toK1Columns @"snd" @_ @_ @_ @structure2 b
1001− , htrd = toK1Columns @"trd" @_ @_ @_ @structure3 c
1002− , hfrt = toK1Columns @"frt" @_ @_ @_ @structure4 d
1003− , hfft = toK1Columns @"fft" @_ @_ @_ @structure5 e
1005− {-# INLINABLE fromK1Columns #-}
1006− {-# INLINABLE toK1Columns #-}
1010− ( IsSpecialContext context ~ isSpecialContext
1011− , IsStructure structure ~ 'False
1012− , K1Columns label structure ~ HLabel label (Columns structure)
1013− , Columns structure ~ Columns a
1014− , Labelable context
1016− ) => K1Table label isSpecialContext context 'False structure a
1018− fromK1Columns = fromColumns . hunlabel unlabeler
1019− toK1Columns = hlabel labeler . toColumns
1020− {-# INLINABLE fromK1Columns #-}
1021− {-# INLINABLE toK1Columns #-}