through-text-0.1.0.0: Convert textual types through Text without needing O(n^2) instances.

Safe HaskellSafe
LanguageHaskell2010

Data.Text.Through

Contents

Synopsis

Type classes

class ToText a where #

Minimal complete definition

toText

Methods

toText :: a -> StrictText #

Instances

ToText StrictText #

The identity instance is used so throughText works even when converting to StrictText

ToText StrictByteString #

Uses lenient decoding which replaces invalid characters with U+FFFD.

ToText LazyText # 
ToText LazyByteString #

Uses lenient decoding which replaces invalid characters with U+FFFD.

ToText [Char] # 

Methods

toText :: [Char] -> StrictText #

ToText a => ToText (CI a) # 

Methods

toText :: CI a -> StrictText #

class FromText a where #

Minimal complete definition

fromText

Methods

fromText :: StrictText -> a #

Instances

FromText StrictText #

The identity instance is used so throughText works even when converting to StrictText.

FromText StrictByteString # 
FromText LazyText # 
FromText LazyByteString # 
FromText [Char] # 

Methods

fromText :: StrictText -> [Char] #

(FoldCase a, FromText a) => FromText (CI a) # 

Methods

fromText :: StrictText -> CI a #

Double conversion

throughText :: (ToText a, FromText b) => a -> b #

Convert between all textual types.

Types and type aliases

type LazyText = Text #

data CI s :: * -> * #

A CI s provides Case Insensitive comparison for the string-like type s (for example: String, Text, ByteString, etc.).

Note that CI s has an instance for IsString which together with the OverloadedStrings language extension allows you to write case insensitive string literals as in:

> ("Content-Type" :: CI Text) == ("CONTENT-TYPE" :: CI Text)
True

Instances

Eq s => Eq (CI s) 

Methods

(==) :: CI s -> CI s -> Bool #

(/=) :: CI s -> CI s -> Bool #

Data s => Data (CI s) 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CI s -> c (CI s) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (CI s) #

toConstr :: CI s -> Constr #

dataTypeOf :: CI s -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (CI s)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (CI s)) #

gmapT :: (forall b. Data b => b -> b) -> CI s -> CI s #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CI s -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CI s -> r #

gmapQ :: (forall d. Data d => d -> u) -> CI s -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CI s -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CI s -> m (CI s) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CI s -> m (CI s) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CI s -> m (CI s) #

Ord s => Ord (CI s) 

Methods

compare :: CI s -> CI s -> Ordering #

(<) :: CI s -> CI s -> Bool #

(<=) :: CI s -> CI s -> Bool #

(>) :: CI s -> CI s -> Bool #

(>=) :: CI s -> CI s -> Bool #

max :: CI s -> CI s -> CI s #

min :: CI s -> CI s -> CI s #

(Read s, FoldCase s) => Read (CI s) 
Show s => Show (CI s) 

Methods

showsPrec :: Int -> CI s -> ShowS #

show :: CI s -> String #

showList :: [CI s] -> ShowS #

(IsString s, FoldCase s) => IsString (CI s) 

Methods

fromString :: String -> CI s #

Semigroup s => Semigroup (CI s) 

Methods

(<>) :: CI s -> CI s -> CI s #

sconcat :: NonEmpty (CI s) -> CI s #

stimes :: Integral b => b -> CI s -> CI s #

Monoid s => Monoid (CI s) 

Methods

mempty :: CI s #

mappend :: CI s -> CI s -> CI s #

mconcat :: [CI s] -> CI s #

FoldCase (CI s) 

Methods

foldCase :: CI s -> CI s #

foldCaseList :: [CI s] -> [CI s]

NFData s => NFData (CI s) 

Methods

rnf :: CI s -> () #

Hashable s => Hashable (CI s) 

Methods

hashWithSalt :: Int -> CI s -> Int #

hash :: CI s -> Int #

(FoldCase a, FromText a) => FromText (CI a) # 

Methods

fromText :: StrictText -> CI a #

ToText a => ToText (CI a) # 

Methods

toText :: CI a -> StrictText #

Provided for efficiency

lazyByteStringToLazyText :: LazyByteString -> LazyText #

More efficient than throughText, replaces invalid characters with U+FFFD.

lazyTextToLazyByteString :: LazyText -> LazyByteString #

More efficient than throughText