hasbolt 0.1.0.6 → 0.1.0.7
raw patch · 6 files changed
+25/−25 lines, 6 filesdep ~hasboltPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: hasbolt
API changes (from Hackage documentation)
Files
- hasbolt.cabal +2/−2
- src/Database/Bolt/Connection.hs +0/−1
- src/Database/Bolt/Connection/Instances.hs +1/−1
- src/Database/Bolt/Record.hs +12/−12
- src/Database/Bolt/Value/Structure.hs +8/−8
- src/Database/Bolt/Value/Type.hs +2/−1
hasbolt.cabal view
@@ -1,5 +1,5 @@ name: hasbolt-version: 0.1.0.6+version: 0.1.0.7 cabal-version: >=1.10 build-type: Simple license: BSD3@@ -63,7 +63,7 @@ main-is: Spec.hs build-depends: base >=4.9.0.0 && <4.10,- hasbolt >=0.1.0.6 && <0.2,+ hasbolt >=0.1.0.7 && <0.2, hspec >=2.2.4 && <2.3, QuickCheck >=2.8.2 && <2.9, hex >=0.1.2 && <0.2,
src/Database/Bolt/Connection.hs view
@@ -52,7 +52,6 @@ when (isSuccess status) $ discardAll pipe - -- |Runs Cypher query and ignores response query_ :: MonadIO m => Text -> BoltActionT m () query_ cypher = queryP_ cypher empty
src/Database/Bolt/Connection/Instances.hs view
@@ -25,7 +25,7 @@ | signature == sigRecs = return $ ResponseRecord (removeExtList fields) | signature == sigIgn = ResponseIgnored <$> extractMap (head fields) | signature == sigFail = ResponseFailure <$> extractMap (head fields)- | otherwise = fail "Not a Response value"+ | otherwise = fail "Not a Response value" where removeExtList :: [Value] -> [Value] removeExtList [L x] = x removeExtList _ = error "Record must contain only a singleton list"
src/Database/Bolt/Record.hs view
@@ -22,27 +22,27 @@ instance RecordValue () where exact (N _) = return ()- exact _ = fail "Not a Null value"+ exact x = fail $ show x ++ " is not a Null value" instance RecordValue Bool where exact (B b) = return b- exact _ = fail "Not a Bool value"+ exact x = fail $ show x ++ " is not a Bool value" instance RecordValue Int where exact (I i) = return i- exact _ = fail "Not an Int value"+ exact x = fail $ show x ++ " is not an Int value" instance RecordValue Double where exact (F d) = return d- exact _ = fail "Not a Double value"+ exact x = fail $ show x ++ " is not a Double value" instance RecordValue Text where exact (T t) = return t- exact _ = fail "Not a Text value"+ exact x = fail $ show x ++ " is not a Text value" instance RecordValue a => RecordValue [a] where exact (L l) = traverse exact l- exact _ = fail "Not a List value"+ exact x = fail $ show x ++ " is not a List value" instance RecordValue a => RecordValue (Maybe a) where exact (N _) = return Nothing@@ -50,28 +50,28 @@ instance RecordValue (Map Text Value) where exact (M m) = return m- exact _ = fail "Not a Map value"+ exact x = fail $ show x ++ " is not a Map value" instance RecordValue Node where exact (S s) = fromStructure s- exact _ = fail "Not a Node value"+ exact x = fail $ show x ++ " is not a Node value" instance RecordValue Relationship where exact (S s) = fromStructure s- exact _ = fail "Not a Relationship value"+ exact x = fail $ show x ++ " is not a Relationship value" instance RecordValue URelationship where exact (S s) = fromStructure s- exact _ = fail "Not a URelationship value"+ exact x = fail $ show x ++ " is not a URelationship value" instance RecordValue Path where exact (S s) = fromStructure s- exact _ = fail "Not a Path value"+ exact x = fail $ show x ++ " is not a Path value" at :: Monad m => Record -> Text -> m Value at record key = case key `M.lookup` record of Just result -> return result- Nothing -> fail "No such key in record"+ Nothing -> fail $ "No such key (" ++ show key ++ ") in record" toRecords :: Monad m => [Response] -> m [Record] toRecords (ResponseSuccess response:rest) =
src/Database/Bolt/Value/Structure.hs view
@@ -14,7 +14,7 @@ mkNode _ = failNode failNode :: Monad m => m Node- failNode = fail "Not a Node value"+ failNode = fail $ show lst ++ " is not a Node value" instance FromStructure Relationship where fromStructure (Structure sig lst) | sig == sigRel = mkRel lst@@ -24,7 +24,7 @@ mkRel _ = failRel failRel :: Monad m => m Relationship- failRel = fail "Not a Relationship value"+ failRel = fail $ show lst ++ " is not a Relationship value" instance FromStructure URelationship where fromStructure (Structure sig lst) | sig == sigURel = mkURel lst@@ -34,7 +34,7 @@ mkURel _ = failURel failURel :: Monad m => m URelationship- failURel = fail "Not a Unbounded Relationship value"+ failURel = fail $ show lst ++ " is not an Unbounded Relationship value" instance FromStructure Path where fromStructure (Structure sig lst) | sig == sigPath = mkPath lst@@ -47,30 +47,30 @@ mkPath _ = failPath failPath :: Monad m => m Path- failPath = fail "Not a Path value"+ failPath = fail $ show lst ++ " is not a Path value" -- = Helper functions cnvT :: Monad m => [Value] -> m [Text] cnvT [] = return [] cnvT (T x:xs) = (x:) <$> cnvT xs-cnvT _ = fail "Non-text value in text list"+cnvT (x:_) = fail $ "Non-text value (" ++ show x ++ ") in text list" cnvN :: Monad m => [Value] -> m [Node] cnvN [] = return [] cnvN (S x:xs) = do hd <- fromStructure x rest <- cnvN xs return (hd:rest)-cnvN _ = fail "Non-node value in text list"+cnvN (x:_) = fail $ "Non-node value (" ++ show x ++ ") in node list" cnvR :: Monad m => [Value] -> m [URelationship] cnvR [] = return [] cnvR (S x:xs) = do hd <- fromStructure x rest <- cnvR xs return (hd:rest)-cnvR _ = fail "Non-(u)relationship value in text list"+cnvR (x:_) = fail $ "Non-(u)relationship value (" ++ show x ++ ") in (u)relationship list" cnvI :: Monad m => [Value] -> m [Int] cnvI [] = return [] cnvI (I x:xs) = (x:) <$> cnvI xs-cnvI _ = fail "Non-int value in text list"+cnvI (x:_) = fail $ "Non-int value (" ++ show x ++ ") in int list"
src/Database/Bolt/Value/Type.hs view
@@ -15,10 +15,11 @@ } deriving (Show, Eq) --- |Generalizes all datatypes that can be serialized (deserialized) to (from) 'Structure's.+-- |Generalizes all datatypes that can be deserialized from 'Structure's. class FromStructure a where fromStructure :: Monad m => Structure -> m a +-- |Generalizes all datatypes that can be serialized to 'Structure's. class ToStructure a where toStructure :: a -> Structure