string-convert-4.0.0.1: Universal string conversions

Safe HaskellNone
LanguageHaskell2010

Text.StringConvert

Description

Provides universal conversions between any two string-like types. Out-of-the-box, Text (both lazy and strict), ByteString (both lazy and strict), and String, are supported.

To hook custom string types into the conversion mechanism, implement both IsString and ToString for your type.

Synopsis

Documentation

class IsString a where #

Class for string-like datastructures; used by the overloaded string extension (-XOverloadedStrings in GHC).

Minimal complete definition

fromString

Methods

fromString :: String -> a #

Instances

IsString ByteString 
IsString ByteString 
(~) * a Char => IsString [a] 

Methods

fromString :: String -> [a] #

IsString a => IsString (Identity a) 

Methods

fromString :: String -> Identity a #

IsString (Seq Char) 

Methods

fromString :: String -> Seq Char #

IsString a => IsString (Const * a b) 

Methods

fromString :: String -> Const * a b #

class ToString a where Source #

Defines how a given type should be converted to String. If at all possible, the conversion should be loss-less, and if encodings are involved, UTF-8 should be the default.

Minimal complete definition

toString

Methods

toString :: a -> String Source #

s :: (ToString a, IsString b) => a -> b Source #