@@ -29,6 +29,7 @@ import Prelude hiding ( null )
29import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye
29import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye
32+import Rel8.Expr.Function ( function, nullaryFunction )
32import Rel8.Expr.Null ( liftOpNull, nullify )
33import Rel8.Expr.Null ( liftOpNull, nullify )
33import Rel8.Expr.Opaleye
34import Rel8.Expr.Opaleye
34 ( castExpr
35 ( castExpr
@@ -50,7 +51,7 @@ import Rel8.Table
50import Rel8.Table.Recontextualize ( Recontextualize )
51import Rel8.Table.Recontextualize ( Recontextualize )
51import Rel8.Type ( DBType )
52import Rel8.Type ( DBType )
52import Rel8.Type.Monoid ( DBMonoid, memptyExpr )
53import Rel8.Type.Monoid ( DBMonoid, memptyExpr )
53−import Rel8.Type.Num ( DBFractional, DBNum )
54+import Rel8.Type.Num ( DBFloating, DBFractional, DBNum )
54import Rel8.Type.Semigroup ( DBSemigroup, (<>.) )
55import Rel8.Type.Semigroup ( DBSemigroup, (<>.) )
@@ -104,6 +105,27 @@ instance Sql DBFractional a => Fractional (Expr a) where
104 castExpr . Expr . Opaleye.ConstExpr . Opaleye.NumericLit . realToFrac
105 castExpr . Expr . Opaleye.ConstExpr . Opaleye.NumericLit . realToFrac
108+instance Sql DBFloating a => Floating (Expr a) where
109+ pi = nullaryFunction "PI"
110+ exp = function "exp"
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"
107instance Interpretation Expr where
129instance Interpretation Expr where
108 data Col Expr _spec where
130 data Col Expr _spec where
109 DB :: {unDB :: Expr a} -> Col Expr ('Spec labels necessity a)
131 DB :: {unDB :: Expr a} -> Col Expr ('Spec labels necessity a)