feat: add strict implicit binder annotation
This commit is contained in:
parent
64f65d28e7
commit
257e38394f
2 changed files with 7 additions and 3 deletions
|
|
@ -93,9 +93,12 @@ def binderTactic := leading_parser atomic (symbol " := " >> " by ") >> Tactic.t
|
|||
def binderDefault := leading_parser " := " >> termParser
|
||||
def explicitBinder (requireType := false) := ppGroup $ leading_parser "(" >> many1 binderIdent >> binderType requireType >> optional (binderTactic <|> binderDefault) >> ")"
|
||||
def implicitBinder (requireType := false) := ppGroup $ leading_parser "{" >> many1 binderIdent >> binderType requireType >> "}"
|
||||
def strictImplicitLeftBracket := atomic (group (symbol "{" >> "{")) <|> "⦃"
|
||||
def strictImplicitRightBracket := atomic (group (symbol "}" >> "}")) <|> "⦄"
|
||||
def strictImplicitBinder (requireType := false) := ppGroup $ leading_parser strictImplicitLeftBracket >> many1 binderIdent >> binderType requireType >> strictImplicitRightBracket
|
||||
def instBinder := ppGroup $ leading_parser "[" >> optIdent >> termParser >> "]"
|
||||
def bracketedBinder (requireType := false) := withAntiquot (mkAntiquot "bracketedBinder" none (anonymous := false)) <|
|
||||
explicitBinder requireType <|> implicitBinder requireType <|> instBinder
|
||||
explicitBinder requireType <|> strictImplicitBinder requireType <|> implicitBinder requireType <|> instBinder
|
||||
|
||||
/-
|
||||
It is feasible to support dependent arrows such as `{α} → α → α` without sacrificing the quality of the error messages for the longer case.
|
||||
|
|
@ -139,8 +142,9 @@ def generalizingParam := leading_parser atomic ("(" >> nonReservedSymbol "genera
|
|||
@[builtinTermParser] def «nomatch» := leading_parser:leadPrec "nomatch " >> termParser
|
||||
|
||||
def funImplicitBinder := atomic (lookahead ("{" >> many1 binderIdent >> (symbol " : " <|> "}"))) >> implicitBinder
|
||||
def funStrictImplicitBinder := atomic (lookahead (strictImplicitLeftBracket >> many1 binderIdent >> (symbol " : " <|> strictImplicitRightBracket))) >> strictImplicitBinder
|
||||
def funSimpleBinder := atomic (lookahead (many1 binderIdent >> " : ")) >> simpleBinder
|
||||
def funBinder : Parser := funImplicitBinder <|> instBinder <|> funSimpleBinder <|> termParser maxPrec
|
||||
def funBinder : Parser := funStrictImplicitBinder <|> funImplicitBinder <|> instBinder <|> funSimpleBinder <|> termParser maxPrec
|
||||
-- NOTE: we use `nodeWithAntiquot` to ensure that `fun $b => ...` remains a `term` antiquotation
|
||||
def basicFun : Parser := nodeWithAntiquot "basicFun" `Lean.Parser.Term.basicFun (many1 (ppSpace >> funBinder) >> darrow >> termParser)
|
||||
@[builtinTermParser] def «fun» := leading_parser:maxPrec unicodeSymbol "λ" "fun" >> (basicFun <|> matchAlts)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
partialVariable.lean:1:9: error: expected '(', '[' or '{'
|
||||
partialVariable.lean:1:9: error: expected '(', '[', '{' or '⦃'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue