{-# LANGUAGE RankNTypes #-}

-- |
-- Module      : Data.Binary.Serialise.CBOR.Read
-- Copyright   : (c) Duncan Coutts 2015-2017
-- License     : BSD3-style (see LICENSE.txt)
--
-- Maintainer  : duncan@community.haskell.org
-- Stability   : experimental
-- Portability : non-portable (GHC extensions)
--
-- Tools for reading values in a CBOR-encoded format
-- back into ordinary values.
--
module Data.Binary.Serialise.CBOR.Read
 ( module X
 , deserialiseFromBytes
 ) where

import           Codec.CBOR.Read as X hiding (deserialiseFromBytes)
import qualified Codec.CBOR.Read as Read
import           Codec.CBOR.Decoding (Decoder)
import qualified Data.ByteString.Lazy as LBS

deserialiseFromBytes :: (forall s. Decoder s a)
                     -> LBS.ByteString
                     -> Either Read.DeserialiseFailure a
deserialiseFromBytes :: forall a.
(forall s. Decoder s a)
-> ByteString -> Either DeserialiseFailure a
deserialiseFromBytes forall s. Decoder s a
f = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a.
(forall s. Decoder s a)
-> ByteString -> Either DeserialiseFailure (ByteString, a)
Read.deserialiseFromBytes forall s. Decoder s a
f