git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Add Escaped constructor to Ident to prevent double mangling of names
80141e6Phil Freeman
src/Language/PureScript/Names.hs+6−1
@@ -30,11 +30,16 @@ data Ident
30 -- |
30 -- |
31 -- A symbolic name for an infix operator
31 -- A symbolic name for an infix operator
32 --
32 --
33+ | Op String
34+ -- |
35+ -- An escaped name
36+ --
33− | Op String deriving (Eq, Ord, Data, Typeable)
37+ | Escaped String deriving (Eq, Ord, Data, Typeable)
34
38
35instance Show Ident where
39instance Show Ident where
36 show (Ident s) = s
40 show (Ident s) = s
37 show (Op op) = '(':op ++ ")"
41 show (Op op) = '(':op ++ ")"
42+ show (Escaped s) = s
38
43
39-- |
44-- |
40-- Proper names, i.e. capitalized names for e.g. module names, type//data constructors.
45-- Proper names, i.e. capitalized names for e.g. module names, type//data constructors.
src/Language/PureScript/Pretty/Common.hs+1
@@ -36,6 +36,7 @@ import Language.PureScript.Names
36identToJs :: Ident -> String
36identToJs :: Ident -> String
37identToJs (Ident name) = concatMap identCharToString name
37identToJs (Ident name) = concatMap identCharToString name
38identToJs (Op op) = concatMap identCharToString op
38identToJs (Op op) = concatMap identCharToString op
39+identToJs (Escaped name) = name
39
40
40identCharToString :: Char -> String
41identCharToString :: Char -> String
41identCharToString c | isAlphaNum c = [c]
42identCharToString c | isAlphaNum c = [c]
src/Language/PureScript/Sugar/TypeClasses.hs+1−1
@@ -151,4 +151,4 @@ typeToString a b = Left $ "Type class instance must be of the form T a1 ... an "
151mkDictionaryEntryName :: ModuleName -> Qualified ProperName -> Type -> Ident -> Desugar Ident
151mkDictionaryEntryName :: ModuleName -> Qualified ProperName -> Type -> Ident -> Desugar Ident
152mkDictionaryEntryName mn name ty ident = do
152mkDictionaryEntryName mn name ty ident = do
153 Ident dictName <- lift $ mkDictionaryValueName mn name ty
153 Ident dictName <- lift $ mkDictionaryValueName mn name ty
154− return $ Ident $ dictName ++ "_" ++ identToJs ident
154+ return $ Escaped $ dictName ++ "_" ++ identToJs ident