Skip to content

Commit 63a1aec

Browse files
committed
classify operator symbols like haskell-src-exts does
1 parent 02c311a commit 63a1aec

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Language/Haskell/Names/SyntaxUtils.hs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ module Language.Haskell.Names.SyntaxUtils
2121
-- export ExtensionSet here for the outside users
2222
, ExtensionSet
2323
, moduleExtensions
24+
, getModuleExtensions
2425
) where
2526
import Prelude hiding (concatMap)
2627
import Data.Char
2728
import Data.Maybe
2829
import Data.Either
29-
import Data.Foldable
30+
import Data.Foldable hiding (elem)
3031
import qualified Data.Set as Set
3132
import qualified Language.Haskell.Exts as UnAnn
3233
import Language.Haskell.Exts.Annotated
@@ -123,9 +124,14 @@ nameToString (Ident _ s) = s
123124
nameToString (Symbol _ s) = s
124125

125126
stringToName :: String -> Name ()
126-
stringToName s@(c:_) | isSymbol c = Symbol () s
127+
stringToName s@(c:_) | isHSymbol c = Symbol () s
127128
stringToName s = Ident () s
128129

130+
isHSymbol :: Char -> Bool
131+
isHSymbol c =
132+
c `elem` ":!#%&*./?@\\-" ||
133+
((isSymbol c || isPunctuation c) && not (c `elem` "(),;[]`{}_\"'"))
134+
129135
specialConToString :: SpecialCon l -> String
130136
specialConToString (UnitCon _) = "()"
131137
specialConToString (ListCon _) = "[]"

0 commit comments

Comments
 (0)