1{-# LANGUAGE DeriveDataTypeable #-}
2module SourceSyntax.Location where
6import SourceSyntax.PrettyPrint
7import qualified Text.Parsec.Pos as Parsec
9data SrcPos = Pos { line :: Int, column :: Int }
10 deriving (Eq, Ord, Data, Typeable)
12data SrcSpan = Span SrcPos SrcPos String | NoSpan String
13 deriving (Eq, Ord, Data, Typeable)
15data Located e = L SrcSpan e
16 deriving (Eq, Ord, Data, Typeable)
18none e = L (NoSpan (render $ pretty e)) e
19noneNoDocs = L (NoSpan "")
21at start end e = L (Span (Pos (Parsec.sourceLine start) (Parsec.sourceColumn start))
22 (Pos (Parsec.sourceLine end ) (Parsec.sourceColumn end ))
23 (render $ pretty e)) e
25merge (L s1 _) (L s2 _) e = L (span (render $ pretty e)) e
26 where span = case (s1,s2) of
27 (Span start _ _, Span _ end _) -> Span start end
28 (Span start end _, _) -> Span start end
29 (_, Span start end _) -> Span start end
32mergeOldDocs (L s1 _) (L s2 _) e = L span e
33 where span = case (s1,s2) of
34 (Span start _ d1, Span _ end d2) -> Span start end (d1 ++ "\n\n" ++ d2)
42instance Show SrcPos where
43 show (Pos r c) = show r ++ "," ++ show c
45instance Show SrcSpan where
50 case line start == line end of
51 False -> "between lines " ++ show (line start) ++ " and " ++ show (line end)
52 True -> "on line " ++ show (line end) ++ ", column " ++
53 show (column start) ++ " to " ++ show (column end)
55instance Show e => Show (Located e) where
56 show (L s e) = "L (" ++ show s ++ ") (" ++ show e ++ ")"
58instance Pretty a => Pretty (Located a) where
59 pretty (L _ 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