mfmts-1.2.0.0: multibase/MultiFormats/MultiBase/Strict.hs
-- | Module : MultiFormats.MultiBase.Strict
-- Description : Multibase encoders and decoders for strict ByteString
-- Copyright : Zoey McBride (c) 2026
-- License : AGPL-3.0-or-later
-- Maintainer : zoeymcbride@mailbox.org
-- Stability : experimental
module MultiFormats.MultiBase.Strict
( BaseSystem (encoder, decoder),
Encoder,
Decoder,
ByteStr,
)
where
import Data.BaseSystems.DigitTranscoder qualified as DXC
import Data.ByteString (ByteString)
import Data.Text (Text)
import MultiFormats.MultiBase.DigitTranscoder (MultiBase)
-- | Sets the bytestring type to use in this file.
type ByteStr = ByteString
-- | Alias for curried encoder method.
type Encoder = ByteStr -> Text
-- | Alias for curried decoder method.
type Decoder = Text -> Maybe ByteStr
-- | Configures the BaseSystem for this file's ByteType.
class BaseSystem a where
encoder :: a -> ByteStr -> Text
decoder :: a -> Text -> Maybe ByteStr
-- | Demotes the DigitTranscoder for MultiBase to BaseSystem transcoders.
instance BaseSystem (MultiBase ByteStr) where
encoder = DXC.digitEncoder
decoder = DXC.digitDecoder