@@ -116,22 +116,62 @@ data NameType =
117||| Types annotations for bound variables in different
117||| Types annotations for bound variables in different
118||| binding contexts
118||| binding contexts
120+||| @ tmTy the terms that can occur inside the binder, as type
121+||| annotations or bound values
119−data Binder a = Lam a
122+data Binder : (tmTy : Type) -> Type where
125+ ||| @ ty the type of the argument
126+ Lam : (ty : a) -> Binder a
130+ ||| @ kind The kind of arrow. Only relevant when dealing with
131+ ||| uniqueness, so you can usually pretend that this
132+ ||| field doesn't exist. For ordinary functions, use the
133+ ||| type of types here.
120− | Pi a a
134+ Pi : (ty, kind : a) -> Binder a
138+ ||| @ ty the type of the bound variable
139+ ||| @ val the bound value
121− | Let a a
140+ Let : (ty, val : a) -> Binder a
142+ ||| A hole that can occur during elaboration, and must be filled
144+ ||| @ ty the type of the value that will eventually be put into the hole
123− | Hole a
145+ Hole : (ty : a) -> Binder a
147+ ||| A hole that will later become a top-level metavariable
124− | GHole a
148+ GHole : (ty : a) -> Binder a
150+ ||| A hole with a solution in it. Computationally inert.
152+ ||| @ ty the type of the value in the hole
153+ ||| @ val the value in the hole
125− | Guess a a
154+ Guess : (ty, val : a) -> Binder a
156+ ||| A pattern variable. These bindings surround the terms that make
157+ ||| up the left and right sides of pattern-matching definition
160+ ||| @ ty the type of the pattern variable
126− | PVar a
161+ PVar : (ty : a) -> Binder a
163+ ||| The type of a pattern binding. This is to `PVar` as `Pi` is to
166+ ||| @ ty the type of the pattern variable
127− | PVTy a
167+ PVTy : (ty : a) -> Binder a
128%name Binder b, b'
169%name Binder b, b'
130instance Functor Binder where
171instance Functor Binder where
131 map f (Lam x) = Lam (f x)
172 map f (Lam x) = Lam (f x)
132 map f (Pi x k) = Pi (f x) (f k)
173 map f (Pi x k) = Pi (f x) (f k)
133 map f (Let x y) = Let (f x) (f y)
174 map f (Let x y) = Let (f x) (f y)
134− map f (NLet x y) = NLet (f x) (f y)
135 map f (Hole x) = Hole (f x)
175 map f (Hole x) = Hole (f x)
136 map f (GHole x) = GHole (f x)
176 map f (GHole x) = GHole (f x)
137 map f (Guess x y) = Guess (f x) (f y)
177 map f (Guess x y) = Guess (f x) (f y)
@@ -142,7 +182,6 @@ instance Foldable Binder where
142 foldr f z (Lam x) = f x z
182 foldr f z (Lam x) = f x z
143 foldr f z (Pi x k) = f x (f k z)
183 foldr f z (Pi x k) = f x (f k z)
144 foldr f z (Let x y) = f x (f y z)
184 foldr f z (Let x y) = f x (f y z)
145− foldr f z (NLet x y) = f x (f y z)
146 foldr f z (Hole x) = f x z
185 foldr f z (Hole x) = f x z
147 foldr f z (GHole x) = f x z
186 foldr f z (GHole x) = f x z
148 foldr f z (Guess x y) = f x (f y z)
187 foldr f z (Guess x y) = f x (f y z)
@@ -153,14 +192,13 @@ instance Traversable Binder where
153 traverse f (Lam x) = [| Lam (f x) |]
192 traverse f (Lam x) = [| Lam (f x) |]
154 traverse f (Pi x k) = [| Pi (f x) (f k) |]
193 traverse f (Pi x k) = [| Pi (f x) (f k) |]
155 traverse f (Let x y) = [| Let (f x) (f y) |]
194 traverse f (Let x y) = [| Let (f x) (f y) |]
156− traverse f (NLet x y) = [| NLet (f x) (f y) |]
157 traverse f (Hole x) = [| Hole (f x) |]
195 traverse f (Hole x) = [| Hole (f x) |]
158 traverse f (GHole x) = [| GHole (f x) |]
196 traverse f (GHole x) = [| GHole (f x) |]
159 traverse f (Guess x y) = [| Guess (f x) (f y) |]
197 traverse f (Guess x y) = [| Guess (f x) (f y) |]
160 traverse f (PVar x) = [| PVar (f x) |]
198 traverse f (PVar x) = [| PVar (f x) |]
161 traverse f (PVTy x) = [| PVTy (f x) |]
199 traverse f (PVTy x) = [| PVTy (f x) |]
163−||| Universes
201+||| The various universes involved in the uniqueness mechanism
164data Universe = NullType | UniqueType | AllTypes
202data Universe = NullType | UniqueType | AllTypes
166||| Reflection of the well typed core language
204||| Reflection of the well typed core language
@@ -199,8 +237,18 @@ data Raw =
199 RConstant Const
237 RConstant Const
200%name Raw tm, tm'
238%name Raw tm, tm'
202−data SourceLocation : Type where
240+||| A source location in an Idris file
241+record SourceLocation where
242+ ||| Either a source span or a source location. `start` and `end`
243+ ||| will be the same if it's a point location.
246+ ||| The file name of the source location
203− FileLoc : (filename : String) -> (start : (Int, Int)) -> (end : (Int, Int)) -> SourceLocation
247+ filename : String
248+ ||| The line and column of the beginning of the source span
250+ ||| The line and column of the end of the source span
205%name SourceLocation loc
253%name SourceLocation loc
@@ -218,7 +266,7 @@ data ErrorReportPart =
218 SubReport (List ErrorReportPart)
266 SubReport (List ErrorReportPart)
219%name ErrorReportPart part, p
267%name ErrorReportPart part, p
221−||| A representation of Idris's tactics that can be returned from custom
269+||| A representation of Idris's old tactics that can be returned from custom
222||| tactic implementations. Generate these using `applyTactic`.
270||| tactic implementations. Generate these using `applyTactic`.
223data Tactic =
271data Tactic =
224 ||| Try the first tactic and resort to the second one on failure
272 ||| Try the first tactic and resort to the second one on failure
@@ -277,6 +325,7 @@ data Tactic =
277 Fail (List ErrorReportPart) |
325 Fail (List ErrorReportPart) |
278 ||| Attempt to fill the hole with source code information
326 ||| Attempt to fill the hole with source code information
280%name Tactic tac, tac'
329%name Tactic tac, tac'
@@ -564,8 +613,6 @@ mutual
564 ~(assert_total (quote k)))
613 ~(assert_total (quote k)))
565 quote (Let x y) = `(Let {a=TT} ~(assert_total (quote x))
614 quote (Let x y) = `(Let {a=TT} ~(assert_total (quote x))
566 ~(assert_total (quote y)))
615 ~(assert_total (quote y)))
567− quote (NLet x y) = `(NLet {a=TT} ~(assert_total (quote x))
568− ~(assert_total (quote y)))
569 quote (Hole x) = `(Hole {a=TT} ~(assert_total (quote x)))
616 quote (Hole x) = `(Hole {a=TT} ~(assert_total (quote x)))
570 quote (GHole x) = `(GHole {a=TT} ~(assert_total (quote x)))
617 quote (GHole x) = `(GHole {a=TT} ~(assert_total (quote x)))
571 quote (Guess x y) = `(Guess {a=TT} ~(assert_total (quote x))
618 quote (Guess x y) = `(Guess {a=TT} ~(assert_total (quote x))
@@ -586,7 +633,6 @@ mutual
586 quoteRawBinderTT (Lam x) = `(Lam {a=Raw} ~(quoteRawTT x))
633 quoteRawBinderTT (Lam x) = `(Lam {a=Raw} ~(quoteRawTT x))
587 quoteRawBinderTT (Pi x k) = `(Pi {a=Raw} ~(quoteRawTT x) ~(quoteRawTT k))
634 quoteRawBinderTT (Pi x k) = `(Pi {a=Raw} ~(quoteRawTT x) ~(quoteRawTT k))
588 quoteRawBinderTT (Let x y) = `(Let {a=Raw} ~(quoteRawTT x) ~(quoteRawTT y))
635 quoteRawBinderTT (Let x y) = `(Let {a=Raw} ~(quoteRawTT x) ~(quoteRawTT y))
589− quoteRawBinderTT (NLet x y) = `(NLet {a=Raw} ~(quoteRawTT x) ~(quoteRawTT y))
590 quoteRawBinderTT (Hole x) = `(Hole {a=Raw} ~(quoteRawTT x))
636 quoteRawBinderTT (Hole x) = `(Hole {a=Raw} ~(quoteRawTT x))
591 quoteRawBinderTT (GHole x) = `(GHole {a=Raw} ~(quoteRawTT x))
637 quoteRawBinderTT (GHole x) = `(GHole {a=Raw} ~(quoteRawTT x))
592 quoteRawBinderTT (Guess x y) = `(Guess {a=Raw} ~(quoteRawTT x) ~(quoteRawTT y))
638 quoteRawBinderTT (Guess x y) = `(Guess {a=Raw} ~(quoteRawTT x) ~(quoteRawTT y))
@@ -614,7 +660,6 @@ mutual
614 quoteRawBinderRaw (Lam x) = `(Lam {a=Raw} ~(quoteRawRaw x))
660 quoteRawBinderRaw (Lam x) = `(Lam {a=Raw} ~(quoteRawRaw x))
615 quoteRawBinderRaw (Pi x k) = `(Pi {a=Raw} ~(quoteRawRaw x) ~(quoteRawRaw k))
661 quoteRawBinderRaw (Pi x k) = `(Pi {a=Raw} ~(quoteRawRaw x) ~(quoteRawRaw k))
616 quoteRawBinderRaw (Let x y) = `(Let {a=Raw} ~(quoteRawRaw x) ~(quoteRawRaw y))
662 quoteRawBinderRaw (Let x y) = `(Let {a=Raw} ~(quoteRawRaw x) ~(quoteRawRaw y))
617− quoteRawBinderRaw (NLet x y) = `(NLet {a=Raw} ~(quoteRawRaw x) ~(quoteRawRaw y))
618 quoteRawBinderRaw (Hole x) = `(Hole {a=Raw} ~(quoteRawRaw x))
663 quoteRawBinderRaw (Hole x) = `(Hole {a=Raw} ~(quoteRawRaw x))
619 quoteRawBinderRaw (GHole x) = `(GHole {a=Raw} ~(quoteRawRaw x))
664 quoteRawBinderRaw (GHole x) = `(GHole {a=Raw} ~(quoteRawRaw x))
620 quoteRawBinderRaw (Guess x y) = `(Guess {a=Raw} ~(quoteRawRaw x) ~(quoteRawRaw y))
665 quoteRawBinderRaw (Guess x y) = `(Guess {a=Raw} ~(quoteRawRaw x) ~(quoteRawRaw y))