conduit-extra-1.3.8: Batteries included conduit: adapters for common libraries.

Safe Haskell | None
Language | Haskell2010

Data.Conduit.Text

Contents

- Text codecs

Description

NOTE It is recommended to start using Data.Conduit.Combinators instead of this module.

Copyright: 2011 Michael Snoyman, 2010-2011 John Millikin License: MIT

Handle streams of text.

Parts of this code were taken from enumerator and adapted for conduits.

For many purposes, it's recommended to use the conduit-combinators library, which provides a more complete set of functions.

Synopsis

- data Codec
- encode :: forall (m :: Type -> Type). MonadThrow m => Codec -> ConduitT Text ByteString m ()
- decode :: forall (m :: Type -> Type). MonadThrow m => Codec -> ConduitT ByteString Text m ()
- utf8 :: Codec
- utf16_le :: Codec
- utf16_be :: Codec
- utf32_le :: Codec
- utf32_be :: Codec
- ascii :: Codec
- iso8859_1 :: Codec
- lines :: forall (m :: Type -> Type). Monad m => ConduitT Text Text m ()
- linesBounded :: forall (m :: Type -> Type). MonadThrow m => Int -> ConduitT Text Text m ()
- data TextException
  - = DecodeException Codec Word8
  - | EncodeException Codec Char
  - | LengthExceeded Int
  - | TextException SomeException
  - | NewDecodeException !Text !Int !ByteString
- takeWhile :: forall (m :: Type -> Type). Monad m => (Char -> Bool) -> ConduitT Text Text m ()
- dropWhile :: forall (m :: Type -> Type) o. Monad m => (Char -> Bool) -> ConduitT Text o m ()
- take :: forall (m :: Type -> Type). Monad m => Int -> ConduitT Text Text m ()
- drop :: forall (m :: Type -> Type) o. Monad m => Int -> ConduitT Text o m ()
- foldLines :: forall (m :: Type -> Type) a o. Monad m => (a -> ConduitM Text o m a) -> a -> ConduitT Text o m a
- withLine :: forall (m :: Type -> Type) a o. Monad m => ConduitT Text Void m a -> ConduitT Text o m (Maybe a)
- decodeUtf8 :: forall (m :: Type -> Type). MonadThrow m => ConduitT ByteString Text m ()
- decodeUtf8Lenient :: forall (m :: Type -> Type). Monad m => ConduitT ByteString Text m ()
- encodeUtf8 :: forall (m :: Type -> Type) text binary. (Monad m, Utf8 text binary) => ConduitT text binary m ()
- detectUtf :: forall (m :: Type -> Type). MonadThrow m => ConduitT ByteString Text m ()

# Text codecs

data Codec Source #

A specific character encoding.

Since 0.3.0

#### Instances

Instances details

Show Codec Source # |
Instance details Defined in Data.Conduit.Text Methods showsPrec :: Int -> Codec -> ShowS Source # show :: Codec -> String Source # showList :: [Codec] -> ShowS Source #

encode :: forall (m :: Type -> Type). MonadThrow m => Codec -> ConduitT Text ByteString m () Source #

Convert text into bytes, using the provided codec. If the codec is not capable of representing an input character, an exception will be thrown.

Since 0.3.0

decode :: forall (m :: Type -> Type). MonadThrow m => Codec -> ConduitT ByteString Text m () Source #

Convert bytes into text, using the provided codec. If the codec is not capable of decoding an input byte sequence, an exception will be thrown.

Since 0.3.0

utf8 :: Codec Source #

Since 0.3.0

utf16_le :: Codec Source #

Since 0.3.0

utf16_be :: Codec Source #

Since 0.3.0

utf32_le :: Codec Source #

Since 0.3.0

utf32_be :: Codec Source #

Since 0.3.0

ascii :: Codec Source #

Since 0.3.0

iso8859_1 :: Codec Source #

Since 0.3.0

lines :: forall (m :: Type -> Type). Monad m => ConduitT Text Text m () Source #

Emit each line separately

Since 0.4.1

linesBounded :: forall (m :: Type -> Type). MonadThrow m => Int -> ConduitT Text Text m () Source #

Variant of the lines function with an integer parameter. The text length of any emitted line never exceeds the value of the parameter. Whenever this is about to happen a LengthExceeded exception is thrown. This function should be used instead of the lines function whenever we are dealing with user input (e.g. a file upload) because we can't be sure that user input won't have extraordinarily large lines which would require large amounts of memory if consumed.

data TextException Source #

Since 0.3.0

Constructors

DecodeException Codec Word8 |
EncodeException Codec Char |
LengthExceeded Int |
TextException SomeException |
NewDecodeException !Text !Int !ByteString |

#### Instances

Instances details

Exception TextException Source # |
Instance details Defined in Data.Conduit.Text Methods toException :: TextException -> SomeException Source # fromException :: SomeException -> Maybe TextException Source # displayException :: TextException -> String Source # backtraceDesired :: TextException -> Bool Source #
Show TextException Source # |
Instance details Defined in Data.Conduit.Text Methods showsPrec :: Int -> TextException -> ShowS Source # show :: TextException -> String Source # showList :: [TextException] -> ShowS Source #

takeWhile :: forall (m :: Type -> Type). Monad m => (Char -> Bool) -> ConduitT Text Text m () Source #

Since 1.0.8

dropWhile :: forall (m :: Type -> Type) o. Monad m => (Char -> Bool) -> ConduitT Text o m () Source #

Since 1.0.8

take :: forall (m :: Type -> Type). Monad m => Int -> ConduitT Text Text m () Source #

Since 1.0.8

drop :: forall (m :: Type -> Type) o. Monad m => Int -> ConduitT Text o m () Source #

Since 1.0.8

foldLines :: forall (m :: Type -> Type) a o. Monad m => (a -> ConduitM Text o m a) -> a -> ConduitT Text o m a Source #

Since 1.0.8

withLine :: forall (m :: Type -> Type) a o. Monad m => ConduitT Text Void m a -> ConduitT Text o m (Maybe a) Source #

Since 1.0.8

decodeUtf8 :: forall (m :: Type -> Type). MonadThrow m => ConduitT ByteString Text m () Source #

Decode a stream of binary data as UTF8.

Since: conduit-1.3.0

decodeUtf8Lenient :: forall (m :: Type -> Type). Monad m => ConduitT ByteString Text m () Source #

Decode a stream of binary data as UTF8, replacing any invalid bytes with the Unicode replacement character.

Since: conduit-1.3.0

encodeUtf8 :: forall (m :: Type -> Type) text binary. (Monad m, Utf8 text binary) => ConduitT text binary m () Source #

Encode a stream of text as UTF8.

Subject to fusion

Since: conduit-1.3.0

detectUtf :: forall (m :: Type -> Type). MonadThrow m => ConduitT ByteString Text m () Source #

Automatically determine which UTF variant is being used. This function checks for BOMs, removing them as necessary. It defaults to assuming UTF-8.

Since 1.1.9