1{-# language AllowAmbiguousTypes #-}
2{-# language DataKinds #-}
3{-# language FlexibleContexts #-}
4{-# language FlexibleInstances #-}
5{-# language MultiParamTypeClasses #-}
6{-# language RankNTypes #-}
7{-# language ScopedTypeVariables #-}
8{-# language StandaloneKindSignatures #-}
9{-# language TypeApplications #-}
10{-# language TypeFamilyDependencies #-}
11{-# language UndecidableInstances #-}
12{-# language UndecidableSuperClasses #-}
20 , ConstructADT, constructADT
21 , DeconstructADT, deconstructADT
23 , AggregateADT, aggregateADT
29import Data.Kind ( Constraint, Type )
30import GHC.Generics ( Generic, from, to )
31import GHC.TypeLits ( Symbol )
35import Rel8.Aggregate ( Aggregate )
36import Rel8.Expr ( Expr )
37import Rel8.FCF ( Eval, Exp )
38import Rel8.Generic.Construction
42 , GGConstruct, ggconstruct
43 , GGDeconstruct, ggdeconstruct
45 , GGAggregate, ggaggregate
47import Rel8.Generic.Record ( Record( Record ), unrecord )
48import Rel8.Generic.Rel8able
50 , GRep, GColumns, gfromColumns, gtoColumns
51 , GFromExprs, gfromResult, gtoResult
52 , TSerialize, deserialize, serialize
54import qualified Rel8.Generic.Table.ADT as G
55import qualified Rel8.Kind.Algebra as K
56import Rel8.Schema.HTable ( HTable )
57import qualified Rel8.Schema.Kind as K
58import Rel8.Schema.Name ( Name )
59import Rel8.Schema.Result ( Result )
60import Rel8.Table ( Table, TColumns )
63type ADT :: K.Rel8able -> K.Rel8able
64newtype ADT t context = ADT (GColumnsADT t context)
67instance ADTable t => Rel8able (ADT t) where
68 type GColumns (ADT t) = GColumnsADT t
69 type GFromExprs (ADT t) = t Result
72 gtoColumns _ (ADT a) = a
80 @(Eval (ADTRep t Expr))
81 @(Eval (ADTRep t Result))
82 (\(_ :: proxy x) -> deserialize @_ @x)
88 @(Eval (ADTRep t Expr))
89 @(Eval (ADTRep t Result))
90 (\(_ :: proxy x) -> serialize @_ @x) .
95type ADTable :: K.Rel8able -> Constraint
97 ( Generic (Record (t Result))
98 , HTable (GColumnsADT t)
99 , G.GSerializeADT TSerialize TColumns (Eval (ADTRep t Expr)) (Eval (ADTRep t Result))
103 ( Generic (Record (t Result))
104 , HTable (GColumnsADT t)
105 , G.GSerializeADT TSerialize TColumns (Eval (ADTRep t Expr)) (Eval (ADTRep t Result))
110type BuildableADT :: K.Rel8able -> Symbol -> Constraint
111class GGBuildable 'K.Sum name (ADTRep t) => BuildableADT t name
112instance GGBuildable 'K.Sum name (ADTRep t) => BuildableADT t name
115type BuildADT :: K.Rel8able -> Symbol -> Type
116type BuildADT t name = GGBuild 'K.Sum name (ADTRep t) (ADT t Expr)
119buildADT :: forall t name. BuildableADT t name => BuildADT t name
121 ggbuild @'K.Sum @name @(ADTRep t) @(ADT t Expr) ADT
124type ConstructableADT :: K.Rel8able -> Constraint
125class GGConstructable 'K.Sum (ADTRep t) => ConstructableADT t
126instance GGConstructable 'K.Sum (ADTRep t) => ConstructableADT t
129type ConstructADT :: K.Rel8able -> Type
130type ConstructADT t = forall r. GGConstruct 'K.Sum (ADTRep t) r
133constructADT :: forall t. ConstructableADT t => ConstructADT t -> ADT t Expr
135 ggconstruct @'K.Sum @(ADTRep t) @(ADT t Expr) ADT
139type DeconstructADT :: K.Rel8able -> Type -> Type
140type DeconstructADT t r = GGDeconstruct 'K.Sum (ADTRep t) (ADT t Expr) r
143deconstructADT :: forall t r. (ConstructableADT t, Table Expr r)
144 => DeconstructADT t r
146 ggdeconstruct @'K.Sum @(ADTRep t) @(ADT t Expr) @r (\(ADT a) -> a)
149type NameADT :: K.Rel8able -> Type
150type NameADT t = GGName 'K.Sum (ADTRep t) (ADT t Name)
153nameADT :: forall t. ConstructableADT t => NameADT t
154nameADT = ggname @'K.Sum @(ADTRep t) @(ADT t Name) ADT
157type AggregateADT :: K.Rel8able -> Type
158type AggregateADT t = forall r. GGAggregate 'K.Sum (ADTRep t) r
161aggregateADT :: forall t. ConstructableADT t
162 => AggregateADT t -> ADT t Expr -> ADT t Aggregate
164 ggaggregate @'K.Sum @(ADTRep t) @(ADT t Expr) @(ADT t Aggregate) ADT (\(ADT a) -> a)
165 (f @(ADT t Aggregate))
168data ADTRep :: K.Rel8able -> K.Context -> Exp (Type -> Type)
169type instance Eval (ADTRep t context) = GRep t context
172type GColumnsADT :: K.Rel8able -> K.HTable
173type GColumnsADT t = G.GColumnsADT TColumns (GRep t Expr)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list