zmactep / hasbolt

Haskell driver for Neo4j 3+ (BOLT protocol)
BSD 3-Clause "New" or "Revised" License
82 stars 13 forks source link

Problem with official example #33

Open danascaza opened 2 years ago

danascaza commented 2 years ago

Hi! I want to use Hasbolt, and I'm trying to run the simple example shown on the post in the Neo4J blog.

main :: IO ()
main = do pipe <- connect myConfiguration
          records <- run pipe $ query "MATCH (n:Person) WHERE n.name CONTAINS \"Tom\" RETURN n"
          let first = head records
          cruise <- first `at` "n" >>= exact :: IO Node
          print cruise
          close pipe

Everything works fine, and I do get the results, but I get an error when I try to use exact that I can't even begin to understand...

Couldn't match type ‘BoltError’ with ‘UnpackError’ arising from a functional dependency between:
          constraint ‘MonadError UnpackError (BoltActionT m0)’
            arising from a use of ‘exact’
          instance ‘MonadError BoltError (BoltActionT m)’
            at <no location info>
In the second argument of ‘(>>=)’, namely ‘exact’
      In a stmt of a 'do' block:
        cruise <- first `at` "n" >>= exact :: IO Node
      In the expression:
        do pipe <- connect myConfiguration
           records <- run pipe
                        $ query "MATCH (n:Person) WHERE n.root CONTAINS \"Tom\" RETURN n"
           let first = head records
           cruise <- first `at` "n" >>= exact :: IO Node

Any ideas?

vadymbiliuk commented 2 years ago

Hi. I believe you should try to use hasbolt-extras. It has features which allows you to get rid of those unpacks like cruise <- first at "n" >>= exact

image

This screenshot has example of code improved with hasbolt-extras