@@ -11,6 +11,22 @@ import Prelude.Traversable
1111
1212%access public
1313
14+||| A source location in an Idris file
15+record SourceLocation where
16+ ||| Either a source span or a source location. `start` and `end`
17+ ||| will be the same if it's a point location.
18+ constructor FileLoc
19+
20+ ||| The file name of the source location
21+ filename : String
22+ ||| The line and column of the beginning of the source span
23+ start : (Int, Int)
24+ ||| The line and column of the end of the source span
25+ end : (Int, Int)
26+
27+%name SourceLocation loc
28+
29+
1430mutual
1531 data TTName =
1632 ||| A user-provided name
@@ -34,7 +50,7 @@ mutual
3450 | InstanceN TTName (List String)
3551 | ParentN TTName String
3652 | MethodN TTName
37− | CaseN TTName
53+ | CaseN SourceLocation TTName
3854 | ElimN TTName
3955 | InstanceCtorN TTName
4056 | MetaN TTName TTName
@@ -237,21 +253,6 @@ data Raw =
237253 RConstant Const
238254%name Raw tm, tm'
239255
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.
244− constructor FileLoc
245−
246− ||| The file name of the source location
247− filename : String
248− ||| The line and column of the beginning of the source span
249− start : (Int, Int)
250− ||| The line and column of the end of the source span
251− end : (Int, Int)
252−
253−%name SourceLocation loc
254−
255256||| Error reports are a list of report parts
256257data ErrorReportPart =
257258 ||| A human-readable string
@@ -455,6 +456,21 @@ instance Quotable a Raw => Quotable (List a) Raw where
455456 quote [] = `(List.Nil {elem=~(quotedTy {a})})
456457 quote (x :: xs) = `(List.(::) {elem=~(quotedTy {a})} ~(quote x) ~(quote xs))
457458
459+instance Quotable SourceLocation TT where
460+ quotedTy = `(SourceLocation)
461+ quote (FileLoc fn (sl, sc) (el, ec)) =
462+ `(FileLoc ~(quote fn)
463+ (~(quote sl), ~(quote sc))
464+ (~(quote el), ~(quote ec)))
465+
466+instance Quotable SourceLocation Raw where
467+ quotedTy = `(SourceLocation)
468+ quote (FileLoc fn (sl, sc) (el, ec)) =
469+ `(FileLoc ~(quote {t=Raw} fn)
470+ (~(quote {t=Raw} sl), ~(quote {t=Raw} sc))
471+ (~(quote {t=Raw} el), ~(quote {t=Raw} ec)))
472+
473+
458474mutual
459475 instance Quotable TTName TT where
460476 quotedTy = `(TTName)
@@ -471,7 +487,7 @@ mutual
471487 quote (InstanceN i ss) = `(InstanceN ~(quote i) ~(quote ss))
472488 quote (ParentN n s) = `(ParentN ~(quote n) ~(quote s))
473489 quote (MethodN n) = `(MethodN ~(quote n))
474− quote (CaseN n) = `(CaseN ~(quote n))
490+ quote (CaseN fc n) = `(CaseN ~(quote fc) ~(quote n))
475491 quote (ElimN n) = `(ElimN ~(quote n))
476492 quote (InstanceCtorN n) = `(InstanceCtorN ~(quote n))
477493 quote (MetaN parent meta) = `(MetaN ~(quote parent) ~(quote meta))
@@ -492,7 +508,7 @@ mutual
492508 quote (InstanceN i ss) = `(InstanceN ~(quote i) ~(quote ss))
493509 quote (ParentN n s) = `(ParentN ~(quote n) ~(quote s))
494510 quote (MethodN n) = `(MethodN ~(quote n))
495− quote (CaseN n) = `(CaseN ~(quote n))
511+ quote (CaseN fc n) = `(CaseN ~(quote fc) ~(quote n))
496512 quote (ElimN n) = `(ElimN ~(quote n))
497513 quote (InstanceCtorN n) = `(InstanceCtorN ~(quote n))
498514 quote (MetaN parent meta) = `(MetaN ~(quote parent) ~(quote meta))
@@ -711,18 +727,3 @@ instance Quotable Tactic TT where
711727 quote Skip = `(Skip)
712728 quote (Fail xs) = `(Fail ~(quote xs))
713729 quote SourceFC = `(SourceFC)
714−
715−
716−instance Quotable SourceLocation TT where
717− quotedTy = `(SourceLocation)
718− quote (FileLoc fn (sl, sc) (el, ec)) =
719− `(FileLoc ~(quote fn)
720− (~(quote sl), ~(quote sc))
721− (~(quote el), ~(quote ec)))
722−
723−instance Quotable SourceLocation Raw where
724− quotedTy = `(SourceLocation)
725− quote (FileLoc fn (sl, sc) (el, ec)) =
726− `(FileLoc ~(quote {t=Raw} fn)
727− (~(quote {t=Raw} sl), ~(quote {t=Raw} sc))
728− (~(quote {t=Raw} el), ~(quote {t=Raw} ec)))