on fb08d70 help sign in
elk/src/Reporting/Annotation.hs
52 lines 966 B 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
19-- CREATE
21at :: R.Position -> R.Position -> a -> Located a
22at start end value =
23 A (R.Region start end) value
26merge :: Located a -> Located b -> value -> Located value
27merge (A region1 _) (A region2 _) value =
28 A (R.merge region1 region2) value
31sameAs :: Annotated info a -> b -> Annotated info b
32sameAs (A annotation _) value =
33 A annotation value
36-- MANIPULATE
38map :: (a -> b) -> Annotated info a -> Annotated info b
39map f (A annotation value) =
40 A annotation (f value)
43drop :: Annotated info a -> a
44drop (A _ value) =
45 value
48-- PRETTY PRINT
50instance (P.Pretty a) => P.Pretty (Annotated info a) where
51 pretty parens (A _ value) =
52 P.pretty parens value