mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2025-01-05 20:04:49 +03:00
Rename functions to lift phamtom type into Maybe.
This commit is contained in:
parent
3255b32bf3
commit
5bac7ea830
@ -177,10 +177,10 @@ inner' :: PrimeRelation p r -> QueryJoin (PlaceHolders p, Projection r)
|
||||
inner' = fmap record' . query Just'
|
||||
|
||||
outer :: Relation r -> QueryJoin (Projection (Maybe r))
|
||||
outer = fmap (record . fmap Relation.outer) . query Maybe
|
||||
outer = fmap (record . fmap Relation.toMaybe) . query Maybe
|
||||
|
||||
outer' :: PrimeRelation p r -> QueryJoin (PlaceHolders p, Projection (Maybe r))
|
||||
outer' = fmap (record' . fmap Relation.outer) . query Maybe
|
||||
outer' = fmap (record' . fmap Relation.toMaybe) . query Maybe
|
||||
|
||||
from :: Table r -> QueryJoin (Projection r)
|
||||
from = inner . table
|
||||
|
@ -1,5 +1,5 @@
|
||||
module Database.Relational.Query.Projection (
|
||||
Projection, outer,
|
||||
Projection, toMaybe,
|
||||
|
||||
width,
|
||||
|
||||
@ -33,8 +33,8 @@ data ProjectionUnit = Columns (Array Int String)
|
||||
|
||||
data Projection t = Composed [ProjectionUnit]
|
||||
|
||||
outer :: Projection r -> Projection (Maybe r)
|
||||
outer = d where
|
||||
toMaybe :: Projection r -> Projection (Maybe r)
|
||||
toMaybe = d where
|
||||
d (Composed qs) = Composed qs
|
||||
|
||||
widthOfUnit :: ProjectionUnit -> Int
|
||||
|
@ -5,7 +5,7 @@ module Database.Relational.Query.Relation (
|
||||
Order (..),
|
||||
PrimeRelation, Relation,
|
||||
|
||||
outer,
|
||||
toMaybe,
|
||||
fromTable,
|
||||
|
||||
toSubQuery,
|
||||
@ -48,10 +48,10 @@ data PrimeRelation a r = Table (Table r)
|
||||
|
||||
type Relation = PrimeRelation ()
|
||||
|
||||
outer :: PrimeRelation a r -> PrimeRelation a (Maybe r)
|
||||
outer = d where
|
||||
d (Table t) = Table $ Table.outer t
|
||||
d r@(Relation { projection = p }) = r { projection = Projection.outer p }
|
||||
toMaybe :: PrimeRelation a r -> PrimeRelation a (Maybe r)
|
||||
toMaybe = d where
|
||||
d (Table t) = Table $ Table.toMaybe t
|
||||
d r@(Relation { projection = p }) = r { projection = Projection.toMaybe p }
|
||||
|
||||
width :: PrimeRelation a r -> Int
|
||||
width = d where
|
||||
@ -72,7 +72,7 @@ composedSQL pj pd re odRev =
|
||||
(\f n -> SQL.word f `asColumnN` n)
|
||||
(Projection.columns pj)
|
||||
[(0 :: Int)..]
|
||||
wheres = maybe [] (\e -> [WHERE, SQL.word . showExpr $ e])
|
||||
wheres = Prelude.maybe [] (\e -> [WHERE, SQL.word . showExpr $ e])
|
||||
order Asc = ASC
|
||||
order Desc = DESC
|
||||
orderList = foldl' (\ r (o, e) -> [SQL.word e, order o] `SQL.sepBy` " " : r) [] odRev
|
||||
|
@ -1,7 +1,7 @@
|
||||
module Database.Relational.Query.Table (
|
||||
Untyped, name', width', columns', (!),
|
||||
|
||||
Table, unType, name, shortName, width, columns, index, table, outer,
|
||||
Table, unType, name, shortName, width, columns, index, table, toMaybe,
|
||||
) where
|
||||
|
||||
import Data.Array (Array, listArray, elems)
|
||||
@ -37,8 +37,8 @@ columns = columns' . unType
|
||||
index :: Table r -> Int -> String
|
||||
index = (!) . unType
|
||||
|
||||
outer :: Table r -> Table (Maybe r)
|
||||
outer (Table t) = (Table t)
|
||||
toMaybe :: Table r -> Table (Maybe r)
|
||||
toMaybe (Table t) = (Table t)
|
||||
|
||||
table :: String -> [String] -> Table r
|
||||
table n f = Table $ Untyped n w fa where
|
||||
|
Loading…
Reference in New Issue
Block a user