hasbolt 0.1.3.4 → 0.1.3.5
raw patch · 5 files changed
+54/−7 lines, 5 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Database.Bolt: (=:) :: IsValue a => Text -> a -> (Text, Value)
+ Database.Bolt: class IsValue a
+ Database.Bolt: props :: [(Text, Value)] -> Map Text Value
+ Database.Bolt: toValue :: IsValue a => a -> Value
+ Database.Bolt: toValueList :: IsValue a => [a] -> Value
+ Database.Bolt.Lazy: (=:) :: IsValue a => Text -> a -> (Text, Value)
+ Database.Bolt.Lazy: class IsValue a
+ Database.Bolt.Lazy: props :: [(Text, Value)] -> Map Text Value
+ Database.Bolt.Lazy: toValue :: IsValue a => a -> Value
+ Database.Bolt.Lazy: toValueList :: IsValue a => [a] -> Value
Files
- hasbolt.cabal +1/−1
- src/Database/Bolt.hs +2/−1
- src/Database/Bolt/Lazy.hs +2/−1
- src/Database/Bolt/Value/Structure.hs +2/−2
- src/Database/Bolt/Value/Type.hs +47/−2
hasbolt.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: hasbolt-version: 0.1.3.4+version: 0.1.3.5 license: BSD3 license-file: LICENSE copyright: (c) 2018 Pavel Yakovlev
src/Database/Bolt.hs view
@@ -3,9 +3,10 @@ , connect, close, reset , run, queryP, query, queryP_, query_ , transact+ , (=:), props , Pipe , BoltCfg (..)- , Value (..), Structure (..), Record, RecordValue (..), at+ , Value (..), IsValue (..), Structure (..), Record, RecordValue (..), at , Node (..), Relationship (..), URelationship (..), Path (..) ) where
src/Database/Bolt/Lazy.hs view
@@ -3,9 +3,10 @@ , connect, close, reset , run, queryP, query, queryP_, query_ , transact+ , (=:), props , Pipe , BoltCfg (..)- , Value (..), Structure (..), Record, RecordValue (..), at+ , Value (..), IsValue (..), Structure (..), Record, RecordValue (..), at , Node (..), Relationship (..), URelationship (..), Path (..) ) where
src/Database/Bolt/Value/Structure.hs view
@@ -10,8 +10,8 @@ fromStructure (Structure sig lst) | sig == sigNode = mkNode lst | otherwise = failNode where mkNode :: Monad m => [Value] -> m Node- mkNode [I nid, L vlbls, M props] = flip (Node nid) props <$> cnvT vlbls- mkNode _ = failNode+ mkNode [I nid, L vlbls, M prps] = flip (Node nid) prps <$> cnvT vlbls+ mkNode _ = failNode failNode :: Monad m => m Node failNode = fail $ show lst ++ " is not a Node value"
src/Database/Bolt/Value/Type.hs view
@@ -1,9 +1,10 @@+{-# LANGUAGE FlexibleInstances #-} module Database.Bolt.Value.Type where import Control.Monad.State (StateT (..), evalStateT) import Data.ByteString (ByteString)-import Data.Map.Strict (Map)-import Data.Text (Text)+import Data.Map.Strict (Map, fromList)+import Data.Text (Text, pack) import Data.Word (Word8) -- |The 'UnpackT' transformer helps to unpack a set of values from one 'ByteString'@@ -44,6 +45,50 @@ | M (Map Text Value) | S Structure deriving (Show, Eq)++-- |Every datatype that can be represented as BOLT protocol value+class IsValue a where+ -- |Wraps value with 'Value' constructor+ toValue :: a -> Value+ -- |How to represent a list of values+ toValueList :: [a] -> Value+ toValueList = L . fmap toValue++instance IsValue () where+ toValue = N++instance IsValue Int where+ toValue = I++instance IsValue Integer where+ toValue = I . fromIntegral++instance IsValue Double where+ toValue = F++instance IsValue Float where+ toValue = F . realToFrac++instance IsValue Text where+ toValue = T++instance IsValue Char where+ toValue = toValueList . pure+ toValueList = T . Data.Text.pack++instance IsValue a => IsValue [a] where+ toValue = toValueList++instance IsValue (Map Text Value) where+ toValue = M++-- |Wrap key-value pair with 'Value' datatype+(=:) :: IsValue a => Text -> a -> (Text, Value)+(=:) key val = (key, toValue val)++-- |Construct properties map from list+props :: [(Text, Value)] -> Map Text Value+props = fromList -- = Structure types