on d3fa290 help sign in
elk/src/Reporting/Annotation.hs
53 lines 807 B history raw
1{-# OPTIONS_GHC -Wall #-}
2module Reporting.Annotation
3 ( Located(..)
4 , at, merge
5 , map, drop
6 , traverse
7 )
8 where
11import Prelude hiding (drop, map, traverse)
12import qualified Reporting.Region as R
16-- ANNOTATION
19data Located a =
20 At R.Region a
24-- CREATE
27at :: R.Position -> R.Position -> a -> Located a
28at start end value =
29 At (R.Region start end) value
32merge :: Located a -> Located b -> value -> Located value
33merge (At region1 _) (At region2 _) value =
34 At (R.merge region1 region2) value
38-- MANIPULATE
41map :: (a -> b) -> Located a -> Located b
42map f (At info value) =
43 At info (f value)
46drop :: Located a -> a
47drop (At _ value) =
48 value
51traverse :: (Functor f) => (a -> f b) -> Located a -> f (Located b)
52traverse func (At region value) =
53 At region <$> func value