HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulebase64-1.0Haskell2010

Data.Base64.Types

This module contains the Base64 type definition, Alphabet datatype, alphabet constraints, and various quality of life combinators for working with Base64-wrapped data.

  • 2 types
  • 3 values
  • Packagebase64-1.0
  • Exports8
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceTypes.hs
datadata Alphabet
#

The different kinds of supported Base64 encodings

Constructors

  • StdPadded

    Standard base64 according to RFC 4648 §4 Padding is always inserted when encoding, and required when decoding

  • UrlPadded

    Standard base64 according to RFC 4648 §4 Padding is never inserted when encoding, and optional when decoding per RFC 7049.

  • UrlUnpadded

    URL-safe base64 according to RFC 4648 §5 aka base64url Padding is never inserted when encoding, and optional when decoding

  • NonStandard

    Any non-standard, non RFC 4648-compliant base64 encoding. Can only be decoded using lenient decoders.

newtypenewtype Base64 (k :: Alphabet) a
#

Wraps a value, asserting that it is or is intended to be in a particular kind of Base64 encoding use extractBase64 to extract the value, and assertBase64 to tag a value as base64-encoded

Instances6Monad, Functor, Applicative, Eq, Show, NFData
  • Monad (Base64 k)Defined in base64-1.0 · Data.Base64.Types.Internal
  • Functor (Base64 k)Defined in base64-1.0 · Data.Base64.Types.Internal
  • Applicative (Base64 k)Defined in base64-1.0 · Data.Base64.Types.Internal
  • Eq a => Eq (Base64 k a)Defined in base64-1.0 · Data.Base64.Types.Internal
  • Show a => Show (Base64 k a)Defined in base64-1.0 · Data.Base64.Types.Internal
  • NFData a => NFData (Base64 k a)Defined in base64-1.0 · Data.Base64.Types.Internal
valueassertBase64 :: a -> Base64 k a
#

Assert the provenance of a value encoded in a particular base64 alphabet.

Warning: This is a blind assertion that a particular value is base64 encoded in some alphabet. If you are not sure of the provenance of the value, you may experience odd behavior when attempting to decode. Use at your own risk. If I see any issues logged on this project from negligent use of this or coerceBase64, I will smite you.

valuecoerceBase64 :: Base64 k a -> Base64 j a
#

Coerce the alphabet of a base64-encoded bytestring

Warning: This is a blind assertion that a particular value is base64 encoded in some alphabet. If you are not sure of the provenance of the value, you may experience odd behavior when attempting to decode. Use at your own risk. If I see any issues logged on this project from negligent use of this or assertBase64, I will smite you.

familytype family UrlAlphabet (k :: Alphabet) :: Constraint where
#

The type family of Url-safe alphabets

This type family defines the union of compatible Url-safe base64 types. To write a function that is parametric over such types, issue a constraint like `forall k. UrlAlphabet k`.

Equations

familytype family StdAlphabet (k :: Alphabet) :: Constraint where
#

The type family of standard alphabets

This type family defines the union of compatible standard alphabet base64 types

Equations

  • StdAlphabet 'StdPadded = ()
  • StdAlphabet _1 = TypeError ('Text "Cannot prove base64 value is encoded using the std alphabet. Please re-encode using the std encoders, or use a lenient decoder for the std alphabet instead.")
familytype family NonStandardAlphabet (k :: Alphabet) :: Constraint where
#

The type family of non-standard alphabets

Only untyped variants of encodeBase64/decodeBase64 can interact with this type family, in addition to assertion/coercion/extraction of these types of values.

Equations