{-# LANGUAGE OverloadedStrings #-}
module Crypto.JOSE.Compact
( FromCompact(..)
, decodeCompact
, ToCompact(..)
, encodeCompact
) where
import Control.Monad.Except (MonadError)
import qualified Data.ByteString.Lazy as L
import Crypto.JOSE.Error (AsError)
class FromCompact a where
fromCompact :: (AsError e, MonadError e m) => [L.ByteString] -> m a
decodeCompact :: (FromCompact a, AsError e, MonadError e m) => L.ByteString -> m a
decodeCompact :: forall a e (m :: * -> *).
(FromCompact a, AsError e, MonadError e m) =>
ByteString -> m a
decodeCompact = forall a e (m :: * -> *).
(FromCompact a, AsError e, MonadError e m) =>
[ByteString] -> m a
fromCompact forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> ByteString -> [ByteString]
L.split Word8
46
class ToCompact a where
toCompact :: a -> [L.ByteString]
encodeCompact :: (ToCompact a) => a -> L.ByteString
encodeCompact :: forall a. ToCompact a => a -> ByteString
encodeCompact = ByteString -> [ByteString] -> ByteString
L.intercalate ByteString
"." forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. ToCompact a => a -> [ByteString]
toCompact