@@ -29,6 +29,7 @@ import Prelude hiding ( null )
2929import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye
3030
3131-- rel8
32+import Rel8.Expr.Function ( function, nullaryFunction )
3233import Rel8.Expr.Null ( liftOpNull, nullify )
3334import Rel8.Expr.Opaleye
3435 ( castExpr
@@ -50,7 +51,7 @@ import Rel8.Table
5051import Rel8.Table.Recontextualize ( Recontextualize )
5152import Rel8.Type ( DBType )
5253import Rel8.Type.Monoid ( DBMonoid, memptyExpr )
53−import Rel8.Type.Num ( DBFractional, DBNum )
54+import Rel8.Type.Num ( DBFloating, DBFractional, DBNum )
5455import Rel8.Type.Semigroup ( DBSemigroup, (<>.) )
5556
5657
@@ -104,6 +105,27 @@ instance Sql DBFractional a => Fractional (Expr a) where
104105 castExpr . Expr . Opaleye.ConstExpr . Opaleye.NumericLit . realToFrac
105106
106107
108+instance Sql DBFloating a => Floating (Expr a) where
109+ pi = nullaryFunction "PI"
110+ exp = function "exp"
111+ log = function "ln"
112+ sqrt = function "sqrt"
113+ (**) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:^))
114+ logBase = function "log"
115+ sin = function "sin"
116+ cos = function "cos"
117+ tan = function "tan"
118+ asin = function "asin"
119+ acos = function "acos"
120+ atan = function "atan"
121+ sinh = function "sinh"
122+ cosh = function "cosh"
123+ tanh = function "tanh"
124+ asinh = function "asinh"
125+ acosh = function "acosh"
126+ atanh = function "atanh"
127+
128+
107129instance Interpretation Expr where
108130 data Col Expr _spec where
109131 DB :: {unDB :: Expr a} -> Col Expr ('Spec labels necessity a)