haskelldb
haskelldb copied to clipboard
How to use `haskelldb` as a library?
After running cabal init
I tried adding haskelldb to .cabal file, e.g.
build-depends:
base,
haskelldb
But cannot cabal build
$ cabal build | tail
Error: cabal: Failed to build haskelldb-2.2.4 (which is required by
exe:smart-query from smart-query-0.1.0.0). See the build log above for
details.
It could refer to
either ‘Prelude.<>’,
imported from ‘Prelude’ at src/Database/HaskellDB/Sql/Print.hs:15:8-35
(and originally defined in ‘GHC.Base’)
or ‘Text.PrettyPrint.HughesPJ.<>’,
imported from ‘Text.PrettyPrint.HughesPJ’ at src/Database/HaskellDB/Sql/Print.hs:28:1-32
|
186 | CastSqlExpr typ expr -> text "CAST" <> parens (ppSqlExpr expr <+> text "AS" <+> text typ)
| ^^
[27 of 27] Compiling Database.HaskellDB.Version ( src/Database/HaskellDB/Version.hs, dist/build/Database/HaskellDB/Version.o, dist/build/Database/HaskellDB/Version.dyn_o )
I suspect haskelldb is effectively unmaintained. You might like to try a library I wrote instead: Opaleye.
I’m not keeping it up to date with GHC myself but glad to accept a PR.
From what I understand the latest changes have it fixed? Based on diff
$ git diff v2.2.4 -- src/Database/HaskellDB/BoundedList.hs
diff --git a/src/Database/HaskellDB/BoundedList.hs b/src/Database/HaskellDB/BoundedList.hs
index 63d05ee..846f68a 100644
--- a/src/Database/HaskellDB/BoundedList.hs
+++ b/src/Database/HaskellDB/BoundedList.hs
@@ -86,7 +86,6 @@ class Size n where
size :: n -> Int
class (Size a, Size b) => Less a b
-
class (Size a, Size b) => LessEq a b
instance (Size a) => LessEq a a
instance (Size a, Size b, Less a b) => LessEq a b
@@ -101,1277 +100,1277 @@ instance Less N0 N1
data N2 = N2
instance Size N2 where size _ = 2
instance Less N1 N2
-instance Less a N1 => Less a N2
+instance (Size a, Less a N1) => Less a N2
data N3 = N3
instance Size N3 where size _ = 3
instance Less N2 N3
So all it needs is to add a tag and publish it?
I suspect haskelldb is effectively unmaintained. You might like to try a library I wrote instead: Opaleye.
Btw can you generate queries for other databases (MySQL, Redshift) besides PostgreSQL?