on master help sign in
Merge pull request #69 from circuithub/exists
f36d7d0Shane
nix/sources.json+3−3
@@ -5,10 +5,10 @@
5 "homepage": "https://input-output-hk.github.io/haskell.nix",
5 "homepage": "https://input-output-hk.github.io/haskell.nix",
6 "owner": "input-output-hk",
6 "owner": "input-output-hk",
7 "repo": "haskell.nix",
7 "repo": "haskell.nix",
8− "rev": "5b5a18e442df6e27ad8549d69b8868b62adb08c3",
8+ "rev": "e7bb8ab2921a11a1d014c70a87898f73e086594d",
9− "sha256": "055mk7kmjppng66ppnb8kr96v4wwc8pcxfsls5gl77129hsz9aph",
9+ "sha256": "17c0xqzwnchcy71p8372cydcxc7qf0i8x12d0lf6p1g8yd4al6fa",
10 "type": "tarball",
10 "type": "tarball",
11− "url": "https://github.com/input-output-hk/haskell.nix/archive/5b5a18e442df6e27ad8549d69b8868b62adb08c3.tar.gz",
11+ "url": "https://github.com/input-output-hk/haskell.nix/archive/e7bb8ab2921a11a1d014c70a87898f73e086594d.tar.gz",
12 "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
12 "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13 },
13 },
14 "niv": {
14 "niv": {
rel8.cabal+1−1
@@ -25,7 +25,7 @@ library
25 , case-insensitive
25 , case-insensitive
26 , contravariant
26 , contravariant
27 , hasql ^>= 1.4.5.1
27 , hasql ^>= 1.4.5.1
28− , opaleye ^>= 0.7.1.0
28+ , opaleye ^>= 0.7.2.0
29 , profunctors
29 , profunctors
30 , scientific
30 , scientific
31 , semialign
31 , semialign
src/Rel8/Query/Exists.hs+4−6
@@ -11,23 +11,21 @@ where
11import Prelude hiding ( filter )
11import Prelude hiding ( filter )
12
12
13-- opaleye
13-- opaleye
14−import qualified Opaleye.Operators as Opaleye
14+import qualified Opaleye.Exists as Opaleye
15+import qualified Opaleye.Operators as Opaleye hiding ( exists )
15
16
16-- rel8
17-- rel8
17import Rel8.Expr ( Expr )
18import Rel8.Expr ( Expr )
19+import Rel8.Expr.Opaleye ( fromColumn, fromPrimExpr )
18import Rel8.Query ( Query )
20import Rel8.Query ( Query )
19import Rel8.Query.Filter ( filter )
21import Rel8.Query.Filter ( filter )
20−import Rel8.Query.Maybe ( optional )
21import Rel8.Query.Opaleye ( mapOpaleye )
22import Rel8.Query.Opaleye ( mapOpaleye )
22import Rel8.Table.Eq ( EqTable, (==:) )
23import Rel8.Table.Eq ( EqTable, (==:) )
23−import Rel8.Table.Maybe ( isJustTable )
24
24
25
25
26-- | Checks if a query returns at least one row.
26-- | Checks if a query returns at least one row.
27exists :: Query a -> Query (Expr Bool)
27exists :: Query a -> Query (Expr Bool)
28−exists = fmap isJustTable . optional . present
28+exists = fmap (fromPrimExpr . fromColumn) . mapOpaleye Opaleye.exists
29−-- FIXME: change this when b7aacc07c6392654cae439fc3b997620c3aa7a87 makes it
30−-- into a release of Opaleye
31
29
32
30
33inQuery :: EqTable a => a -> Query a -> Query (Expr Bool)
31inQuery :: EqTable a => a -> Query a -> Query (Expr Bool)