string-conv-0.2.0: Standardized conversion between string types
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.String.Conv

Synopsis

Documentation

class StringConv a b where Source #

A type class to standardize string conversions. With this type class you only need to remember one function for converting between any two string variants. This package includes support for String, ByteString, and Text as well as the Lazy and Strict variants where necessary.

This type class lets you control how conversion should behave when failure is possible. Strict mode will cause an exception to be thrown when decoding fails. Lenient mode will attempt to recover, inserting a replacement character for invalid bytes.

StringConv's toS function is most useful when you have a fully defined string conversion with a fixed (non-polymorphic) input and output type. Of course you can still use it when you don't have a fixed type. In that case you might need to specify a type class constraint such as StringConv s String.

Methods

strConv :: Leniency -> a -> b Source #

Instances

Instances details
StringConv String String Source # 
Instance details

Defined in Data.String.Conv

StringConv String ByteString Source # 
Instance details

Defined in Data.String.Conv

StringConv String ByteString Source # 
Instance details

Defined in Data.String.Conv

StringConv String Text Source # 
Instance details

Defined in Data.String.Conv

StringConv String Text Source # 
Instance details

Defined in Data.String.Conv

StringConv ByteString String Source # 
Instance details

Defined in Data.String.Conv

StringConv ByteString ByteString Source # 
Instance details

Defined in Data.String.Conv

StringConv ByteString ByteString Source # 
Instance details

Defined in Data.String.Conv

StringConv ByteString Text Source # 
Instance details

Defined in Data.String.Conv

StringConv ByteString Text Source # 
Instance details

Defined in Data.String.Conv

StringConv ByteString String Source # 
Instance details

Defined in Data.String.Conv

StringConv ByteString ByteString Source # 
Instance details

Defined in Data.String.Conv

StringConv ByteString ByteString Source # 
Instance details

Defined in Data.String.Conv

StringConv ByteString Text Source # 
Instance details

Defined in Data.String.Conv

StringConv ByteString Text Source # 
Instance details

Defined in Data.String.Conv

StringConv Text String Source # 
Instance details

Defined in Data.String.Conv

StringConv Text ByteString Source # 
Instance details

Defined in Data.String.Conv

StringConv Text ByteString Source # 
Instance details

Defined in Data.String.Conv

StringConv Text Text Source # 
Instance details

Defined in Data.String.Conv

Methods

strConv :: Leniency -> Text -> Text Source #

StringConv Text Text Source # 
Instance details

Defined in Data.String.Conv

Methods

strConv :: Leniency -> Text0 -> Text Source #

StringConv Text String Source # 
Instance details

Defined in Data.String.Conv

StringConv Text ByteString Source # 
Instance details

Defined in Data.String.Conv

StringConv Text ByteString Source # 
Instance details

Defined in Data.String.Conv

StringConv Text Text Source # 
Instance details

Defined in Data.String.Conv

Methods

strConv :: Leniency -> Text -> Text0 Source #

StringConv Text Text Source # 
Instance details

Defined in Data.String.Conv

Methods

strConv :: Leniency -> Text -> Text Source #

toS :: StringConv a b => a -> b Source #

Universal string conversion function for strict decoding.

toSL :: StringConv a b => a -> b Source #

Universal string conversion function for lenient decoding.

convS :: (StringConv a b, StringConv b a, Functor f) => (b -> f b) -> a -> f a Source #

A lens for toS to make it slightly more convenient in some scenarios.

convSL :: (StringConv a b, StringConv b a, Functor f) => (b -> f b) -> a -> f a Source #

A lens for toSL to make it slightly more convenient in some scenarios.

data Leniency Source #

Data type representing the two leniency modes defining how decoding failure is handled.

Constructors

Lenient 
Strict