purescript-0.15.15: PureScript Programming Language Compiler
Safe HaskellNone
LanguageHaskell2010

Language.PureScript.PSString

Synopsis

Documentation

data PSString #

Strings in PureScript are sequences of UTF-16 code units, which do not necessarily represent UTF-16 encoded text. For example, it is permissible for a string to contain *lone surrogates,* i.e. characters in the range U+D800 to U+DFFF which do not appear as a part of a surrogate pair.

The Show instance for PSString produces a string literal which would represent the same data were it inserted into a PureScript source file.

Because JSON parsers vary wildly in terms of how they deal with lone surrogates in JSON strings, the ToJSON instance for PSString produces JSON strings where that would be safe (i.e. when there are no lone surrogates), and arrays of UTF-16 code units (integers) otherwise.

Instances

Instances details
FromJSON PSString # 
Instance details

Defined in Language.PureScript.PSString

ToJSON PSString # 
Instance details

Defined in Language.PureScript.PSString

NFData PSString # 
Instance details

Defined in Language.PureScript.PSString

Methods

rnf :: PSString -> () #

Monoid PSString # 
Instance details

Defined in Language.PureScript.PSString

Semigroup PSString # 
Instance details

Defined in Language.PureScript.PSString

IsString PSString # 
Instance details

Defined in Language.PureScript.PSString

Generic PSString # 
Instance details

Defined in Language.PureScript.PSString

Associated Types

type Rep PSString 
Instance details

Defined in Language.PureScript.PSString

type Rep PSString = D1 ('MetaData "PSString" "Language.PureScript.PSString" "purescript-0.15.15-8K0LbmS63k4ILju2RsIrDp" 'True) (C1 ('MetaCons "PSString" 'PrefixI 'True) (S1 ('MetaSel ('Just "toUTF16CodeUnits") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Word16])))

Methods

from :: PSString -> Rep PSString x #

to :: Rep PSString x -> PSString #

Show PSString # 
Instance details

Defined in Language.PureScript.PSString

Eq PSString # 
Instance details

Defined in Language.PureScript.PSString

Ord PSString # 
Instance details

Defined in Language.PureScript.PSString

Serialise PSString # 
Instance details

Defined in Language.PureScript.PSString

type Rep PSString # 
Instance details

Defined in Language.PureScript.PSString

type Rep PSString = D1 ('MetaData "PSString" "Language.PureScript.PSString" "purescript-0.15.15-8K0LbmS63k4ILju2RsIrDp" 'True) (C1 ('MetaCons "PSString" 'PrefixI 'True) (S1 ('MetaSel ('Just "toUTF16CodeUnits") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Word16])))

decodeString :: PSString -> Maybe Text #

Attempt to decode a PSString as UTF-16 text. This will fail (returning Nothing) if the argument contains lone surrogates.

decodeStringEither :: PSString -> [Either Word16 Char] #

Decode a PSString as UTF-16. Lone surrogates in the input are represented in the output with the Left constructor; characters which were successfully decoded are represented with the Right constructor.

decodeStringWithReplacement :: PSString -> String #

Decode a PSString as UTF-16 text. Lone surrogates will be replaced with U+FFFD REPLACEMENT CHARACTER

prettyPrintString :: PSString -> Text #

Pretty print a PSString, using PureScript escape sequences.

prettyPrintStringJS :: PSString -> Text #

Pretty print a PSString, using JavaScript escape sequences. Intended for use in compiled JS output.