on fe1e5d2 help sign in
elk/src/Reporting/Annotation.hs
48 lines 830 B history raw
1module Reporting.Annotation where
3import Prelude hiding (map)
4import qualified Reporting.Region as R
7-- ANNOTATION
9data Annotated annotation a
10 = A annotation a
13type Located a =
14 Annotated R.Region a
17type Commented a =
18 Annotated (R.Region, Maybe String) a
21-- CREATE
23at :: R.Position -> R.Position -> a -> Located a
24at start end value =
25 A (R.Region start end) value
28merge :: Located a -> Located b -> value -> Located value
29merge (A region1 _) (A region2 _) value =
30 A (R.merge region1 region2) value
33sameAs :: Annotated info a -> b -> Annotated info b
34sameAs (A annotation _) value =
35 A annotation value
38-- MANIPULATE
40map :: (a -> b) -> Annotated info a -> Annotated info b
41map f (A annotation value) =
42 A annotation (f value)
45drop :: Annotated info a -> a
46drop (A _ value) =
47 value