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 TypeFamilies #-}
11{-# language TypeFamilyDependencies #-}
12{-# language UndecidableInstances #-}
13{-# language UndecidableSuperClasses #-}
21 , ConstructADT, constructADT
22 , DeconstructADT, deconstructADT
24 , AggregateADT, aggregateADT
30import Data.Kind ( Constraint, Type )
31import GHC.Generics ( Generic, Rep, from, to )
32import GHC.TypeLits ( Symbol )
36import Rel8.Aggregate ( Aggregate )
37import Rel8.Expr ( Expr )
38import Rel8.FCF ( Eval, Exp )
39import Rel8.Generic.Construction
43 , GGConstruct, ggconstruct
44 , GGDeconstruct, ggdeconstruct
46 , GGAggregate, ggaggregate
48import Rel8.Generic.Map ( GMap )
49import Rel8.Generic.Record ( Record( Record ), unrecord )
50import Rel8.Generic.Rel8able
52 , GRep, GColumns, gfromColumns, gtoColumns
53 , GFromExprs, gfromResult, gtoResult
55import qualified Rel8.Generic.Table.ADT as G
56import qualified Rel8.Kind.Algebra as K
57import Rel8.Schema.Context.Virtual
58import Rel8.Schema.HTable ( HTable )
59import qualified Rel8.Schema.Kind as K
60import Rel8.Schema.Name ( Name )
61import Rel8.Schema.Result ( Result )
63 ( Table, fromResult, toResult
64 , TTable, TColumns, TFromExprs
68type ADT :: K.Rel8able -> K.Rel8able
69newtype ADT t context = ADT (GColumnsADT t context)
72instance ADTable t => Rel8able (ADT t) where
73 type GColumns (ADT t) = GColumnsADT t
74 type GFromExprs (ADT t) = t Result
76 gfromColumns VAggregate = ADT
77 gfromColumns VExpr = ADT
78 gfromColumns VName = ADT
80 gtoColumns VAggregate (ADT a) = a
81 gtoColumns VExpr (ADT a) = a
82 gtoColumns VName (ADT a) = a
91 @(Eval (ADTRep t Expr))
92 (\(_ :: proxy x) -> fromResult @_ @x)
99 @(Eval (ADTRep t Expr))
100 (\(_ :: proxy x) -> toResult @_ @x) .
105type ADTable :: K.Rel8able -> Constraint
107 ( Generic (Record (t Result))
108 , HTable (GColumnsADT t)
109 , G.GTableADT (TTable Expr) TColumns TFromExprs (Eval (ADTRep t Expr))
110 , GMap TFromExprs (Rep (Record (t Expr))) ~ Rep (Record (t Result))
114 ( Generic (Record (t Result))
115 , HTable (GColumnsADT t)
116 , G.GTableADT (TTable Expr) TColumns TFromExprs (Eval (ADTRep t Expr))
117 , GMap TFromExprs (Rep (Record (t Expr))) ~ Rep (Record (t Result))
122type BuildableADT :: K.Rel8able -> Symbol -> Constraint
123class GGBuildable 'K.Sum name (ADTRep t) => BuildableADT t name
124instance GGBuildable 'K.Sum name (ADTRep t) => BuildableADT t name
127type BuildADT :: K.Rel8able -> Symbol -> Type
128type BuildADT t name = GGBuild 'K.Sum name (ADTRep t) (ADT t Expr)
131buildADT :: forall t name. BuildableADT t name => BuildADT t name
133 ggbuild @'K.Sum @name @(ADTRep t) @(ADT t Expr) ADT
136type ConstructableADT :: K.Rel8able -> Constraint
137class GGConstructable 'K.Sum (ADTRep t) => ConstructableADT t
138instance GGConstructable 'K.Sum (ADTRep t) => ConstructableADT t
141type ConstructADT :: K.Rel8able -> Type
142type ConstructADT t = forall r. GGConstruct 'K.Sum (ADTRep t) r
145constructADT :: forall t. ConstructableADT t => ConstructADT t -> ADT t Expr
147 ggconstruct @'K.Sum @(ADTRep t) @(ADT t Expr) ADT
151type DeconstructADT :: K.Rel8able -> Type -> Type
152type DeconstructADT t r = GGDeconstruct 'K.Sum (ADTRep t) (ADT t Expr) r
155deconstructADT :: forall t r. (ConstructableADT t, Table Expr r)
156 => DeconstructADT t r
158 ggdeconstruct @'K.Sum @(ADTRep t) @(ADT t Expr) @r (\(ADT a) -> a)
161type NameADT :: K.Rel8able -> Type
162type NameADT t = GGName 'K.Sum (ADTRep t) (ADT t Name)
165nameADT :: forall t. ConstructableADT t => NameADT t
166nameADT = ggname @'K.Sum @(ADTRep t) @(ADT t Name) ADT
169type AggregateADT :: K.Rel8able -> Type
170type AggregateADT t = forall r. GGAggregate 'K.Sum (ADTRep t) r
173aggregateADT :: forall t. ConstructableADT t
174 => AggregateADT t -> ADT t Expr -> ADT t Aggregate
176 ggaggregate @'K.Sum @(ADTRep t) @(ADT t Expr) @(ADT t Aggregate) ADT (\(ADT a) -> a)
177 (f @(ADT t Aggregate))
180data ADTRep :: K.Rel8able -> K.Context -> Exp (Type -> Type)
181type instance Eval (ADTRep t context) = GRep t context
184type GColumnsADT :: K.Rel8able -> K.HTable
185type 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