1{-# language FlexibleContexts #-}
2{-# language TypeFamilies #-}
4{-# options_ghc -fno-warn-redundant-constraints #-}
7 ( fromIntegral, realToFrac, div, mod, ceiling, floor, round, truncate
15import Rel8.Expr ( Expr( Expr ) )
16import Rel8.Expr.Function ( function )
17import Rel8.Expr.Opaleye ( castExpr )
18import Rel8.Schema.Null ( Homonullable, Sql )
19import Rel8.Type.Num ( DBFractional, DBIntegral, DBNum )
22-- | Cast 'DBIntegral' types to 'DBNum' types. For example, this can be useful
23-- if you need to turn an @Expr Int32@ into an @Expr Double@.
24fromIntegral :: (Sql DBIntegral a, Sql DBNum b, Homonullable a b)
26fromIntegral (Expr a) = castExpr (Expr a)
29-- | Cast 'DBNum' types to 'DBFractional' types. For example, his can be useful
30-- to convert @Expr Float@ to @Expr Double@.
31realToFrac :: (Sql DBNum a, Sql DBFractional b, Homonullable a b)
33realToFrac (Expr a) = castExpr (Expr a)
36-- | Round a 'DBFractional' to a 'DBIntegral' by rounding to the nearest larger
39-- Corresponds to the @ceiling()@ function.
40ceiling :: (Sql DBFractional a, Sql DBIntegral b, Homonullable a b)
42ceiling = function "ceiling"
45-- | Perform integral division. Corresponds to the @div()@ function.
46div :: Sql DBIntegral a => Expr a -> Expr a -> Expr a
50-- | Corresponds to the @mod()@ function.
51mod :: Sql DBIntegral a => Expr a -> Expr a -> Expr a
55-- | Round a 'DFractional' to a 'DBIntegral' by rounding to the nearest smaller
58-- Corresponds to the @floor()@ function.
59floor :: (Sql DBFractional a, Sql DBIntegral b, Homonullable a b)
61floor = function "floor"
64-- | Round a 'DBFractional' to a 'DBIntegral' by rounding to the nearest
67-- Corresponds to the @round()@ function.
68round :: (Sql DBFractional a, Sql DBIntegral b, Homonullable a b)
70round = function "round"
73-- | Round a 'DBFractional' to a 'DBIntegral' by rounding to the nearest
74-- integer towards zero.
75truncate :: (Sql DBFractional a, Sql DBIntegral b, Homonullable a b)
77truncate = function "trunc"
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