1{-# language NamedFieldPuns #-}
2{-# language ScopedTypeVariables #-}
3{-# language TypeApplications #-}
4{-# language TypeFamilies #-}
13import Data.Functor.Const ( Const( Const ), getConst )
14import Data.Functor.Contravariant ( (>$<), contramap )
18import Rel8.Expr.Order ( asc, desc, nullsFirst, nullsLast )
19import Rel8.Order ( Order )
20import Rel8.Schema.Context ( unDB )
21import Rel8.Schema.Dict ( Dict( Dict ) )
22import Rel8.Schema.HTable (htabulateA, hfield, hdicts, hspecs)
23import Rel8.Schema.Nullability ( Nullability( Nullable, NonNullable ) )
24import Rel8.Schema.Spec ( SSpec(..) )
25import Rel8.Schema.Spec.ConstrainDBType ( ConstrainDBType )
31ascTable :: forall a. OrdTable a => Order a
32ascTable = contramap toColumns $ getConst $
33 htabulateA @(Columns a) $ \field -> case hfield hspecs field of
34 SSpec {nullability} -> case hfield ords field of
35 Dict -> Const $ unDB . (`hfield` field) >$< case nullability of
36 Nullable -> nullsFirst asc
39 ords = hdicts @(Columns a) @(ConstrainDBType DBOrd)
42descTable :: forall a. OrdTable a => Order a
43descTable = contramap toColumns $ getConst $
44 htabulateA @(Columns a) $ \field -> case hfield hspecs field of
45 SSpec {nullability} -> case hfield ords field of
46 Dict -> Const $ unDB . (`hfield` field) >$< case nullability of
47 Nullable -> nullsLast desc
50 ords = hdicts @(Columns a) @(ConstrainDBType DBOrd)
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