purescript-0.15.15: PureScript Programming Language Compiler

Safe Haskell | None
Language | Haskell2010

Language.PureScript.PSString

Synopsis

- data PSString
- toUTF16CodeUnits :: PSString -> [Word16]
- decodeString :: PSString -> Maybe Text
- decodeStringEither :: PSString -> [Either Word16 Char]
- decodeStringWithReplacement :: PSString -> String
- prettyPrintString :: PSString -> Text
- prettyPrintStringJS :: PSString -> Text
- mkString :: Text -> PSString

# 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 Methods parseJSON :: Value -> Parser PSString # parseJSONList :: Value -> Parser [PSString] # omittedField :: Maybe PSString #
ToJSON PSString # |
Instance details Defined in Language.PureScript.PSString Methods toJSON :: PSString -> Value # toEncoding :: PSString -> Encoding # toJSONList :: [PSString] -> Value # toEncodingList :: [PSString] -> Encoding # omitField :: PSString -> Bool #
NFData PSString # |
Instance details Defined in Language.PureScript.PSString Methods rnf :: PSString -> () #
Monoid PSString # |
Instance details Defined in Language.PureScript.PSString Methods mempty :: PSString # mappend :: PSString -> PSString -> PSString # mconcat :: [PSString] -> PSString #
Semigroup PSString # |
Instance details Defined in Language.PureScript.PSString Methods (<>) :: PSString -> PSString -> PSString # sconcat :: NonEmpty PSString -> PSString # stimes :: Integral b => b -> PSString -> PSString #
IsString PSString # |
Instance details Defined in Language.PureScript.PSString Methods fromString :: String -> 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 Methods showsPrec :: Int -> PSString -> ShowS # show :: PSString -> String # showList :: [PSString] -> ShowS #
Eq PSString # |
Instance details Defined in Language.PureScript.PSString Methods (==) :: PSString -> PSString -> Bool # (/=) :: PSString -> PSString -> Bool #
Ord PSString # |
Instance details Defined in Language.PureScript.PSString Methods compare :: PSString -> PSString -> Ordering # (<) :: PSString -> PSString -> Bool # (<=) :: PSString -> PSString -> Bool # (>) :: PSString -> PSString -> Bool # (>=) :: PSString -> PSString -> Bool # max :: PSString -> PSString -> PSString # min :: PSString -> PSString -> PSString #
Serialise PSString # |
Instance details Defined in Language.PureScript.PSString Methods encode :: PSString -> Encoding # decode :: Decoder s PSString # encodeList :: [PSString] -> Encoding # decodeList :: Decoder s [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])))

toUTF16CodeUnits :: PSString -> [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.

mkString :: Text -> PSString #