{-# language FlexibleContexts #-}
{-# language TypeFamilies #-}
{-# options_ghc -fno-warn-redundant-constraints #-}
module Rel8.Expr.Num
( fromIntegral, realToFrac, div, mod, ceiling, floor, round, truncate
)
where
import Prelude ()
import Rel8.Expr ( Expr( Expr ) )
import Rel8.Expr.Function ( function )
import Rel8.Expr.Opaleye ( castExpr )
import Rel8.Schema.Null ( Homonullable, Sql )
import Rel8.Type.Num ( DBFractional, DBIntegral, DBNum )
fromIntegral :: (Sql DBIntegral a, Sql DBNum b, Homonullable a b)
=> Expr a -> Expr b
fromIntegral :: Expr a -> Expr b
fromIntegral (Expr PrimExpr
a) = Expr b -> Expr b
forall a. Sql DBType a => Expr a -> Expr a
castExpr (PrimExpr -> Expr b
forall k (a :: k). (k ~ *) => PrimExpr -> Expr a
Expr PrimExpr
a)
realToFrac :: (Sql DBNum a, Sql DBFractional b, Homonullable a b)
=> Expr a -> Expr b
realToFrac :: Expr a -> Expr b
realToFrac (Expr PrimExpr
a) = Expr b -> Expr b
forall a. Sql DBType a => Expr a -> Expr a
castExpr (PrimExpr -> Expr b
forall k (a :: k). (k ~ *) => PrimExpr -> Expr a
Expr PrimExpr
a)
ceiling :: (Sql DBFractional a, Sql DBIntegral b, Homonullable a b)
=> Expr a -> Expr b
ceiling :: Expr a -> Expr b
ceiling = String -> Expr a -> Expr b
forall args result.
Function args result =>
String -> args -> result
function String
"ceiling"
div :: Sql DBIntegral a => Expr a -> Expr a -> Expr a
div :: Expr a -> Expr a -> Expr a
div = String -> Expr a -> Expr a -> Expr a
forall args result.
Function args result =>
String -> args -> result
function String
"div"
mod :: Sql DBIntegral a => Expr a -> Expr a -> Expr a
mod :: Expr a -> Expr a -> Expr a
mod = String -> Expr a -> Expr a -> Expr a
forall args result.
Function args result =>
String -> args -> result
function String
"mod"
floor :: (Sql DBFractional a, Sql DBIntegral b, Homonullable a b)
=> Expr a -> Expr b
floor :: Expr a -> Expr b
floor = String -> Expr a -> Expr b
forall args result.
Function args result =>
String -> args -> result
function String
"floor"
round :: (Sql DBFractional a, Sql DBIntegral b, Homonullable a b)
=> Expr a -> Expr b
round :: Expr a -> Expr b
round = String -> Expr a -> Expr b
forall args result.
Function args result =>
String -> args -> result
function String
"round"
truncate :: (Sql DBFractional a, Sql DBIntegral b, Homonullable a b)
=> Expr a -> Expr b
truncate :: Expr a -> Expr b
truncate = String -> Expr a -> Expr b
forall args result.
Function args result =>
String -> args -> result
function String
"trunc"