purescript-0.11.7: PureScript Programming Language Compiler

Safe HaskellNone
LanguageHaskell2010

Language.PureScript.PSString

Synopsis

Documentation

data PSString Source #

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

Eq PSString Source # 
Ord PSString Source # 
Show PSString Source # 
IsString PSString Source # 
Generic PSString Source # 

Associated Types

type Rep PSString :: * -> * #

Methods

from :: PSString -> Rep PSString x #

to :: Rep PSString x -> PSString #

Monoid PSString Source # 
FromJSON PSString Source # 
ToJSON PSString Source # 
NFData PSString Source # 

Methods

rnf :: PSString -> () #

type Rep PSString Source # 
type Rep PSString = D1 (MetaData "PSString" "Language.PureScript.PSString" "purescript-0.11.7-LYkkdaNPe76o3Ss2KvZX" True) (C1 (MetaCons "PSString" PrefixI True) (S1 (MetaSel (Just Symbol "toUTF16CodeUnits") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Word16])))

decodeString :: PSString -> Maybe Text Source #

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] Source #

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 Source #

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

prettyPrintString :: PSString -> Text Source #

Pretty print a PSString, using Haskell/PureScript escape sequences. This is identical to the Show instance except that we get a Text out instead of a String.

prettyPrintStringJS :: PSString -> Text Source #

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