Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use haskelldb as a library? #34

Open
nurdann opened this issue Jul 21, 2024 · 4 comments
Open

How to use haskelldb as a library? #34

nurdann opened this issue Jul 21, 2024 · 4 comments

Comments

@nurdann
Copy link

nurdann commented Jul 21, 2024

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 )
@tomjaguarpaw
Copy link

I suspect haskelldb is effectively unmaintained. You might like to try a library I wrote instead: Opaleye.

@m4dc4p
Copy link
Owner

m4dc4p commented Jul 21, 2024

I’m not keeping it up to date with GHC myself but glad to accept a PR.

@nurdann
Copy link
Author

nurdann commented Jul 21, 2024

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?

@nurdann
Copy link
Author

nurdann commented Jul 21, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants