on c5b225d help sign in
elk/src/Reporting/Annotation.hs
54 lines 836 B history raw
1module Reporting.Annotation where
3import Prelude hiding (map)
4import qualified Reporting.Region as R
8-- ANNOTATION
11data Annotated annotation a
12 = A annotation a
15type Located a =
16 Annotated R.Region a
19type Commented a =
20 Annotated (R.Region, Maybe String) a
24-- CREATE
27at :: R.Position -> R.Position -> a -> Located a
28at start end value =
29 A (R.Region start end) value
32merge :: Located a -> Located b -> value -> Located value
33merge (A region1 _) (A region2 _) value =
34 A (R.merge region1 region2) value
37sameAs :: Annotated info a -> b -> Annotated info b
38sameAs (A annotation _) value =
39 A annotation value
43-- MANIPULATE
46map :: (a -> b) -> Annotated info a -> Annotated info b
47map f (A annotation value) =
48 A annotation (f value)
51drop :: Annotated info a -> a
52drop (A _ value) =
53 value