@@ -1,695 +0,0 @@
1−{-# language DataKinds #-}
2−{-# language FlexibleContexts #-}
3−{-# language GADTs #-}
4−{-# language LambdaCase #-}
5−{-# language MultiParamTypeClasses #-}
6−{-# language RankNTypes #-}
7−{-# language StandaloneKindSignatures #-}
8−{-# language TypeFamilies #-}
9−{-# language UndecidableInstances #-}
10−
11−module Rel8.Schema.Field
12− ( Field
13− , HEither, HList, HMaybe, HNonEmpty, HThese
14− , AField(..)
15− , AHEither(..), AHList(..), AHMaybe(..), AHNonEmpty(..), AHThese(..)
16− )
17−where
18−
19−-- base
20−import Control.Applicative ( liftA2 )
21−import Data.Bifunctor ( Bifunctor, bimap )
22−import Data.Kind ( Type )
23−import Data.List.NonEmpty ( NonEmpty )
24−import Prelude
25−
26−-- rel8
27−import Rel8.Aggregate ( Aggregate, Col(..) )
28−import Rel8.Expr ( Expr, Col(..) )
29−import Rel8.Kind.Context ( SContext(..), Reifiable( contextSing ) )
30−import Rel8.Kind.Necessity
31− ( Necessity( Required, Optional )
32− , SNecessity( SRequired, SOptional )
33− , KnownNecessity, necessitySing
34− )
35−import Rel8.Schema.HTable.Either ( HEitherTable )
36−import Rel8.Schema.HTable.List ( HListTable )
37−import Rel8.Schema.HTable.Maybe ( HMaybeTable )
38−import Rel8.Schema.HTable.NonEmpty ( HNonEmptyTable )
39−import Rel8.Schema.HTable.These ( HTheseTable )
40−import Rel8.Schema.HTable.Identity ( HIdentity( HIdentity ) )
41−import Rel8.Schema.Insert ( Insert, Col(..) )
42−import qualified Rel8.Schema.Kind as K
43−import Rel8.Schema.Name ( Name(..), Col(..) )
44−import Rel8.Schema.Null ( Sql )
45−import Rel8.Schema.Reify ( Reify, Col(..), hreify, hunreify )
46−import Rel8.Schema.Result ( Col( Result ), Result )
47−import Rel8.Schema.Spec ( Spec( Spec ) )
48−import Rel8.Table
49− ( Table, Columns, Congruent, Context, fromColumns, toColumns
50− , Unreify, reify, unreify
51− )
52−import Rel8.Table.Either ( EitherTable )
53−import Rel8.Table.List ( ListTable( ListTable ) )
54−import Rel8.Table.Maybe ( MaybeTable )
55−import Rel8.Table.NonEmpty ( NonEmptyTable( NonEmptyTable ) )
56−import Rel8.Table.Recontextualize ( Recontextualize )
57−import Rel8.Table.These ( TheseTable )
58−import Rel8.Table.Unreify ( Unreifiable )
59−import Rel8.Type ( DBType )
60−
61−-- these
62−import Data.These ( These )
63−
64−
65−type Field :: K.Context -> Necessity -> Type -> Type
66−type family Field context necessity a where
67− Field (Reify context) necessity a = AField context necessity a
68− Field Aggregate _necessity a = Aggregate (Expr a)
69− Field Expr _necessity a = Expr a
70− Field Insert 'Required a = Expr a
71− Field Insert 'Optional a = Maybe (Expr a)
72− Field Name _necessity a = Name a
73− Field Result _necessity a = a
74−
75−
76−type HEither :: K.Context -> Type -> Type -> Type
77−type family HEither context where
78− HEither (Reify context) = AHEither context
79− HEither Aggregate = EitherTable
80− HEither Expr = EitherTable
81− HEither Insert = EitherTable
82− HEither Name = EitherTable
83− HEither Result = Either
84−
85−
86−type HList :: K.Context -> Type -> Type
87−type family HList context where
88− HList (Reify context) = AHList context
89− HList Aggregate = ListTable
90− HList Expr = ListTable
91− HList Insert = ListTable
92− HList Name = ListTable
93− HList Result = []
94−
95−
96−type HMaybe :: K.Context -> Type -> Type
97−type family HMaybe context where
98− HMaybe (Reify context) = AHMaybe context
99− HMaybe Aggregate = MaybeTable
100− HMaybe Expr = MaybeTable
101− HMaybe Insert = MaybeTable
102− HMaybe Name = MaybeTable
103− HMaybe Result = Maybe
104−
105−
106−type HNonEmpty :: K.Context -> Type -> Type
107−type family HNonEmpty context where
108− HNonEmpty (Reify context) = AHNonEmpty context
109− HNonEmpty Aggregate = NonEmptyTable
110− HNonEmpty Expr = NonEmptyTable
111− HNonEmpty Insert = NonEmptyTable
112− HNonEmpty Name = NonEmptyTable
113− HNonEmpty Result = NonEmpty
114−
115−
116−type HThese :: K.Context -> Type -> Type -> Type
117−type family HThese context where
118− HThese (Reify context) = AHThese context
119− HThese Aggregate = TheseTable
120− HThese Expr = TheseTable
121− HThese Insert = TheseTable
122− HThese Name = TheseTable
123− HThese Result = These
124−
125−
126−type AField :: K.Context -> Necessity -> Type -> Type
127−newtype AField context necessity a = AField (Field context necessity a)
128−
129−
130−instance (Reifiable context, KnownNecessity necessity, Sql DBType a) =>
131− Table (Reify context) (AField context necessity a)
132− where
133− type Context (AField context necessity a) = Reify context
134− type Columns (AField context necessity a) = HIdentity ('Spec '[""] necessity a)
135− type Unreify (AField context necessity a) = Field context necessity a
136−
137− fromColumns (HIdentity (Reify a)) = sfromColumn contextSing a
138− toColumns = HIdentity . Reify . stoColumn contextSing necessitySing
139− reify _ = AField
140− unreify _ (AField a) = a
141−
142−
143−instance
144− ( Reifiable context, Reifiable context'
145− , KnownNecessity necessity, Sql DBType a
146− ) =>
147− Recontextualize
148− (Reify context)
149− (Reify context')
150− (AField context necessity a)
151− (AField context' necessity a)
152−
153−
154−type AHEither :: K.Context -> Type -> Type -> Type
155−newtype AHEither context a b = AHEither (HEither context a b)
156−
157−
158−instance Reifiable context => Bifunctor (AHEither context) where
159− bimap = sbimapEither contextSing
160−
161−
162−instance Reifiable context => Functor (AHEither context a) where
163− fmap = bimap id
164−
165−
166−instance (Reifiable context, Table (Reify context) a, Table (Reify context) b)
167− => Table (Reify context) (AHEither context a b)
168− where
169− type Context (AHEither context a b) = Reify context
170− type Columns (AHEither context a b) = HEitherTable (Columns a) (Columns b)
171− type Unreify (AHEither context a b) = HEither context (Unreify a) (Unreify b)
172−
173− fromColumns = sfromColumnsEither contextSing
174− toColumns = stoColumnsEither contextSing
175− reify proof = liftA2 bimap reify reify proof . AHEither
176− unreify proof = (\(AHEither a) -> a) . liftA2 bimap unreify unreify proof
177−
178−
179−instance
180− ( Reifiable context, Reifiable context'
181− , Recontextualize (Reify context) (Reify context') a a'
182− , Recontextualize (Reify context) (Reify context') b b'
183− ) =>
184− Recontextualize
185− (Reify context)
186− (Reify context')
187− (AHEither context a b)
188− (AHEither context' a' b')
189−
190−
191−type AHList :: K.Context -> Type -> Type
192−newtype AHList context a = AHList (HList context a)
193−
194−
195−instance
196− ( Reifiable context
197− , Table (Reify context) a
198− , Unreifiable (Reify context) a
199− )
200− => Table (Reify context) (AHList context a)
201− where
202− type Context (AHList context a) = Reify context
203− type Columns (AHList context a) = HListTable (Columns a)
204− type Unreify (AHList context a) = HList context (Unreify a)
205−
206− fromColumns = sfromColumnsList contextSing
207− toColumns = stoColumnsList contextSing
208− reify proof =
209− smapList contextSing (reify proof) hreify .
210− AHList
211− unreify proof =
212− (\(AHList a) -> a) .
213− smapList contextSing (unreify proof) hunreify
214−
215−
216−instance
217− ( Reifiable context, Reifiable context'
218− , Unreifiable (Reify context) a, Unreifiable (Reify context') a'
219− , Recontextualize (Reify context) (Reify context') a a'
220− ) =>
221− Recontextualize
222− (Reify context)
223− (Reify context')
224− (AHList context a)
225− (AHList context' a')
226−
227−
228−type AHMaybe :: K.Context -> Type -> Type
229−newtype AHMaybe context a = AHMaybe (HMaybe context a)
230−
231−
232−instance Reifiable context => Functor (AHMaybe context) where
233− fmap = smapMaybe contextSing
234−
235−
236−instance (Reifiable context, Table (Reify context) a) =>
237− Table (Reify context) (AHMaybe context a)
238− where
239− type Context (AHMaybe context a) = Reify context
240− type Columns (AHMaybe context a) = HMaybeTable (Columns a)
241− type Unreify (AHMaybe context a) = HMaybe context (Unreify a)
242−
243− fromColumns = sfromColumnsMaybe contextSing
244− toColumns = stoColumnsMaybe contextSing
245− reify proof = fmap fmap reify proof . AHMaybe
246− unreify proof = (\(AHMaybe a) -> a) . fmap fmap unreify proof
247−
248−
249−instance
250− ( Reifiable context, Reifiable context'
251− , Recontextualize (Reify context) (Reify context') a a'
252− ) =>
253− Recontextualize
254− (Reify context)
255− (Reify context')
256− (AHMaybe context a)
257− (AHMaybe context' a')
258−
259−
260−type AHNonEmpty :: K.Context -> Type -> Type
261−newtype AHNonEmpty context a = AHNonEmpty (HNonEmpty context a)
262−
263−
264−instance
265− ( Reifiable context
266− , Table (Reify context) a
267− , Unreifiable (Reify context) a
268− )
269− => Table (Reify context) (AHNonEmpty context a)
270− where
271− type Context (AHNonEmpty context a) = Reify context
272− type Columns (AHNonEmpty context a) = HNonEmptyTable (Columns a)
273− type Unreify (AHNonEmpty context a) = HNonEmpty context (Unreify a)
274−
275− fromColumns = sfromColumnsNonEmpty contextSing
276− toColumns = stoColumnsNonEmpty contextSing
277− reify proof =
278− smapNonEmpty contextSing (reify proof) hreify .
279− AHNonEmpty
280− unreify proof =
281− (\(AHNonEmpty a) -> a) .
282− smapNonEmpty contextSing (unreify proof) hunreify
283−
284−
285−instance
286− ( Reifiable context, Reifiable context'
287− , Unreifiable (Reify context) a, Unreifiable (Reify context') a'
288− , Recontextualize (Reify context) (Reify context') a a'
289− ) =>
290− Recontextualize
291− (Reify context)
292− (Reify context')
293− (AHNonEmpty context a)
294− (AHNonEmpty context' a')
295−
296−
297−type AHThese :: K.Context -> Type -> Type -> Type
298−newtype AHThese context a b = AHThese (HThese context a b)
299−
300−
301−instance Reifiable context => Bifunctor (AHThese context) where
302− bimap = sbimapThese contextSing
303−
304−
305−instance Reifiable context => Functor (AHThese context a) where
306− fmap = bimap id
307−
308−
309−instance (Reifiable context, Table (Reify context) a, Table (Reify context) b)
310− => Table (Reify context) (AHThese context a b)
311− where
312− type Context (AHThese context a b) = Reify context
313− type Columns (AHThese context a b) = HTheseTable (Columns a) (Columns b)
314− type Unreify (AHThese context a b) = HThese context (Unreify a) (Unreify b)
315−
316− fromColumns = sfromColumnsThese contextSing
317− toColumns = stoColumnsThese contextSing
318− reify proof = liftA2 bimap reify reify proof . AHThese
319− unreify proof = (\(AHThese a) -> a) . liftA2 bimap unreify unreify proof
320−
321−
322−instance
323− ( Reifiable context, Reifiable context'
324− , Recontextualize (Reify context) (Reify context') a a'
325− , Recontextualize (Reify context) (Reify context') b b'
326− ) =>
327− Recontextualize
328− (Reify context)
329− (Reify context')
330− (AHThese context a b)
331− (AHThese context' a' b')
332−
333−
334−sfromColumn :: ()
335− => SContext context
336− -> Col context ('Spec labels necessity a)
337− -> AField context necessity a
338−sfromColumn = \case
339− SAggregate -> \(Aggregation a) -> AField a
340− SExpr -> \(DB a) -> AField a
341− SResult -> \(Result a) -> AField a
342− SInsert -> \case
343− RequiredInsert a -> AField a
344− OptionalInsert a -> AField a
345− SName -> \(NameCol a) -> AField (Name a)
346− SReify context -> \(Reify a) -> AField (sfromColumn context a)
347−
348−
349−stoColumn :: ()
350− => SContext context
351− -> SNecessity necessity
352− -> AField context necessity a
353− -> Col context ('Spec labels necessity a)
354−stoColumn = \case
355− SAggregate -> \_ (AField a) -> Aggregation a
356− SExpr -> \_ (AField a) -> DB a
357− SResult -> \_ (AField a) -> Result a
358− SInsert -> \case
359− SRequired -> \(AField a) -> RequiredInsert a
360− SOptional -> \(AField a) -> OptionalInsert a
361− SName -> \_ (AField (Name a)) -> NameCol a
362− SReify context ->
363− \necessity (AField a) -> Reify (stoColumn context necessity a)
364−
365−
366−sbimapEither :: ()
367− => SContext context
368− -> (a -> c)
369− -> (b -> d)
370− -> AHEither context a b
371− -> AHEither context c d
372−sbimapEither = \case
373− SAggregate -> \f g (AHEither a) -> AHEither (bimap f g a)
374− SExpr -> \f g (AHEither a) -> AHEither (bimap f g a)
375− SResult -> \f g (AHEither a) -> AHEither (bimap f g a)
376− SInsert -> \f g (AHEither a) -> AHEither (bimap f g a)
377− SName -> \f g (AHEither a) -> AHEither (bimap f g a)
378− SReify context -> \f g (AHEither a) -> AHEither (sbimapEither context f g a)
379−
380−
381−sfromColumnsEither :: (Table (Reify context) a, Table (Reify context) b)
382− => SContext context
383− -> HEitherTable (Columns a) (Columns b) (Col (Reify context))
384− -> AHEither context a b
385−sfromColumnsEither = \case
386− SAggregate ->
387− AHEither .
388− bimap (fromColumns . hreify) (fromColumns . hreify) .
389− fromColumns .
390− hunreify
391− SExpr ->
392− AHEither .
393− bimap (fromColumns . hreify) (fromColumns . hreify) .
394− fromColumns .
395− hunreify
396− SResult ->
397− AHEither .
398− bimap (fromColumns . hreify) (fromColumns . hreify) .
399− fromColumns .
400− hunreify
401− SInsert ->
402− AHEither .
403− bimap (fromColumns . hreify) (fromColumns . hreify) .
404− fromColumns .
405− hunreify
406− SName ->
407− AHEither .
408− bimap (fromColumns . hreify) (fromColumns . hreify) .
409− fromColumns .
410− hunreify
411− SReify context ->
412− AHEither .
413− sbimapEither context (fromColumns . hreify) (fromColumns . hreify) .
414− sfromColumnsEither context .
415− hunreify
416−
417−
418−stoColumnsEither :: (Table (Reify context) a, Table (Reify context) b)
419− => SContext context
420− -> AHEither context a b
421− -> HEitherTable (Columns a) (Columns b) (Col (Reify context))
422−stoColumnsEither = \case
423− SAggregate ->
424− hreify .
425− toColumns .
426− bimap (hunreify . toColumns) (hunreify . toColumns) .
427− (\(AHEither a) -> a)
428− SExpr ->
429− hreify .
430− toColumns .
431− bimap (hunreify . toColumns) (hunreify . toColumns) .
432− (\(AHEither a) -> a)
433− SResult ->
434− hreify .
435− toColumns .
436− bimap (hunreify . toColumns) (hunreify . toColumns) .
437− (\(AHEither a) -> a)
438− SInsert ->
439− hreify .
440− toColumns .
441− bimap (hunreify . toColumns) (hunreify . toColumns) .
442− (\(AHEither a) -> a)
443− SName ->
444− hreify .
445− toColumns .
446− bimap (hunreify . toColumns) (hunreify . toColumns) .
447− (\(AHEither a) -> a)
448− SReify context ->
449− hreify .
450− stoColumnsEither context .
451− sbimapEither context (hunreify . toColumns) (hunreify . toColumns) .
452− (\(AHEither a) -> a)
453−
454−
455−smapList :: Congruent a b
456− => SContext context
457− -> (a -> b)
458− -> (HListTable (Columns a) (Col (Context a)) -> HListTable (Columns b) (Col (Context b)))
459− -> AHList context a
460− -> AHList context b
461−smapList = \case
462− SAggregate -> \_ f (AHList (ListTable a)) -> AHList (ListTable (f a))
463− SExpr -> \_ f (AHList (ListTable a)) -> AHList (ListTable (f a))
464− SResult -> \f _ (AHList as) -> AHList (fmap f as)
465− SInsert -> \_ f (AHList (ListTable a)) -> AHList (ListTable (f a))
466− SName -> \_ f (AHList (ListTable a)) -> AHList (ListTable (f a))
467− SReify context -> \f g (AHList as) -> AHList (smapList context f g as)
468−
469−
470−sfromColumnsList :: Table (Reify context) a
471− => SContext context
472− -> HListTable (Columns a) (Col (Reify context))
473− -> AHList context a
474−sfromColumnsList = \case
475− SAggregate -> AHList . ListTable
476− SExpr -> AHList . ListTable
477− SResult -> AHList . fmap (fromColumns . hreify) . fromColumns . hunreify
478− SInsert -> AHList . ListTable
479− SName -> AHList . ListTable
480− SReify context ->
481− AHList .
482− smapList context (fromColumns . hreify) hreify .
483− sfromColumnsList context .
484− hunreify
485−
486−
487−stoColumnsList :: Table (Reify context) a
488− => SContext context
489− -> AHList context a
490− -> HListTable (Columns a) (Col (Reify context))
491−stoColumnsList = \case
492− SAggregate -> \(AHList (ListTable a)) -> a
493− SExpr -> \(AHList (ListTable a)) -> a
494− SResult ->
495− hreify . toColumns . fmap (hunreify . toColumns) . (\(AHList a) -> a)
496− SInsert -> \(AHList (ListTable a)) -> a
497− SName -> \(AHList (ListTable a)) -> a
498− SReify context ->
499− hreify .
500− stoColumnsList context .
501− smapList context (hunreify . toColumns) hunreify .
502− (\(AHList a) -> a)
503−
504−
505−smapMaybe :: ()
506− => SContext context
507− -> (a -> b)
508− -> AHMaybe context a
509− -> AHMaybe context b
510−smapMaybe = \case
511− SAggregate -> \f (AHMaybe a) -> AHMaybe (fmap f a)
512− SExpr -> \f (AHMaybe a) -> AHMaybe (fmap f a)
513− SResult -> \f (AHMaybe a) -> AHMaybe (fmap f a)
514− SInsert -> \f (AHMaybe a) -> AHMaybe (fmap f a)
515− SName -> \f (AHMaybe a) -> AHMaybe (fmap f a)
516− SReify context -> \f (AHMaybe a) -> AHMaybe (smapMaybe context f a)
517−
518−
519−sfromColumnsMaybe :: Table (Reify context) a
520− => SContext context
521− -> HMaybeTable (Columns a) (Col (Reify context))
522− -> AHMaybe context a
523−sfromColumnsMaybe = \case
524− SAggregate -> AHMaybe . fmap (fromColumns . hreify) . fromColumns . hunreify
525− SExpr -> AHMaybe . fmap (fromColumns . hreify) . fromColumns . hunreify
526− SResult -> AHMaybe . fmap (fromColumns . hreify) . fromColumns . hunreify
527− SInsert -> AHMaybe . fmap (fromColumns . hreify) . fromColumns . hunreify
528− SName -> AHMaybe . fmap (fromColumns . hreify) . fromColumns . hunreify
529− SReify context ->
530− AHMaybe .
531− smapMaybe context (fromColumns . hreify) .
532− sfromColumnsMaybe context .
533− hunreify
534−
535−
536−stoColumnsMaybe :: Table (Reify context) a
537− => SContext context
538− -> AHMaybe context a
539− -> HMaybeTable (Columns a) (Col (Reify context))
540−stoColumnsMaybe = \case
541− SAggregate ->
542− hreify . toColumns . fmap (hunreify . toColumns) . (\(AHMaybe a) -> a)
543− SExpr ->
544− hreify . toColumns . fmap (hunreify . toColumns) . (\(AHMaybe a) -> a)
545− SResult ->
546− hreify . toColumns . fmap (hunreify . toColumns) . (\(AHMaybe a) -> a)
547− SInsert ->
548− hreify . toColumns . fmap (hunreify . toColumns) . (\(AHMaybe a) -> a)
549− SName ->
550− hreify . toColumns . fmap (hunreify . toColumns) . (\(AHMaybe a) -> a)
551− SReify context ->
552− hreify .
553− stoColumnsMaybe context .
554− smapMaybe context (hunreify . toColumns) .
555− (\(AHMaybe a) -> a)
556−
557−
558−smapNonEmpty :: Congruent a b
559− => SContext context
560− -> (a -> b)
561− -> (HNonEmptyTable (Columns a) (Col (Context a)) -> HNonEmptyTable (Columns b) (Col (Context b)))
562− -> AHNonEmpty context a
563− -> AHNonEmpty context b
564−smapNonEmpty = \case
565− SAggregate -> \_ f (AHNonEmpty (NonEmptyTable a)) -> AHNonEmpty (NonEmptyTable (f a))
566− SExpr -> \_ f (AHNonEmpty (NonEmptyTable a)) -> AHNonEmpty (NonEmptyTable (f a))
567− SResult -> \f _ (AHNonEmpty as) -> AHNonEmpty (fmap f as)
568− SInsert -> \_ f (AHNonEmpty (NonEmptyTable a)) -> AHNonEmpty (NonEmptyTable (f a))
569− SName -> \_ f (AHNonEmpty (NonEmptyTable a)) -> AHNonEmpty (NonEmptyTable (f a))
570− SReify context -> \f g (AHNonEmpty as) -> AHNonEmpty (smapNonEmpty context f g as)
571−
572−
573−sfromColumnsNonEmpty :: Table (Reify context) a
574− => SContext context
575− -> HNonEmptyTable (Columns a) (Col (Reify context))
576− -> AHNonEmpty context a
577−sfromColumnsNonEmpty = \case
578− SAggregate -> AHNonEmpty . NonEmptyTable
579− SExpr -> AHNonEmpty . NonEmptyTable
580− SResult ->
581− AHNonEmpty . fmap (fromColumns . hreify) . fromColumns . hunreify
582− SInsert -> AHNonEmpty . NonEmptyTable
583− SName -> AHNonEmpty . NonEmptyTable
584− SReify context ->
585− AHNonEmpty .
586− smapNonEmpty context (fromColumns . hreify) hreify .
587− sfromColumnsNonEmpty context .
588− hunreify
589−
590−
591−stoColumnsNonEmpty :: Table (Reify context) a
592− => SContext context
593− -> AHNonEmpty context a
594− -> HNonEmptyTable (Columns a) (Col (Reify context))
595−stoColumnsNonEmpty = \case
596− SAggregate -> \(AHNonEmpty (NonEmptyTable a)) -> a
597− SExpr -> \(AHNonEmpty (NonEmptyTable a)) -> a
598− SResult ->
599− hreify . toColumns . fmap (hunreify . toColumns) . (\(AHNonEmpty a) -> a)
600− SInsert -> \(AHNonEmpty (NonEmptyTable a)) -> a
601− SName -> \(AHNonEmpty (NonEmptyTable a)) -> a
602− SReify context ->
603− hreify .
604− stoColumnsNonEmpty context .
605− smapNonEmpty context (hunreify . toColumns) hunreify .
606− (\(AHNonEmpty a) -> a)
607−
608−
609−sbimapThese :: ()
610− => SContext context
611− -> (a -> c)
612− -> (b -> d)
613− -> AHThese context a b
614− -> AHThese context c d
615−sbimapThese = \case
616− SAggregate -> \f g (AHThese a) -> AHThese (bimap f g a)
617− SExpr -> \f g (AHThese a) -> AHThese (bimap f g a)
618− SResult -> \f g (AHThese a) -> AHThese (bimap f g a)
619− SInsert -> \f g (AHThese a) -> AHThese (bimap f g a)
620− SName -> \f g (AHThese a) -> AHThese (bimap f g a)
621− SReify context -> \f g (AHThese a) -> AHThese (sbimapThese context f g a)
622−
623−
624−sfromColumnsThese :: (Table (Reify context) a, Table (Reify context) b)
625− => SContext context
626− -> HTheseTable (Columns a) (Columns b) (Col (Reify context))
627− -> AHThese context a b
628−sfromColumnsThese = \case
629− SAggregate ->
630− AHThese .
631− bimap (fromColumns . hreify) (fromColumns . hreify) .
632− fromColumns .
633− hunreify
634− SExpr ->
635− AHThese .
636− bimap (fromColumns . hreify) (fromColumns . hreify) .
637− fromColumns .
638− hunreify
639− SResult ->
640− AHThese .
641− bimap (fromColumns . hreify) (fromColumns . hreify) .
642− fromColumns .
643− hunreify
644− SInsert ->
645− AHThese .
646− bimap (fromColumns . hreify) (fromColumns . hreify) .
647− fromColumns .
648− hunreify
649− SName ->
650− AHThese .
651− bimap (fromColumns . hreify) (fromColumns . hreify) .
652− fromColumns .
653− hunreify
654− SReify context ->
655− AHThese .
656− sbimapThese context (fromColumns . hreify) (fromColumns . hreify) .
657− sfromColumnsThese context .
658− hunreify
659−
660−
661−stoColumnsThese :: (Table (Reify context) a, Table (Reify context) b)
662− => SContext context
663− -> AHThese context a b
664− -> HTheseTable (Columns a) (Columns b) (Col (Reify context))
665−stoColumnsThese = \case
666− SAggregate ->
667− hreify .
668− toColumns .
669− bimap (hunreify . toColumns) (hunreify . toColumns) .
670− (\(AHThese a) -> a)
671− SExpr ->
672− hreify .
673− toColumns .
674− bimap (hunreify . toColumns) (hunreify . toColumns) .
675− (\(AHThese a) -> a)
676− SResult ->
677− hreify .
678− toColumns .
679− bimap (hunreify . toColumns) (hunreify . toColumns) .
680− (\(AHThese a) -> a)
681− SInsert ->
682− hreify .
683− toColumns .
684− bimap (hunreify . toColumns) (hunreify . toColumns) .
685− (\(AHThese a) -> a)
686− SName ->
687− hreify .
688− toColumns .
689− bimap (hunreify . toColumns) (hunreify . toColumns) .
690− (\(AHThese a) -> a)
691− SReify context ->
692− hreify .
693− stoColumnsThese context .
694− sbimapThese context (hunreify . toColumns) (hunreify . toColumns) .
695− (\(AHThese a) -> a)