From 9d5e9d7686da500d3124457307e0404bd2247370 Mon Sep 17 00:00:00 2001 From: Maxim Koltsov Date: Thu, 28 Sep 2023 15:13:36 +0300 Subject: [PATCH 1/3] Better error message from TH converter --- src/Database/Bolt/Extras/Template/Internal/Converters.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Database/Bolt/Extras/Template/Internal/Converters.hs b/src/Database/Bolt/Extras/Template/Internal/Converters.hs index b9e4cd1..2adaa4f 100644 --- a/src/Database/Bolt/Extras/Template/Internal/Converters.hs +++ b/src/Database/Bolt/Extras/Template/Internal/Converters.hs @@ -323,7 +323,10 @@ getProp container (fieldName, fieldMaybe) | fieldMaybe && fieldName `notMember` where exactE v = case exactEither v of Right res -> res - Left err -> error $ show err + Left err -> error + $ "Could not unpack " + <> unpack fieldName <> ": " <> show err + <> ", value: " <> show v unpackError :: HasCallStack => Show c => c -> String -> a unpackError container label = error $ $currentLoc ++ " could not unpack " ++ label ++ " from " ++ show container From e77f60cbaf2295a88b4d90e197dd18af8e9e8199 Mon Sep 17 00:00:00 2001 From: Maxim Koltsov Date: Thu, 28 Sep 2023 15:24:16 +0300 Subject: [PATCH 2/3] Support unpacking DB Int as Double --- src/Database/Bolt/Extras/Internal/Instances.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Database/Bolt/Extras/Internal/Instances.hs b/src/Database/Bolt/Extras/Internal/Instances.hs index e33b6a9..701ecb7 100644 --- a/src/Database/Bolt/Extras/Internal/Instances.hs +++ b/src/Database/Bolt/Extras/Internal/Instances.hs @@ -19,7 +19,7 @@ import Database.Bolt.Extras.Internal.Types (FromValue (..), NodeLike ( NodeLikeProps (..), ToIsValue (..), ToValue (..)) import Database.Bolt.Extras.Utils (currentLoc) -import GHC.Float (double2Float, float2Double) +import GHC.Float (double2Float, float2Double, int2Double) import GHC.Stack (HasCallStack) @@ -80,6 +80,7 @@ instance FromValue Int where instance FromValue Double where fromValue (F doubleV) = doubleV + fromValue (I intV) = int2Double intV fromValue v = error $ $currentLoc ++ "could not unpack " ++ show v ++ " into Double" instance FromValue Float where From 3aef2c18e465fa3b98ade3984a650d41e7ec2d2b Mon Sep 17 00:00:00 2001 From: Maxim Koltsov Date: Thu, 28 Sep 2023 15:28:14 +0300 Subject: [PATCH 3/3] version 0.0.3.1 --- CHANGELOG.md | 6 ++++++ hasbolt-extras.cabal | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67e47b5..6dada14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.0.3.1] - 2023-09-28 +### Changed +- `FromValue` now can unpack DB `Int` as Haskell `Double`. +- Verbose error in TemplateHaskell converter when property of a node or a relationship can't be + unpacked. + ## [0.0.3.0] - 2023-08-17 ### Added - `IsString` instance for `Cond` and `Conds`. diff --git a/hasbolt-extras.cabal b/hasbolt-extras.cabal index e691898..632d120 100644 --- a/hasbolt-extras.cabal +++ b/hasbolt-extras.cabal @@ -1,5 +1,5 @@ name: hasbolt-extras -version: 0.0.3.0 +version: 0.0.3.1 synopsis: Extras for hasbolt library description: Extras for hasbolt library homepage: https://github.com/biocad/hasbolt-extras#readme