module Database.Redis.ByteStringClass where
import Prelude hiding (concat)
import Data.ByteString
import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString.UTF8 as U
class BS a where
toBS :: a -> ByteString
fromBS :: ByteString -> a
instance BS ByteString where
toBS = id
fromBS = id
instance BS L.ByteString where
toBS = concat . L.toChunks
fromBS = L.fromChunks . return
instance BS String where
toBS = U.fromString
fromBS = U.toString
instance BS Int where
toBS = U.fromString . show
fromBS = read . U.toString
instance BS Double where
toBS = U.fromString . show
fromBS = read . U.toString
instance BS () where
toBS = const empty
fromBS = const ()