git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Generate proper name for names involving tick characters #133
71ebb7bPhil Freeman
examples/passing/Tick.pursnew file+7
@@ -0,0 +1,7 @@
1+module Tick where
2+
3+test' x = x
4+
5+module Main where
6+
7+main = Trace.trace "Done"
src/Language/PureScript/Pretty/Common.hs+7−5
@@ -26,11 +26,13 @@ import Control.Arrow ((***), (<+>))
26import Language.PureScript.Names
26import Language.PureScript.Names
27
27
28identToJs :: Ident -> String
28identToJs :: Ident -> String
29−identToJs (Ident name) = name
29+identToJs (Ident name) = concatMap identCharToString name
30−identToJs (Op op) = concatMap opCharToString op
30+identToJs (Op op) = concatMap identCharToString op
31− where
31+
32− opCharToString :: Char -> String
32+identCharToString :: Char -> String
33− opCharToString = (:) '$'. show . ord
33+identCharToString c | isAlphaNum c = [c]
34+identCharToString '_' = "_"
35+identCharToString c = '$' : show (ord c)
34
36
35newtype Pattern u a b = Pattern { runPattern :: A.Kleisli (StateT u Maybe) a b } deriving (C.Category, A.Arrow, A.ArrowZero, A.ArrowPlus)
37newtype Pattern u a b = Pattern { runPattern :: A.Kleisli (StateT u Maybe) a b } deriving (C.Category, A.Arrow, A.ArrowZero, A.ArrowPlus)
36
38