HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulererebase-1.21.2Haskell2010

Data.Text.Encoding.Error

  • 4 types
  • 5 values
valuereplace :: b -> OnError a b
#

Replace an invalid input with a valid output.

datadata UnicodeException
#

An exception type for representing Unicode encoding errors.

Constructors

  • DecodeError String (Maybe Word8)

    Could not decode a byte sequence because it was invalid under the given encoding, or ran out of input in mid-decode.

  • EncodeError String (Maybe Char)

    Tried to encode a character that could not be represented under the given encoding, or ran out of input in mid-encode.

Instances4Eq, Show, Exception, NFData
valueignore :: OnError a b
#

Ignore an invalid input, substituting nothing in the output.

Deprecated. This exception is never used in practice, and will be removed.

A handler for an encoding error.

typetype OnError a b = String -> Maybe a -> Maybe b
#

Function type for handling a coding error. It is supplied with two inputs:

  • A String that describes the error.

  • The input value that caused the error. If the error arose because the end of input was reached or could not be identified precisely, this value will be Nothing.

If the handler returns a value wrapped with Just, that value will be used in the output as the replacement for the invalid input. If it returns Nothing, no value will be used in the output.

Should the handler need to abort processing, it should use error or throw an exception (preferably a UnicodeException). It may use the description provided to construct a more helpful error report.