never executed always true always false
    1 {-# LANGUAGE TypeSynonymInstances #-}
    2 {-# LANGUAGE FlexibleInstances #-}
    3 
    4 module Reporting.Annotation where
    5 
    6 import Prelude ()
    7 import Relude
    8 
    9 import Data.Coapplicative
   10 import Text.Show (showParen, showString, showsPrec)
   11 
   12 import qualified Reporting.Region as R
   13 import qualified Data.String as String
   14 
   15 
   16 -- ANNOTATION
   17 
   18 data Located a =
   19     A R.Region a
   20     deriving (Eq, Functor)
   21 
   22 
   23 instance (Show a) => Show (Located a) where
   24     showsPrec p (A ann a) = showParen (p > 10) $
   25         showString $ String.unwords
   26             [ show ann
   27             , showsPrec 99 a ""
   28             ]
   29 
   30 instance Coapplicative Located where
   31     extract (A _ x) = x
   32     {-# INLINE extract #-}
   33 
   34 instance Foldable Located where
   35     foldMap f (A _ a) = f a
   36 
   37 instance Traversable Located where
   38     traverse f (A region a) = fmap (A region) $ f a
   39 
   40 
   41 -- CREATE
   42 
   43 at :: R.Position -> R.Position -> a -> Located a
   44 at start end value =
   45     A (R.Region start end) value
   46 
   47 
   48 merge :: Located a -> Located b -> value -> Located value
   49 merge (A region1 _) (A region2 _) value =
   50     A (R.merge region1 region2) value
   51 
   52 
   53 sameAs :: Located a -> b -> Located b
   54 sameAs (A annotation _) value =
   55     A annotation value