Added RawString wrapper
Getty Ritter
8 years ago
| 1 |
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
| 2 |
|
| 3 |
module Database.Tansu.RawString ( RawString(..) ) where
|
| 4 |
|
| 5 |
import Control.DeepSeq ( NFData )
|
| 6 |
import Data.ByteString ( ByteString )
|
| 7 |
import Data.Serialize ( Serialize(..)
|
| 8 |
, getByteString
|
| 9 |
, putByteString
|
| 10 |
, remaining
|
| 11 |
)
|
| 12 |
import GHC.Exts ( IsString )
|
| 13 |
|
| 14 |
-- | A wrapper over 'ByteString' with a serialize instance
|
| 15 |
-- that just passes the bytestring on unchanged. It will
|
| 16 |
-- always be the case that
|
| 17 |
--
|
| 18 |
-- > encode bs == bs
|
| 19 |
--
|
| 20 |
-- and that
|
| 21 |
--
|
| 22 |
-- > decode bs == Right bs
|
| 23 |
newtype RawString =
|
| 24 |
RawString { toByteString :: ByteString }
|
| 25 |
deriving (Eq, Show, Ord, Read, IsString, Monoid, NFData)
|
| 26 |
|
| 27 |
instance Serialize RawString where
|
| 28 |
put = putByteString . toByteString
|
| 29 |
get = RawString `fmap` (getByteString =<< remaining)
|
15 | 15 |
library
|
16 | 16 |
exposed-modules: Database.Tansu,
|
17 | 17 |
Database.Tansu.Internal,
|
| 18 |
Database.Tansu.RawString,
|
18 | 19 |
Database.Tansu.Backend.Filesystem,
|
19 | 20 |
Database.Tansu.Backend.Ephemeral
|
20 | 21 |
build-depends: base >=4.8 && <4.9,
|
21 | 22 |
bytestring,
|
22 | 23 |
cereal,
|
| 24 |
deepseq,
|
23 | 25 |
monadLib,
|
24 | 26 |
directory,
|
25 | 27 |
filepath,
|