-
Notifications
You must be signed in to change notification settings - Fork 395
docs: added library documentation for Elab
#3635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,66 +29,96 @@ mutual | |||||||
| | UnderAppliedCon | ||||||||
| %name DotReason dr | ||||||||
|
|
||||||||
| ||| The elaborator representation of an Idris term | ||||||||
| ||| All of these take a file context `FC` as their first argument | ||||||||
| public export | ||||||||
| data TTImp : Type where | ||||||||
| ||| A variable reference, by name | ||||||||
| IVar : FC -> Name -> TTImp | ||||||||
| IPi : FC -> Count -> PiInfo TTImp -> Maybe Name -> | ||||||||
| ||| A function type, of the form `(mult binder : argTy) -> retTy`, with implicitness determined by `info` | ||||||||
| IPi : FC -> (mult : Count) -> (info : PiInfo TTImp) -> (binder : Maybe Name) -> | ||||||||
| (argTy : TTImp) -> (retTy : TTImp) -> TTImp | ||||||||
| ILam : FC -> Count -> PiInfo TTImp -> Maybe Name -> | ||||||||
| ||| A lambda abstraction, of the form`\(mult binder : argTy) => retTy`, with implicitness determined by `info` | ||||||||
| ILam : FC -> (mult : Count) -> (info : PiInfo TTImp) -> (binder : Maybe Name) -> | ||||||||
| (argTy : TTImp) -> (lamTy : TTImp) -> TTImp | ||||||||
| ILet : FC -> (lhsFC : FC) -> Count -> Name -> | ||||||||
| ||| A let binding, of the form `let mult var : nTy = nVal in scope` | ||||||||
| ILet : FC -> (lhsFC : FC) -> (mult : Count) -> (var : Name) -> | ||||||||
| (nTy : TTImp) -> (nVal : TTImp) -> | ||||||||
| (scope : TTImp) -> TTImp | ||||||||
| ICase : FC -> List FnOpt -> TTImp -> (ty : TTImp) -> | ||||||||
| List Clause -> TTImp | ||||||||
| ILocal : FC -> List Decl -> TTImp -> TTImp | ||||||||
| IUpdate : FC -> List IFieldUpdate -> TTImp -> TTImp | ||||||||
|
|
||||||||
wizard7377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| IApp : FC -> TTImp -> TTImp -> TTImp | ||||||||
| INamedApp : FC -> TTImp -> Name -> TTImp -> TTImp | ||||||||
| IAutoApp : FC -> TTImp -> TTImp -> TTImp | ||||||||
| ||| A case expression `case val : ty of clauses` | ||||||||
| ICase : FC -> (opts : List FnOpt) -> (val : TTImp) -> (ty : TTImp) -> | ||||||||
| (clauses : List Clause) -> TTImp | ||||||||
| ||| A list of full declarations local to a term | ||||||||
| ILocal : FC -> (context : List Decl) -> (term : TTImp) -> TTImp | ||||||||
| ||| An update to a record value, `{ updates } val` | ||||||||
| IUpdate : FC -> (updates : List IFieldUpdate) -> (val : TTImp) -> TTImp | ||||||||
|
|
||||||||
| ||| A function application, `f x` | ||||||||
| IApp : FC -> (f : TTImp) -> (x : TTImp) -> TTImp | ||||||||
| ||| A named function application (for named parameters), e.g, `f {arg=x}` | ||||||||
| INamedApp : FC -> (f : TTImp) -> (arg : Name) -> (x : TTImp) -> TTImp | ||||||||
| ||| An explicitly inserted auto implicit, `f @{x}` | ||||||||
| IAutoApp : FC -> (f : TTImp) -> (x : TTImp) -> TTImp | ||||||||
| ||| A view in a `with` rule | ||||||||
| IWithApp : FC -> TTImp -> TTImp -> TTImp | ||||||||
|
Comment on lines
+62
to
63
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a view. View with |
||||||||
|
|
||||||||
wizard7377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| ||| `%search` | ||||||||
| ISearch : FC -> (depth : Nat) -> TTImp | ||||||||
| ||| This operation is for expression that tries to typecheck expression in the list according to the given AltType and return either one of them, or default one (if present in the AltType), or fails | ||||||||
| IAlternative : FC -> AltType -> List TTImp -> TTImp | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This operation is for expression that tries to typecheck expression in the list according to the given
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because I'm not familiar with this, I'm just going to copy paste your description if that's alright with you
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's okay |
||||||||
| IRewrite : FC -> TTImp -> TTImp -> TTImp | ||||||||
| ||| A rewrite expression, `rewrite eq in exp` | ||||||||
| IRewrite : FC -> (eq : TTImp) -> (exp : TTImp) -> TTImp | ||||||||
|
|
||||||||
| -- Any implicit bindings in the scope should be bound here, using | ||||||||
| -- the given binder | ||||||||
| ||| Any implicit bindings in the scope should be bound here, using | ||||||||
| ||| the given binder | ||||||||
| IBindHere : FC -> BindMode -> TTImp -> TTImp | ||||||||
|
Comment on lines
+72
to
74
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say "A bound for implicit bindings to be automatically bound using the given bind mode" |
||||||||
| -- A name which should be implicitly bound | ||||||||
| ||| A name which should be implicitly bound | ||||||||
| IBindVar : FC -> Name -> TTImp | ||||||||
| -- An 'as' pattern, valid on the LHS of a clause only | ||||||||
| IAs : FC -> (nameFC : FC) -> UseSide -> Name -> TTImp -> TTImp | ||||||||
| -- A 'dot' pattern, i.e. one which must also have the given value | ||||||||
| -- by unification | ||||||||
| ||| An 'as' pattern, valid on the LHS of a clause only, `group@pat` | ||||||||
| IAs : FC -> (nameFC : FC) -> UseSide -> (group : Name) -> (pat : TTImp) -> TTImp | ||||||||
| ||| A 'dot' pattern, i.e. one which must also have the given value | ||||||||
| ||| by unification, `.(...)` | ||||||||
| IMustUnify : FC -> DotReason -> TTImp -> TTImp | ||||||||
|
|
||||||||
| -- Laziness annotations | ||||||||
| IDelayed : FC -> LazyReason -> TTImp -> TTImp -- the type | ||||||||
| IDelay : FC -> TTImp -> TTImp -- delay constructor | ||||||||
| ||| The delay type, `Delay t` | ||||||||
| IDelayed : FC -> LazyReason -> TTImp -> TTImp | ||||||||
|
Comment on lines
+84
to
+85
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delay types are |
||||||||
| ||| The constructor of `Delay`, `delay t` | ||||||||
| IDelay : FC -> TTImp -> TTImp | ||||||||
|
Comment on lines
+86
to
+87
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||
| ||| `force` | ||||||||
| IForce : FC -> TTImp -> TTImp | ||||||||
|
Comment on lines
+88
to
89
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same for above, |
||||||||
|
|
||||||||
| -- Quasiquotation | ||||||||
| ||| Quasi-quotation of expression (`( ... )) | ||||||||
| IQuote : FC -> TTImp -> TTImp | ||||||||
| ||| Quasi-quotation of a name (`{ ... }) | ||||||||
| IQuoteName : FC -> Name -> TTImp | ||||||||
| ||| Quasi-quotation of a list of declarations (`[ ... ]) | ||||||||
| IQuoteDecl : FC -> List Decl -> TTImp | ||||||||
| ||| Unquote of an expression (~e) | ||||||||
| IUnquote : FC -> TTImp -> TTImp | ||||||||
|
|
||||||||
| ||| A primitive value, such as an integer or string constant. | ||||||||
| ||| Also any primitive *type*, apart from `Type` itself | ||||||||
| IPrimVal : FC -> (c : Constant) -> TTImp | ||||||||
| ||| The type `Type` | ||||||||
| IType : FC -> TTImp | ||||||||
| ||| A named hole | ||||||||
| IHole : FC -> String -> TTImp | ||||||||
|
|
||||||||
| -- An implicit value, solved by unification, but which will also be | ||||||||
| -- bound (either as a pattern variable or a type variable) if unsolved | ||||||||
| -- at the end of elaborator | ||||||||
| ||| An implicit value, solved by unification, but which will also be | ||||||||
| ||| bound (either as a pattern variable or a type variable) if unsolved | ||||||||
| ||| at the end of elaborator. | ||||||||
|
Comment on lines
+108
to
+109
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what is said about the bound. I mean, if |
||||||||
| ||| Note that `Implicit False` is `?`, while `Implicit True` is `_` | ||||||||
| Implicit : FC -> (bindIfUnsolved : Bool) -> TTImp | ||||||||
wizard7377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| IWithUnambigNames : FC -> List (FC, Name) -> TTImp -> TTImp | ||||||||
| ||| `with name exp` | ||||||||
| IWithUnambigNames : FC -> (name : List (FC, Name)) -> (exp : TTImp) -> TTImp | ||||||||
|
Comment on lines
+112
to
+113
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd add that except it is |
||||||||
| %name TTImp s, t, u | ||||||||
|
|
||||||||
| ||| A record field update | ||||||||
| public export | ||||||||
| data IFieldUpdate : Type where | ||||||||
| ||| `path := val` | ||||||||
| ISetField : (path : List String) -> TTImp -> IFieldUpdate | ||||||||
| ||| `path $= val` | ||||||||
| ISetFieldApp : (path : List String) -> TTImp -> IFieldUpdate | ||||||||
|
|
||||||||
| %name IFieldUpdate upd | ||||||||
|
|
@@ -105,22 +135,23 @@ mutual | |||||||
| NoInline : FnOpt | ||||||||
| Deprecate : FnOpt | ||||||||
| TCInline : FnOpt | ||||||||
| -- Flag means the hint is a direct hint, not a function which might | ||||||||
| -- find the result (e.g. chasing parent interface dictionaries) | ||||||||
| ||| Flag means the hint is a direct hint, not a function which might | ||||||||
| ||| find the result (e.g. chasing parent interface dictionaries) | ||||||||
| Hint : Bool -> FnOpt | ||||||||
| -- Flag means to use as a default if all else fails | ||||||||
| ||| `%globalhint` if true, `%defaulthint` if false | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| GlobalHint : Bool -> FnOpt | ||||||||
wizard7377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| ExternFn : FnOpt | ||||||||
| -- Defined externally, list calling conventions | ||||||||
| ||| Defined externally, list calling conventions | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| ForeignFn : List TTImp -> FnOpt | ||||||||
| -- Mark for export to a foreign language, list calling conventions | ||||||||
| ||| Mark for export to a foreign language, list calling conventions | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| ForeignExport : List TTImp -> FnOpt | ||||||||
| -- assume safe to cancel arguments in unification | ||||||||
| ||| assume safe to cancel arguments in unification | ||||||||
| Invertible : FnOpt | ||||||||
| Totality : TotalReq -> FnOpt | ||||||||
| ||| `%macro` | ||||||||
| Macro : FnOpt | ||||||||
wizard7377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| SpecArgs : List Name -> FnOpt | ||||||||
|
|
||||||||
| ||| A name with an associated type | ||||||||
| public export | ||||||||
| data ITy : Type where | ||||||||
| MkTy : FC -> (n : WithFC Name) -> (ty : TTImp) -> ITy | ||||||||
|
|
@@ -129,11 +160,16 @@ mutual | |||||||
|
|
||||||||
| public export | ||||||||
| data DataOpt : Type where | ||||||||
| SearchBy : List1 Name -> DataOpt -- determining arguments | ||||||||
| NoHints : DataOpt -- Don't generate search hints for constructors | ||||||||
| UniqueSearch : DataOpt -- auto implicit search must check result is unique | ||||||||
| External : DataOpt -- implemented externally | ||||||||
| NoNewtype : DataOpt -- don't apply newtype optimisation | ||||||||
| ||| Determining arguments | ||||||||
| SearchBy : List1 Name -> DataOpt | ||||||||
| ||| Don't generate search hints for constructors | ||||||||
| NoHints : DataOpt | ||||||||
| ||| Auto implicit search must check result is unique | ||||||||
| UniqueSearch : DataOpt | ||||||||
| ||| Implemented externally | ||||||||
| External : DataOpt | ||||||||
| ||| Don't apply newtype optimization | ||||||||
| NoNewtype : DataOpt | ||||||||
|
|
||||||||
| %name DataOpt dopt | ||||||||
|
|
||||||||
|
|
@@ -165,15 +201,18 @@ mutual | |||||||
|
|
||||||||
| public export | ||||||||
| data WithFlag = Syntactic | ||||||||
|
|
||||||||
| ||| A clause in a function definition | ||||||||
| public export | ||||||||
| data Clause : Type where | ||||||||
| ||| A simple pattern | ||||||||
| PatClause : FC -> (lhs : TTImp) -> (rhs : TTImp) -> Clause | ||||||||
| ||| A pattern with views | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, we could add the surface syntax here, like <lhs> with <rig> (<wval>) proof <prf>
<subclauses> |
||||||||
| WithClause : FC -> (lhs : TTImp) -> | ||||||||
| (rig : Count) -> (wval : TTImp) -> -- with'd expression (& quantity) | ||||||||
| (prf : Maybe (Count, Name)) -> -- optional name for the proof (& quantity) | ||||||||
| (flags : List WithFlag) -> | ||||||||
| List Clause -> Clause | ||||||||
| ||| An impossible pattern | ||||||||
| ImpossibleClause : FC -> (lhs : TTImp) -> Clause | ||||||||
|
|
||||||||
| %name Clause cl | ||||||||
|
|
@@ -209,22 +248,34 @@ mutual | |||||||
| (opts : List FnOpt) -> | ||||||||
| (type : ITy) -> | ||||||||
| IClaimData | ||||||||
|
|
||||||||
| ||| A top-level declaration | ||||||||
| public export | ||||||||
| data Decl : Type where | ||||||||
| IClaim : WithFC IClaimData -> Decl | ||||||||
| IData : FC -> WithDefault Visibility Private -> Maybe TotalReq -> Data -> Decl | ||||||||
| IDef : FC -> Name -> (cls : List Clause) -> Decl | ||||||||
| ||| A type ascription, `a : b`. | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type ascription term is used then you try to refine the type of an expression. I think, this should be called "a function signature" |
||||||||
| ||| Called a claim because of Curry Howard, the statement `x : p` is equivalent to `x` is a proof of `p`. | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this line is a valid one. I thought it is a claim because it starts definition of a function, but does not define its body |
||||||||
| IClaim : (claim : WithFC IClaimData) -> Decl | ||||||||
| ||| A data declaration | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| IData : FC -> (vis : WithDefault Visibility Private) -> Maybe TotalReq -> (cons : Data) -> Decl | ||||||||
| ||| A function definition by its clauses | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| IDef : FC -> (f : Name) -> (cls : List Clause) -> Decl | ||||||||
| ||| A parameter block | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest giving an example here, something like
Suggested change
|
||||||||
| IParameters : FC -> (params : List (Name, Count, PiInfo TTImp, TTImp)) -> | ||||||||
| (decls : List Decl) -> Decl | ||||||||
| ||| A record declaration | ||||||||
| ||| @ ns Nested namespace | ||||||||
| IRecord : FC -> | ||||||||
| Maybe String -> -- nested namespace | ||||||||
| WithDefault Visibility Private -> | ||||||||
| Maybe TotalReq -> Record -> Decl | ||||||||
| (ns : Maybe String) -> | ||||||||
| (vis : WithDefault Visibility Private) -> | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any need for names here? I suppose, their types are self expanatory and they are not used on the documentation either, so these names, I think, just clutter reading. What do you think? |
||||||||
| (totality : Maybe TotalReq) -> (rec : Record) -> Decl | ||||||||
| ||| A namespace declaration, `namespace ns where decls` | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In namespace syntax where is not |
||||||||
| INamespace : FC -> Namespace -> (decls : List Decl) -> Decl | ||||||||
| ||| A transformation declaration | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| ITransform : FC -> Name -> TTImp -> TTImp -> Decl | ||||||||
| ||| A top-level elaboration run | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| IRunElabDecl : FC -> TTImp -> Decl | ||||||||
| ||| A logging directive | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| ILog : Maybe (List String, Nat) -> Decl | ||||||||
| ||| A builtin declaration, `%builtin type name` | ||||||||
| IBuiltin : FC -> BuiltinType -> Name -> Decl | ||||||||
|
|
||||||||
| %name Decl decl | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please change
infotopiinfo, becauseinfoseems to be too generic