packstream 0.1.0.1 → 0.1.0.2
raw patch · 3 files changed
+12/−4 lines, 3 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Data.PackStream: DictHasNoKey :: Text -> PackStreamError
+ Data.PackStream: at :: (MonadError PackStreamError m, FromValue a) => Map Text Value -> Text -> m a
+ Data.PackStream: class FromValue a
+ Data.PackStream: class ToValue a
+ Data.PackStream: fromValue :: FromValue a => Value -> Either PackStreamError a
+ Data.PackStream: toValue :: ToValue a => a -> Value
+ Data.PackStream.Internal.Type: DictHasNoKey :: Text -> PackStreamError
Files
packstream.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: d55d5d199583510c5e154e94d070d24639588316cf5fa50e70104fa10f4bf14c+-- hash: 47ff8f45a904776e9131ea25bea1f85eacab002f8e61ac81b1403b77f5ac5355 name: packstream-version: 0.1.0.1+version: 0.1.0.2 synopsis: PackStream converter for Neo4j BOLT protocol description: Please see the README on GitHub at <https://github.com/zmactep/packstream#readme> category: Data
src/Data/PackStream.hs view
@@ -5,7 +5,7 @@ ( PackStreamError (..), PackStream (..), PackStreamValue (..) , unpackStream, unpackFail, unpackThrow-, Value (..), (=:)+, Value (..), ToValue (..), FromValue (..), (=:), at , Structure (..) ) where @@ -13,9 +13,10 @@ import qualified Data.PackStream.Parser as P import qualified Data.PackStream.Serializer as S +import Prelude hiding (lookup) import Data.ByteString (ByteString) import Data.Text (Text)-import Data.Map.Strict (Map)+import Data.Map.Strict (Map, lookup) import Control.Monad.Except (MonadError(..), liftEither) #if !MIN_VERSION_base(4, 13, 0)@@ -82,3 +83,9 @@ unpackFail bs = case unpackStream unpack bs of Right x -> pure x Left e -> fail $ show e++-- |Extract a value of a specific type from 'Value' dictionary+at :: (MonadError PackStreamError m, FromValue a) => Map Text Value -> Text -> m a+at dict key = case key `lookup` dict of+ Just val -> liftEither $ fromValue val+ Nothing -> throwError $ DictHasNoKey key
src/Data/PackStream/Internal/Type.hs view
@@ -30,6 +30,7 @@ | NotStructure -- ^This 'ByteString' doesn't represent any 'Structure' | NotValue -- ^This 'ByteString' doesn't represent any 'Value' | WrongStructure Text -- ^This 'ByteString' doesn't represent specific 'Structure'+ | DictHasNoKey Text -- ^The dictionary doesn't have a specified 'Text' key deriving (Show, Eq, Ord) -- |Basic parser type. It works like parser combinators for binary data that represents PackStream.