@@ -23,7 +23,7 @@ import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye
23import {-# SOURCE #-} Rel8.Expr ( Expr( Expr ) )
23import {-# SOURCE #-} Rel8.Expr ( Expr( Expr ) )
24import Rel8.Expr.Bool ( (||.), boolExpr )
24import Rel8.Expr.Bool ( (||.), boolExpr )
25import Rel8.Expr.Opaleye ( scastExpr, mapPrimExpr )
25import Rel8.Expr.Opaleye ( scastExpr, mapPrimExpr )
26−import Rel8.Schema.Nullability ( IsMaybe )
26+import Rel8.Schema.Nullability ( NotNull )
27import Rel8.Type ( DBType, typeInformation )
27import Rel8.Type ( DBType, typeInformation )
28import Rel8.Type.Information ( TypeInformation )
28import Rel8.Type.Information ( TypeInformation )
@@ -31,7 +31,7 @@ import Rel8.Type.Information ( TypeInformation )
31-- | Lift an expression that can't be @null@ to a type that might be @null@.
31-- | Lift an expression that can't be @null@ to a type that might be @null@.
32-- This is an identity operation in terms of any generated query, and just
32-- This is an identity operation in terms of any generated query, and just
33-- modifies the query's type.
33-- modifies the query's type.
34−nullify :: IsMaybe a ~ 'False => Expr a -> Expr (Maybe a)
34+nullify :: NotNull a => Expr a -> Expr (Maybe a)
35nullify (Expr a) = Expr a
35nullify (Expr a) = Expr a
@@ -50,8 +50,7 @@ nullable :: Expr b -> (Expr a -> Expr b) -> Expr (Maybe a) -> Expr b
50nullable b f ma = boolExpr (f (unsafeUnnullify ma)) b (isNull ma)
50nullable b f ma = boolExpr (f (unsafeUnnullify ma)) b (isNull ma)
53−nullableOf :: (IsMaybe a ~ 'False, DBType a)
54− => Maybe (Expr a) -> Expr (Maybe a)
53+nullableOf :: DBType a => Maybe (Expr a) -> Expr (Maybe a)
55nullableOf = maybe null nullify
54nullableOf = maybe null nullify
@@ -75,7 +74,7 @@ isNonNull = mapPrimExpr (Opaleye.UnExpr Opaleye.OpIsNotNull)
75-- values. When given @null@, @mapNullable f@ returns @null@.
74-- values. When given @null@, @mapNullable f@ returns @null@.
77-- This is like 'fmap' for 'Maybe'.
76-- This is like 'fmap' for 'Maybe'.
78−mapNullable :: (IsMaybe b ~ 'False, DBType b)
77+mapNullable :: DBType b
79 => (Expr a -> Expr b) -> Expr (Maybe a) -> Expr (Maybe b)
78 => (Expr a -> Expr b) -> Expr (Maybe a) -> Expr (Maybe b)
80mapNullable f ma = boolExpr (unsafeMapNullable f ma) null (isNull ma)
79mapNullable f ma = boolExpr (unsafeMapNullable f ma) null (isNull ma)
@@ -85,7 +84,7 @@ mapNullable f ma = boolExpr (unsafeMapNullable f ma) null (isNull ma)
85-- are @null@, @liftOpNullable@ returns @null@.
84-- are @null@, @liftOpNullable@ returns @null@.
87-- This is like 'liftA2' for 'Maybe'.
86-- This is like 'liftA2' for 'Maybe'.
88−liftOpNullable :: (IsMaybe c ~ 'False, DBType c)
87+liftOpNullable :: DBType c
89 => (Expr a -> Expr b -> Expr c)
88 => (Expr a -> Expr b -> Expr c)
90 -> Expr (Maybe a) -> Expr (Maybe b) -> Expr (Maybe c)
89 -> Expr (Maybe a) -> Expr (Maybe b) -> Expr (Maybe c)
91liftOpNullable f ma mb =
90liftOpNullable f ma mb =
@@ -98,16 +97,16 @@ snull info = scastExpr info $ Expr $ Opaleye.ConstExpr Opaleye.NullLit
100-- | Corresponds to SQL @null@.
99-- | Corresponds to SQL @null@.
101−null :: (IsMaybe a ~ 'False, DBType a) => Expr (Maybe a)
100+null :: DBType a => Expr (Maybe a)
102null = snull typeInformation
101null = snull typeInformation
105−unsafeMapNullable :: IsMaybe b ~ 'False
104+unsafeMapNullable :: NotNull b
106 => (Expr a -> Expr b) -> Expr (Maybe a) -> Expr (Maybe b)
105 => (Expr a -> Expr b) -> Expr (Maybe a) -> Expr (Maybe b)
107unsafeMapNullable f ma = nullify (f (unsafeUnnullify ma))
106unsafeMapNullable f ma = nullify (f (unsafeUnnullify ma))
110−unsafeLiftOpNullable :: IsMaybe c ~ 'False
109+unsafeLiftOpNullable :: NotNull c
111 => (Expr a -> Expr b -> Expr c)
110 => (Expr a -> Expr b -> Expr c)
112 -> Expr (Maybe a) -> Expr (Maybe b) -> Expr (Maybe c)
111 -> Expr (Maybe a) -> Expr (Maybe b) -> Expr (Maybe c)
113unsafeLiftOpNullable f ma mb =
112unsafeLiftOpNullable f ma mb =