@@ -195,17 +195,24 @@ expr = addLocation (choice [ ifExpr, letExpr, caseExpr ])
195195 <|> binaryExpr
196196 <?> "an expression"
197197
198−funcDef = try (do p1 <- try Pattern.term ; infics p1 <|> func p1)
199− <|> ((:[]) <$> Pattern.expr)
200− <?> "the definition of a variable (x = ...)"
201− where func p@(PVar v) = (p:) <$> spacePrefix Pattern.term
202− func p = do try (lookAhead (whitespace >> string "="))
203− return [p]
204− infics p1 = do
205− o:p <- try (whitespace >> anyOp)
206− p2 <- (whitespace >> Pattern.term)
207− return $ if o == '`' then [ PVar $ takeWhile (/='`') p, p1, p2 ]
208− else [ PVar (o:p), p1, p2 ]
198+funcDef =
199+ choice [ do p1 <- try Pattern.term
200+ infics p1 <|> func p1
201+ , func =<< (PVar <$> parens symOp)
202+ , (:[]) <$> Pattern.expr
203+ ] <?> "the definition of a variable (x = ...)"
204+ where
205+ func pattern =
206+ case pattern of
207+ PVar v -> (pattern:) <$> spacePrefix Pattern.term
208+ _ -> do try (lookAhead (whitespace >> string "="))
209+ return [pattern]
210+
211+ infics p1 = do
212+ o:p <- try (whitespace >> anyOp)
213+ p2 <- (whitespace >> Pattern.term)
214+ return $ if o == '`' then [ PVar $ takeWhile (/='`') p, p1, p2 ]
215+ else [ PVar (o:p), p1, p2 ]
209216
210217makeFunction :: [Pattern] -> LExpr t v -> LExpr t v
211218makeFunction args body@(L a b _) =