Skip to content

Commit 2711d85

Browse files
committed
Apply feedback by @avh4
1 parent b4d760d commit 2711d85

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

elm-format-lib/src/Parse/Helpers.hs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
module Parse.Helpers where
44

55
import Prelude hiding (until)
6-
import Control.Monad (guard)
6+
import Control.Monad (guard, void, when)
77
import qualified Data.Indexed as I
88
import Data.Map.Strict hiding (foldl)
9-
import Parse.ParsecAdapter hiding (newline, spaces, State)
9+
import Parse.ParsecAdapter
1010

1111
import AST.V0_16
1212
import qualified AST.Helpers as Help
@@ -136,47 +136,47 @@ symOpInParens =
136136

137137
equals :: IParser ()
138138
equals =
139-
const () <$> char '=' <?> "="
139+
void (char '=' <?> "=")
140140

141141

142142
lenientEquals :: IParser ()
143143
lenientEquals =
144-
const () <$> (char '=' <|> char ':') <?> "="
144+
void ((char '=' <|> char ':') <?> "=")
145145

146146

147147
rightArrow :: IParser ()
148148
rightArrow =
149-
const () <$> (string "->" <|> string "\8594") <?> "->"
149+
void ((string "->" <|> string "\8594" <|> string "=>") <?> "->")
150150

151151

152152
cons :: IParser ()
153153
cons =
154-
const () <$> string "::" <?> "a cons operator '::'"
154+
void (string "::" <?> "a cons operator '::'")
155155

156156

157157
hasType :: IParser ()
158158
hasType =
159-
const () <$> char ':' <?> "the \"has type\" symbol ':'"
159+
void (char ':' <?> "the \"has type\" symbol ':'")
160160

161161

162162
lenientHasType :: IParser ()
163163
lenientHasType =
164-
const () <$> (char ':' <|> char '=') <?> "the \"has type\" symbol ':'"
164+
void ((char ':' <|> char '=') <?> "the \"has type\" symbol ':'")
165165

166166

167167
comma :: IParser ()
168168
comma =
169-
const () <$> char ',' <?> "a comma ','"
169+
void (char ',' <?> "a comma ','")
170170

171171

172172
semicolon :: IParser ()
173173
semicolon =
174-
const () <$> char ';' <?> "a semicolon ';'"
174+
void (char ';' <?> "a semicolon ';'")
175175

176176

177177
verticalBar :: IParser ()
178178
verticalBar =
179-
const () <$> char '|' <?> "a vertical bar '|'"
179+
void (char '|' <?> "a vertical bar '|'")
180180

181181

182182
commitIf :: IParser any -> IParser a -> IParser a
@@ -339,7 +339,7 @@ constrainedSpacePrefix :: IParser a -> IParser [(C1 before a, Multiline)]
339339
constrainedSpacePrefix parser =
340340
constrainedSpacePrefix' parser constraint
341341
where
342-
constraint empty = if empty then notFollowedBy (char '-') else return ()
342+
constraint empty = when empty $ notFollowedBy (char '-')
343343

344344

345345
constrainedSpacePrefix' :: IParser a -> (Bool -> IParser b) -> IParser [(C1 before a, Multiline)]
@@ -439,7 +439,7 @@ surround'' leftDelim rightDelim inner =
439439
sep''' =
440440
do
441441
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'''))
443443
sep'' =
444444
do
445445
pre <- whitespace
@@ -448,7 +448,7 @@ surround'' leftDelim rightDelim inner =
448448
Nothing ->
449449
return $ Left pre
450450
Just v' ->
451-
Right <$> option [v'] ((\x -> v' : x) <$> (char ',' >> sep'''))
451+
Right <$> option [v'] ((v' :) <$> (char ',' >> sep'''))
452452
in
453453
do
454454
_ <- char leftDelim
@@ -501,8 +501,7 @@ commentedKeyword elmVersion word parser =
501501
do
502502
pre <- try (whitespace <* reserved elmVersion word)
503503
post <- whitespace
504-
value <- parser
505-
return $ C (pre, post) value
504+
C (pre, post) <$> parser
506505

507506

508507
-- ODD COMBINATORS
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
foo : Int => Int => Int => Int
2+
foo = \a b c => a + b + c
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Main exposing (foo)
2+
3+
4+
foo : Int -> Int -> Int -> Int
5+
foo = \a b c -> a + b + c

0 commit comments

Comments
 (0)