git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Generate proper name for names involving tick characters #133
commit71ebb7b85eae9671e6ef6376d325855a3485a63d authorPhil Freeman <paf31@cantab.net> dateSun 26 Jan 2014, 20:52 (13 years ago) parent5e3f09c
2 files changed+14−5
examples/passing/Tick.purs+7 src/Language/PureScript/Pretty/Common.hs+7−5
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 ((***), (<+>))
2626import Language.PureScript.Names
2727
2828identToJs :: Ident -> String
29−identToJs (Ident name) = name
30−identToJs (Op op) = concatMap opCharToString op
31− where
32− opCharToString :: Char -> String
33− opCharToString = (:) '$'. show . ord
29+identToJs (Ident name) = concatMap identCharToString name
30+identToJs (Op op) = concatMap identCharToString op
31+
32+identCharToString :: Char -> String
33+identCharToString c | isAlphaNum c = [c]
34+identCharToString '_' = "_"
35+identCharToString c = '$' : show (ord c)
3436
3537newtype Pattern u a b = Pattern { runPattern :: A.Kleisli (StateT u Maybe) a b } deriving (C.Category, A.Arrow, A.ArrowZero, A.ArrowPlus)
3638