@@ -1103,6 +1103,7 @@ WhereOrTerminator ::= WhereBlock | Terminator;
11031103-}
11041104clause :: SyntaxInfo -> IdrisParser PClause
11051105clause syn
1106+ -- unnamed with or function clause (inside a with)
11061107 = appExtent (do
11071108 wargs <- P.try (do pushIndent; some (wExpr syn))
11081109 ist <- get
@@ -1123,6 +1124,7 @@ clause syn
11231124 let withs = concat ds
11241125 closeBlock
11251126 return $ \fc -> PWithR fc wargs wval pn withs))
1127+ -- <==
11261128 <|> do ty <- P.try (do pushIndent
11271129 ty <- simpleExpr syn
11281130 symbol "<=="
@@ -1139,22 +1141,23 @@ clause syn
11391141 ist <- get
11401142 put (ist { lastParse = Just n })
11411143 return $ PClause fc n capp [] r wheres
1142− <|> do (l, op, nfc) <- P.try (do
1143− pushIndent
1144− l <- argExpr syn
1145− (op, nfc) <- withExtent symbolicOperator
1146− when (op == "=" || op == "?=" ) $
1147− fail "infix clause definition with \"=\" and \"?=\" not supported "
1148− return (l, op, nfc))
1149− let n = expandNS syn (sUN op)
1150− r <- argExpr syn
1151− wargs <- many (wExpr syn)
1144+ -- infix with or function clause
1145+ <|> do pushIndent
1146+ ((n, nfc, args, wargs), lhs_fc) <- P.try $ withExtent (do
1147+ l <- argExpr syn
1148+ (op, nfc) <- withExtent symbolicOperator
1149+ when (op == "=" || op == "?=" ) $
1150+ fail "infix clause definition with \"=\" and \"?=\" not supported "
1151+ let n = expandNS syn (sUN op)
1152+ r <- argExpr syn
1153+ wargs <- many (wExpr syn)
1154+ return (n, nfc, [pexp l, pexp r], wargs))
1155+ let capp = PApp lhs_fc (PRef nfc [nfc] n) args
11521156 (do (rs, fc) <- withExtent (rhs syn n)
11531157 let wsyn = syn { syn_namespace = [] }
11541158 (wheres, nmap) <- whereBlock n wsyn <* popIndent
11551159 <|> ([], []) <$ terminator
11561160 ist <- get
1157− let capp = PApp fc (PRef nfc [nfc] n) [pexp l, pexp r]
11581161 put (ist { lastParse = Just n })
11591162 return $ PClause fc n capp wargs rs wheres) <|> (do
11601163 popIndent
@@ -1167,10 +1170,10 @@ clause syn
11671170 ds <- some $ fnDecl syn
11681171 closeBlock
11691172 ist <- get
1170− let capp = PApp fc (PRef fc [] n) [pexp l, pexp r]
11711173 let withs = map (fillLHSD n capp wargs) $ concat ds
11721174 put (ist { lastParse = Just n })
11731175 return $ PWith fc n capp wargs wval pn withs)
1176+ -- prefix with or function clause
11741177 <|> do pushIndent
11751178 ((n, nfc, args, wargs), lhs_fc) <- withExtent $ do
11761179 (n, nfc) <- withExtent (expandNS syn <$> fnName)