on 49ada59 help sign in
elk/src/Reporting/Annotation.hs
55 lines 858 B history raw
1module Reporting.Annotation where
3import Prelude hiding (map)
4import Data.Text (Text)
5import qualified Reporting.Region as R
9-- ANNOTATION
12data Annotated annotation a
13 = A annotation a
16type Located a =
17 Annotated R.Region a
20type Commented a =
21 Annotated (R.Region, Maybe Text) a
25-- CREATE
28at :: R.Position -> R.Position -> a -> Located a
29at start end value =
30 A (R.Region start end) value
33merge :: Located a -> Located b -> value -> Located value
34merge (A region1 _) (A region2 _) value =
35 A (R.merge region1 region2) value
38sameAs :: Annotated info a -> b -> Annotated info b
39sameAs (A annotation _) value =
40 A annotation value
44-- MANIPULATE
47map :: (a -> b) -> Annotated info a -> Annotated info b
48map f (A annotation value) =
49 A annotation (f value)
52drop :: Annotated info a -> a
53drop (A _ value) =
54 value