purescript-0.15.7: PureScript Programming Language Compiler
Safe HaskellSafe-Inferred
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

Instances details
FromJSON PSString Source # 
Instance details

Defined in Language.PureScript.PSString

ToJSON PSString Source # 
Instance details

Defined in Language.PureScript.PSString

IsString PSString Source # 
Instance details

Defined in Language.PureScript.PSString

Monoid PSString Source # 
Instance details

Defined in Language.PureScript.PSString

Semigroup PSString Source # 
Instance details

Defined in Language.PureScript.PSString

Generic PSString Source # 
Instance details

Defined in Language.PureScript.PSString

Associated Types

type Rep PSString :: Type -> Type #

Methods

from :: PSString -> Rep PSString x #

to :: Rep PSString x -> PSString #

Show PSString Source # 
Instance details

Defined in Language.PureScript.PSString

NFData PSString Source # 
Instance details

Defined in Language.PureScript.PSString

Methods

rnf :: PSString -> () #

Eq PSString Source # 
Instance details

Defined in Language.PureScript.PSString

Ord PSString Source # 
Instance details

Defined in Language.PureScript.PSString

Serialise PSString Source # 
Instance details

Defined in Language.PureScript.PSString

type Rep PSString Source # 
Instance details

Defined in Language.PureScript.PSString

type Rep PSString = D1 ('MetaData "PSString" "Language.PureScript.PSString" "purescript-0.15.7-3xSYkQR1O27GufieOHVqoE" 'True) (C1 ('MetaCons "PSString" 'PrefixI 'True) (S1 ('MetaSel ('Just "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 PureScript escape sequences.

prettyPrintStringJS :: PSString -> Text Source #

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