1module AST.Annotation where
3import qualified Text.Parsec.Pos as Parsec
4import qualified Text.PrettyPrint as P
7data Annotated annotation expr = A annotation expr
11 = Span Position Position P.Doc
15data Position = Position
20type Located expr = Annotated Region expr
22none e = A (None (pretty e)) e
23noneNoDocs e = A (None P.empty) e
25at :: (Pretty expr) => Parsec.SourcePos -> Parsec.SourcePos -> expr
26 -> Annotated Region expr
28 A (Span (position start) (position end) (pretty e)) e
30 position loc = Position (Parsec.sourceLine loc) (Parsec.sourceColumn loc)
32merge (A s1 _) (A s2 _) e =
35 span = case (s1,s2) of
36 (Span start _ _, Span _ end _) -> Span start end
37 (Span start end _, _) -> Span start end
38 (_, Span start end _) -> Span start end
41mergeOldDocs (A s1 _) (A s2 _) e =
44 span = case (s1,s2) of
45 (Span start _ d1, Span _ end d2) ->
46 Span start end (P.vcat [d1, P.text "\n", d2])
50 (_, _) -> None P.empty
52sameAs :: Annotated a expr -> expr' -> Annotated a expr'
53sameAs (A annotation _) expr = A annotation expr
60instance Pretty Region where
66 case line start == line end of
67 False -> "between lines " ++ show (line start) ++ " and " ++ show (line end)
68 True -> "on line " ++ show (line end) ++ ", column " ++
69 show (column start) ++ " to " ++ show (column end)
71instance Pretty e => Pretty (Annotated a e) where
72 pretty (A _ e) = pretty e
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list