3
3
module Parse.Helpers where
4
4
5
5
import Prelude hiding (until )
6
- import Control.Monad (guard )
6
+ import Control.Monad (guard , void , when )
7
7
import qualified Data.Indexed as I
8
8
import Data.Map.Strict hiding (foldl )
9
- import Parse.ParsecAdapter hiding ( newline , spaces , State )
9
+ import Parse.ParsecAdapter
10
10
11
11
import AST.V0_16
12
12
import qualified AST.Helpers as Help
@@ -136,47 +136,47 @@ symOpInParens =
136
136
137
137
equals :: IParser ()
138
138
equals =
139
- const () <$> char ' =' <?> " ="
139
+ void ( char ' =' <?> " =" )
140
140
141
141
142
142
lenientEquals :: IParser ()
143
143
lenientEquals =
144
- const () <$> (char ' =' <|> char ' :' ) <?> " ="
144
+ void ( (char ' =' <|> char ' :' ) <?> " =" )
145
145
146
146
147
147
rightArrow :: IParser ()
148
148
rightArrow =
149
- const () <$> (string " ->" <|> string " \8594" ) <?> " ->"
149
+ void ( (string " ->" <|> string " \8594" <|> string " => " ) <?> " ->" )
150
150
151
151
152
152
cons :: IParser ()
153
153
cons =
154
- const () <$> string " ::" <?> " a cons operator '::'"
154
+ void ( string " ::" <?> " a cons operator '::'" )
155
155
156
156
157
157
hasType :: IParser ()
158
158
hasType =
159
- const () <$> char ' :' <?> " the \" has type\" symbol ':'"
159
+ void ( char ' :' <?> " the \" has type\" symbol ':'" )
160
160
161
161
162
162
lenientHasType :: IParser ()
163
163
lenientHasType =
164
- const () <$> (char ' :' <|> char ' =' ) <?> " the \" has type\" symbol ':'"
164
+ void ( (char ' :' <|> char ' =' ) <?> " the \" has type\" symbol ':'" )
165
165
166
166
167
167
comma :: IParser ()
168
168
comma =
169
- const () <$> char ' ,' <?> " a comma ','"
169
+ void ( char ' ,' <?> " a comma ','" )
170
170
171
171
172
172
semicolon :: IParser ()
173
173
semicolon =
174
- const () <$> char ' ;' <?> " a semicolon ';'"
174
+ void ( char ' ;' <?> " a semicolon ';'" )
175
175
176
176
177
177
verticalBar :: IParser ()
178
178
verticalBar =
179
- const () <$> char ' |' <?> " a vertical bar '|'"
179
+ void ( char ' |' <?> " a vertical bar '|'" )
180
180
181
181
182
182
commitIf :: IParser any -> IParser a -> IParser a
@@ -339,7 +339,7 @@ constrainedSpacePrefix :: IParser a -> IParser [(C1 before a, Multiline)]
339
339
constrainedSpacePrefix parser =
340
340
constrainedSpacePrefix' parser constraint
341
341
where
342
- constraint empty = if empty then notFollowedBy (char ' -' ) else return ( )
342
+ constraint empty = when empty $ notFollowedBy (char ' -' )
343
343
344
344
345
345
constrainedSpacePrefix' :: IParser a -> (Bool -> IParser b ) -> IParser [(C1 before a , Multiline )]
@@ -439,7 +439,7 @@ surround'' leftDelim rightDelim inner =
439
439
sep''' =
440
440
do
441
441
v <- (\ pre a post -> C (pre, post) a) <$> whitespace <*> inner <*> whitespace
442
- option [v] ((\ x -> v : x ) <$> (char ' ,' >> sep'''))
442
+ option [v] ((v : ) <$> (char ' ,' >> sep'''))
443
443
sep'' =
444
444
do
445
445
pre <- whitespace
@@ -448,7 +448,7 @@ surround'' leftDelim rightDelim inner =
448
448
Nothing ->
449
449
return $ Left pre
450
450
Just v' ->
451
- Right <$> option [v'] ((\ x -> v' : x ) <$> (char ' ,' >> sep'''))
451
+ Right <$> option [v'] ((v' : ) <$> (char ' ,' >> sep'''))
452
452
in
453
453
do
454
454
_ <- char leftDelim
@@ -501,8 +501,7 @@ commentedKeyword elmVersion word parser =
501
501
do
502
502
pre <- try (whitespace <* reserved elmVersion word)
503
503
post <- whitespace
504
- value <- parser
505
- return $ C (pre, post) value
504
+ C (pre, post) <$> parser
506
505
507
506
508
507
-- ODD COMBINATORS
0 commit comments