Safe Haskell | None |
---|---|
Language | Haskell98 |
Common code generation utility functions
- moduleNameToJs :: ModuleName -> Text
- identToJs :: Ident -> Text
- properToJs :: Text -> Text
- identNeedsEscaping :: Text -> Bool
- identCharToText :: Char -> Text
- nameIsJsReserved :: Text -> Bool
- nameIsJsBuiltIn :: Text -> Bool
- jsAnyReserved :: [Text]
- jsKeywords :: [Text]
- jsSometimesReserved :: [Text]
- jsFutureReserved :: [Text]
- jsFutureReservedStrict :: [Text]
- jsOldReserved :: [Text]
- jsLiterals :: [Text]
Documentation
moduleNameToJs :: ModuleName -> Text Source #
identToJs :: Ident -> Text Source #
Convert an Ident into a valid Javascript identifier:
- Alphanumeric characters are kept unmodified.
- Reserved javascript identifiers are prefixed with
$$
. - Symbols are prefixed with
$
followed by a symbol name or their ordinal value.
properToJs :: Text -> Text Source #
identNeedsEscaping :: Text -> Bool Source #
Test if a string is a valid JS identifier without escaping.
identCharToText :: Char -> Text Source #
Attempts to find a human-readable name for a symbol, if none has been specified returns the ordinal value.
nameIsJsReserved :: Text -> Bool Source #
Checks whether an identifier name is reserved in Javascript.
nameIsJsBuiltIn :: Text -> Bool Source #
Checks whether a name matches a built-in value in Javascript.
jsAnyReserved :: [Text] Source #
jsKeywords :: [Text] Source #
jsSometimesReserved :: [Text] Source #
jsFutureReserved :: [Text] Source #
jsOldReserved :: [Text] Source #
jsLiterals :: [Text] Source #