{-# LANGUAGE OverloadedStrings #-}
module Crypto.JOSE.Compact 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 :: ByteString -> m a
decodeCompact = [ByteString] -> m a
forall a e (m :: * -> *).
(FromCompact a, AsError e, MonadError e m) =>
[ByteString] -> m a
fromCompact ([ByteString] -> m a)
-> (ByteString -> [ByteString]) -> ByteString -> m a
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 :: a -> ByteString
encodeCompact = ByteString -> [ByteString] -> ByteString
L.intercalate ByteString
"." ([ByteString] -> ByteString)
-> (a -> [ByteString]) -> a -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> [ByteString]
forall a. ToCompact a => a -> [ByteString]
toCompact