diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-05-30 16:57:54 +0200 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-05-30 16:57:54 +0200 |
commit | a57d329a5e123013998624870e207acebfc86c52 (patch) | |
tree | 238e103078479da65742dbdd939ed43fc1c61663 /src | |
parent | 1c148d8dc222913d6e0ec7a8a30254fcbf25daab (diff) | |
download | stylish-haskell-a57d329a5e123013998624870e207acebfc86c52.tar.gz |
Can now replace => by ⇒
Diffstat (limited to 'src')
-rw-r--r-- | src/StylishHaskell/Stylish/UnicodeSyntax.hs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/StylishHaskell/Stylish/UnicodeSyntax.hs b/src/StylishHaskell/Stylish/UnicodeSyntax.hs index 1a62127..e6e9c74 100644 --- a/src/StylishHaskell/Stylish/UnicodeSyntax.hs +++ b/src/StylishHaskell/Stylish/UnicodeSyntax.hs @@ -1,5 +1,4 @@ -------------------------------------------------------------------------------- -{-# LANGUAGE UnicodeSyntax #-} module StylishHaskell.Stylish.UnicodeSyntax ( stylish ) where @@ -24,6 +23,7 @@ import StylishHaskell.Util unicodeReplacements :: Map String String unicodeReplacements = M.fromList [ ("->", "→") + , ("=>", "⇒") ] @@ -59,8 +59,8 @@ groupPerLine = M.toList . M.fromListWith (++) . -------------------------------------------------------------------------------- -types :: H.Module H.SrcSpanInfo -> Lines -> [((Int, Int), String)] -types module' ls = +typeFuns :: H.Module H.SrcSpanInfo -> Lines -> [((Int, Int), String)] +typeFuns module' ls = [ (pos, "->") | H.TyFun _ t1 t2 <- everything module' , let start = H.srcSpanEnd $ H.srcInfoSpan $ H.ann t1 @@ -70,6 +70,17 @@ types module' ls = -------------------------------------------------------------------------------- +contexts :: H.Module H.SrcSpanInfo -> Lines -> [((Int, Int), String)] +contexts module' ls = + [ (pos, "=>") + | context <- everything module' :: [H.Context H.SrcSpanInfo] + , point <- H.srcInfoPoints $ H.ann context + , let (start, end) = (H.srcSpanStart point, H.srcSpanEnd point) + , pos <- maybeToList $ between start end "=>" ls + ] + + +-------------------------------------------------------------------------------- -- | Search for a needle in a haystack of lines. Only part the inside (startRow, -- startCol), (endRow, endCol) is searched. The return value is the position of -- the needle. @@ -100,4 +111,6 @@ stylish :: Stylish stylish ls (module', _) = applyChanges changes ls where changes = replaceAll perLine ls - perLine = sort $ groupPerLine $ types module' ls + perLine = sort $ groupPerLine $ + typeFuns module' ls ++ + contexts module' ls |