2module AST.Annotation where
4import qualified Text.Parsec.Pos as Parsec
5import qualified Text.PrettyPrint as P
8data Annotated annotation expr = A annotation expr
12 = Span Position Position P.Doc
16data Position = Position
21type Located expr = Annotated Region expr
23none e = A (None (pretty e)) e
24noneNoDocs e = A (None P.empty) e
26at :: (Pretty expr) => Parsec.SourcePos -> Parsec.SourcePos -> expr
27 -> Annotated Region expr
29 A (Span (position start) (position end) (pretty e)) e
31 position loc = Position (Parsec.sourceLine loc) (Parsec.sourceColumn loc)
33merge (A s1 _) (A s2 _) e =
36 span = case (s1,s2) of
37 (Span start _ _, Span _ end _) -> Span start end
38 (Span start end _, _) -> Span start end
39 (_, Span start end _) -> Span start end
42mergeOldDocs (A s1 _) (A s2 _) e =
45 span = case (s1,s2) of
46 (Span start _ d1, Span _ end d2) ->
47 Span start end (P.vcat [d1, P.text "\n", d2])
51 (_, _) -> None P.empty
53sameAs :: Annotated a expr -> expr' -> Annotated a expr'
54sameAs (A annotation _) expr = A annotation expr
61instance Pretty Region where
67 case line start == line end of
68 False -> "between lines " ++ show (line start) ++ " and " ++ show (line end)
69 True -> "on line " ++ show (line end) ++ ", column " ++
70 show (column start) ++ " to " ++ show (column end)
72instance Pretty e => Pretty (Annotated a e) where
73 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