on 2d29699 help sign in
elk/src/Reporting/Annotation.hs
56 lines 1.0 kB history raw
1module Reporting.Annotation where
3import Prelude hiding (map)
4import qualified Reporting.PrettyPrint as P
5import qualified Reporting.Region as R
8-- ANNOTATION
10data Annotated annotation a
11 = A annotation a
12 deriving (Show)
15type Located a =
16 Annotated R.Region a
19type Commented a =
20 Annotated (R.Region, Maybe String) a
23-- CREATE
25at :: R.Position -> R.Position -> a -> Located a
26at start end value =
27 A (R.Region start end) value
30merge :: Located a -> Located b -> value -> Located value
31merge (A region1 _) (A region2 _) value =
32 A (R.merge region1 region2) value
35sameAs :: Annotated info a -> b -> Annotated info b
36sameAs (A annotation _) value =
37 A annotation value
40-- MANIPULATE
42map :: (a -> b) -> Annotated info a -> Annotated info b
43map f (A annotation value) =
44 A annotation (f value)
47drop :: Annotated info a -> a
48drop (A _ value) =
49 value
52-- PRETTY PRINT
54instance (P.Pretty a) => P.Pretty (Annotated info a) where
55 pretty dealiaser parens (A _ value) =
56 P.pretty dealiaser parens value