1{-# language NamedFieldPuns #-}
2{-# language TypeFamilies #-}
4module Rel8.Expr.Serialize
15import qualified Hasql.Decoders as Hasql
18import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye
21import {-# SOURCE #-} Rel8.Expr ( Expr( Expr ) )
22import Rel8.Expr.Opaleye ( scastExpr )
23import Rel8.Schema.Nullability
24 ( Nullability( Nullable, NonNullable )
25 , Nullabilizes, nullabilization
27import Rel8.Type ( DBType, typeInformation )
28import Rel8.Type.Information ( TypeInformation(..) )
31litExpr :: (DBType db, Nullabilizes db a) => a -> Expr a
32litExpr = slitExpr nullabilization typeInformation
35slitExpr :: Nullability db a -> TypeInformation db -> a -> Expr a
36slitExpr nullable info@TypeInformation {encode} =
37 scastExpr nullable info . Expr . encoder
39 encoder = case nullable of
40 Nullable -> maybe (Opaleye.ConstExpr Opaleye.NullLit) encode
44sparseValue :: Nullability db a -> TypeInformation db -> Hasql.Row a
45sparseValue nullability TypeInformation {decode, out} = case nullability of
46 Nullable -> Hasql.column $ Hasql.nullable $ out <$> decode
47 NonNullable -> Hasql.column $ Hasql.nonNullable $ out <$> decode
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