1{-# language DataKinds #-}
2{-# language DerivingStrategies #-}
3{-# language FlexibleContexts #-}
4{-# language FlexibleInstances #-}
6{-# language MultiParamTypeClasses #-}
7{-# language PolyKinds #-}
8{-# language RankNTypes #-}
9{-# language StandaloneDeriving #-}
10{-# language StandaloneKindSignatures #-}
11{-# language TypeFamilies #-}
12{-# language UndecidableInstances #-}
13{-# language UndecidableSuperClasses #-}
15module Rel8.Schema.Name
23import Data.Functor.Identity ( Identity )
24import Data.Kind ( Constraint, Type )
25import Data.String ( IsString, fromString )
29import Rel8.Expr ( Expr )
30import Rel8.Schema.Context ( Interpretation, Col )
31import Rel8.Schema.Context.Label ( Labelable, labeler, unlabeler )
32import Rel8.Schema.HTable.Type ( HType( HType ) )
33import Rel8.Schema.Null ( Sql )
34import Rel8.Schema.Reify ( notReify )
35import Rel8.Schema.Result ( Result )
37 ( Table, Columns, Context, fromColumns, toColumns, reify, unreify
39import Rel8.Table.Recontextualize ( Recontextualize )
40import Rel8.Type ( DBType )
43-- | A @Name@ is the name of a column, as it would be defined in a table's
44-- schema definition. You can construct names by using the @OverloadedStrings@
45-- extension and writing string literals. This is typically done when providing
46-- a 'TableSchema' value.
49 Name :: k ~ Type => !String -> Name (a :: k)
52deriving stock instance Show (Name a)
55instance k ~ Type => IsString (Name (a :: k)) where
59instance Sql DBType a => Table Name (Name a) where
60 type Columns (Name a) = HType a
61 type Context (Name a) = Name
63 toColumns (Name a) = HType (NameCol a)
64 fromColumns (HType (NameCol a)) = Name a
69instance Sql DBType a => Recontextualize Expr Name (Expr a) (Name a)
72instance Sql DBType a => Recontextualize Result Name (Identity a) (Name a)
75instance Sql DBType a => Recontextualize Name Expr (Name a) (Expr a)
78instance Sql DBType a => Recontextualize Name Result (Name a) (Identity a)
81instance Sql DBType a => Recontextualize Name Name (Name a) (Name a)
84instance Interpretation Name where
85 newtype Col Name _spec = NameCol String
88instance Labelable Name where
89 labeler (NameCol a) = NameCol a
90 unlabeler (NameCol a) = NameCol a
93-- | @Selects a b@ means that @a@ is a schema (i.e., a 'Table' of 'Name's) for
94-- the 'Expr' columns in @b@.
95type Selects :: Type -> Type -> Constraint
96class Recontextualize Name Expr names exprs => Selects names exprs
97instance Recontextualize Name Expr names exprs => Selects names exprs
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