Safe Haskell | None |
---|---|
Language | GHC2021 |
Synopsis
- type AsText (enc :: k) = Refined enc Text
- class Encode (enc :: k) where
- encode :: forall {k} (enc :: k). Encode enc => AsText enc -> Bytes
- encodeToRep :: forall {k1} {k2} (rep :: k1) (enc :: k2). (Encode enc, Refine rep Bytes) => AsText enc -> Either RefineFailure (Refined rep Bytes)
- class Decode (enc :: k) where
- module Binrep.Type.Text.Encoding.Utf8
- module Binrep.Type.Text.Encoding.Ascii
- module Binrep.Type.Text.Encoding.Utf16
- module Binrep.Type.Text.Encoding.Utf32
- module Binrep.Type.Text.Encoding.ShiftJis
Documentation
class Encode (enc :: k) where Source #
Bytestring encoders for text validated for a given encoding.
encode :: forall {k} (enc :: k). Encode enc => AsText enc -> Bytes Source #
Encode some validated text.
encodeToRep :: forall {k1} {k2} (rep :: k1) (enc :: k2). (Encode enc, Refine rep Bytes) => AsText enc -> Either RefineFailure (Refined rep Bytes) Source #
Encode some text to a bytestring, asserting that the resulting value is valid for the requested bytestring representation.
This is intended to be used with visible type applications:
>>>
let Right t = refine @UTF8 (Text.pack "hi")
>>>
:t t
t :: AsText UTF8>>>
let Right bs = encodeToRep @'C t
>>>
:t bs
bs :: Refined 'C Bytes
class Decode (enc :: k) where Source #
decode :: Bytes -> Either String (AsText enc) Source #
Decode a ByteString
to Text
with an explicit encoding.
This is intended to be used with visible type applications.