packstream-bolt-0.1.0.0: src/Data/PackStream/Get.hs
{-# LANGUAGE PatternSynonyms #-}
-- | Internal module. Not part of the public API.
module Data.PackStream.Get
( -- * Primitive decoders
getNull
, getBoolean
, getFloat
-- * Integer decoders
, getInt
, getInt64
-- * Container decoders
, getString
, getBytes
, getList
, getDictionary
) where
import Compat.Binary
import Compat.Prelude
import Data.PackStream.Get.Internal
import Data.PackStream.Integer
-- | Deserialize an integer into an 'Int'
--
-- This operation will fail if the encoded integer doesn't fit into the value range of the 'Int' type.
getInt :: Get Int
getInt = maybe (fail "integer out of Int range") pure =<< fromPSInteger <$> get
-- | Deserialize an integer into an 'Int64'
--
-- This operation will fail if the encoded integer doesn't fit into the value range of the 'Int64' type.
getInt64 :: Get Int64
getInt64 = maybe (fail "integer out of Int64 range") pure =<< fromPSInteger <$> get