{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE Safe #-}
{-# OPTIONS_GHC -Wno-missing-methods #-} -- the intentionally-empty `Data Annote` (SYB leaf).
module ReWire.Annotation
      ( Annote (Annote, NoAnnote, MsgAnnote)
      , Provenance (..)
      , Span (..)
      , Annotation (..)
      , Annotated (..)
      , Blind (..)
      , srcAnnote
      , primSpan, annProv, annContext
      , noAnn, unAnn
      ) where

import ReWire.SYB (transform)
import ReWire.Pretty (TextShow (showb), fromString)

import Control.DeepSeq (NFData (..))
import Data.Text (Text)
import Data.Data (Typeable, Data (..))
import Data.Hashable (Hashable (..))

import GHC.Generics (Generic (..))

-- | A source region: a file together with 1-based (line, column) start and end
--   positions. Carries the full extent of a node (unlike a single point), which
--   is what lets a diagnostic underline the offending text.
data Span = Span
      { Span -> FilePath
spanFile  :: !FilePath
      , Span -> (Int, Int)
spanStart :: !(Int, Int)
      , Span -> (Int, Int)
spanEnd   :: !(Int, Int)
      } deriving (Span -> Span -> Bool
(Span -> Span -> Bool) -> (Span -> Span -> Bool) -> Eq Span
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Span -> Span -> Bool
== :: Span -> Span -> Bool
$c/= :: Span -> Span -> Bool
/= :: Span -> Span -> Bool
Eq, Eq Span
Eq Span =>
(Span -> Span -> Ordering)
-> (Span -> Span -> Bool)
-> (Span -> Span -> Bool)
-> (Span -> Span -> Bool)
-> (Span -> Span -> Bool)
-> (Span -> Span -> Span)
-> (Span -> Span -> Span)
-> Ord Span
Span -> Span -> Bool
Span -> Span -> Ordering
Span -> Span -> Span
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Span -> Span -> Ordering
compare :: Span -> Span -> Ordering
$c< :: Span -> Span -> Bool
< :: Span -> Span -> Bool
$c<= :: Span -> Span -> Bool
<= :: Span -> Span -> Bool
$c> :: Span -> Span -> Bool
> :: Span -> Span -> Bool
$c>= :: Span -> Span -> Bool
>= :: Span -> Span -> Bool
$cmax :: Span -> Span -> Span
max :: Span -> Span -> Span
$cmin :: Span -> Span -> Span
min :: Span -> Span -> Span
Ord, Int -> Span -> ShowS
[Span] -> ShowS
Span -> FilePath
(Int -> Span -> ShowS)
-> (Span -> FilePath) -> ([Span] -> ShowS) -> Show Span
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Span -> ShowS
showsPrec :: Int -> Span -> ShowS
$cshow :: Span -> FilePath
show :: Span -> FilePath
$cshowList :: [Span] -> ShowS
showList :: [Span] -> ShowS
Show, (forall x. Span -> Rep Span x)
-> (forall x. Rep Span x -> Span) -> Generic Span
forall x. Rep Span x -> Span
forall x. Span -> Rep Span x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Span -> Rep Span x
from :: forall x. Span -> Rep Span x
$cto :: forall x. Rep Span x -> Span
to :: forall x. Rep Span x -> Span
Generic)

-- | Where an annotated node came from. Nodes parsed from user source are
--   'FromSource'; nodes a pass invents are 'Synthesized', recording the pass
--   name and the source spans of the inputs it was built from (so errors on
--   generated code can still point back at the user's source).
data Provenance
      = FromSource  !Span
      | Synthesized !Text ![Span]
      | NoProvenance
      deriving (Provenance -> Provenance -> Bool
(Provenance -> Provenance -> Bool)
-> (Provenance -> Provenance -> Bool) -> Eq Provenance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Provenance -> Provenance -> Bool
== :: Provenance -> Provenance -> Bool
$c/= :: Provenance -> Provenance -> Bool
/= :: Provenance -> Provenance -> Bool
Eq, Eq Provenance
Eq Provenance =>
(Provenance -> Provenance -> Ordering)
-> (Provenance -> Provenance -> Bool)
-> (Provenance -> Provenance -> Bool)
-> (Provenance -> Provenance -> Bool)
-> (Provenance -> Provenance -> Bool)
-> (Provenance -> Provenance -> Provenance)
-> (Provenance -> Provenance -> Provenance)
-> Ord Provenance
Provenance -> Provenance -> Bool
Provenance -> Provenance -> Ordering
Provenance -> Provenance -> Provenance
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Provenance -> Provenance -> Ordering
compare :: Provenance -> Provenance -> Ordering
$c< :: Provenance -> Provenance -> Bool
< :: Provenance -> Provenance -> Bool
$c<= :: Provenance -> Provenance -> Bool
<= :: Provenance -> Provenance -> Bool
$c> :: Provenance -> Provenance -> Bool
> :: Provenance -> Provenance -> Bool
$c>= :: Provenance -> Provenance -> Bool
>= :: Provenance -> Provenance -> Bool
$cmax :: Provenance -> Provenance -> Provenance
max :: Provenance -> Provenance -> Provenance
$cmin :: Provenance -> Provenance -> Provenance
min :: Provenance -> Provenance -> Provenance
Ord, Int -> Provenance -> ShowS
[Provenance] -> ShowS
Provenance -> FilePath
(Int -> Provenance -> ShowS)
-> (Provenance -> FilePath)
-> ([Provenance] -> ShowS)
-> Show Provenance
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Provenance -> ShowS
showsPrec :: Int -> Provenance -> ShowS
$cshow :: Provenance -> FilePath
show :: Provenance -> FilePath
$cshowList :: [Provenance] -> ShowS
showList :: [Provenance] -> ShowS
Show, (forall x. Provenance -> Rep Provenance x)
-> (forall x. Rep Provenance x -> Provenance) -> Generic Provenance
forall x. Rep Provenance x -> Provenance
forall x. Provenance -> Rep Provenance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Provenance -> Rep Provenance x
from :: forall x. Provenance -> Rep Provenance x
$cto :: forall x. Rep Provenance x -> Provenance
to :: forall x. Rep Provenance x -> Provenance
Generic)

-- | The annotation carried by every IR node: its provenance plus any
--   human-readable context breadcrumbs accumulated as it travels through the
--   passes.
data Annote = Annote { Annote -> Provenance
annProv :: !Provenance, Annote -> [Text]
annContext :: ![Text] }
      deriving (Int -> Annote -> ShowS
[Annote] -> ShowS
Annote -> FilePath
(Int -> Annote -> ShowS)
-> (Annote -> FilePath) -> ([Annote] -> ShowS) -> Show Annote
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Annote -> ShowS
showsPrec :: Int -> Annote -> ShowS
$cshow :: Annote -> FilePath
show :: Annote -> FilePath
$cshowList :: [Annote] -> ShowS
showList :: [Annote] -> ShowS
Show, Typeable)

-- | The empty annotation: a node with no known origin.
pattern NoAnnote :: Annote
pattern $mNoAnnote :: forall {r}. Annote -> ((# #) -> r) -> ((# #) -> r) -> r
$bNoAnnote :: Annote
NoAnnote = Annote NoProvenance []

-- | A locationless annotation carrying a single explanatory message. Matches
--   the first context message of any annotation.
pattern MsgAnnote :: Text -> Annote
pattern $mMsgAnnote :: forall {r}. Annote -> (Text -> r) -> ((# #) -> r) -> r
$bMsgAnnote :: Text -> Annote
MsgAnnote m <- Annote _ (m : _)
      where MsgAnnote Text
m = Provenance -> [Text] -> Annote
Annote Provenance
NoProvenance [Text
m]

class Annotation a where
      toAnnote :: a -> Annote

instance Annotation Annote where
      toAnnote :: Annote -> Annote
toAnnote = Annote -> Annote
forall a. a -> a
id

class Annotated a where
      ann :: a -> Annote

-- | Strip every annotation from a value, replacing each with 'noAnn'. Used to
--   make dumps readable and to compare terms structurally.
unAnn :: Data d => d -> d
unAnn :: forall d. Data d => d -> d
unAnn = (Annote -> Annote) -> d -> d
forall a b. (Data a, Data b) => (a -> a) -> b -> b
transform ((Annote -> Annote) -> d -> d) -> (Annote -> Annote) -> d -> d
forall a b. (a -> b) -> a -> b
$ \ (Annote
_ :: Annote) -> Annote
noAnn

-- | Build an annotation for an explicit source region: a file with 1-based
--   (line, column) start and end positions.
srcAnnote :: FilePath -> (Int, Int) -> (Int, Int) -> Annote
srcAnnote :: FilePath -> (Int, Int) -> (Int, Int) -> Annote
srcAnnote FilePath
f (Int, Int)
start (Int, Int)
end = Provenance -> [Text] -> Annote
Annote (Span -> Provenance
FromSource (Span -> Provenance) -> Span -> Provenance
forall a b. (a -> b) -> a -> b
$ FilePath -> (Int, Int) -> (Int, Int) -> Span
Span FilePath
f (Int, Int)
start (Int, Int)
end) []

-- | The source span underlying an annotation, if it has one. Synthesized nodes
--   yield the span of their first input.
primSpan :: Annote -> Maybe Span
primSpan :: Annote -> Maybe Span
primSpan = \ case
      Annote (FromSource Span
s)          [Text]
_ -> Span -> Maybe Span
forall a. a -> Maybe a
Just Span
s
      Annote (Synthesized Text
_ (Span
s : [Span]
_)) [Text]
_ -> Span -> Maybe Span
forall a. a -> Maybe a
Just Span
s
      Annote
_                                -> Maybe Span
forall a. Maybe a
Nothing

-- | Opaque to SYB: 'gfoldl' uses its default (no children), so 'unAnn' and the
--   generic traversals treat an annotation as an indivisible leaf rather than
--   recursing into its provenance.
instance Data Annote

instance TextShow Annote where
      showb :: Annote -> Builder
showb = FilePath -> Builder
fromString (FilePath -> Builder) -> (Annote -> FilePath) -> Annote -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Annote -> FilePath
forall a. Show a => a -> FilePath
show

-- | Annotations are metadata about a node, not part of its meaning. Equality,
--   ordering, and hashing are therefore intentionally blind to them: two terms
--   that differ only in source location must still compare equal, or type
--   comparison and term deduplication (which run over annotated IR) would wrongly
--   distinguish them.
instance Ord Annote where
      Annote
_ <= :: Annote -> Annote -> Bool
<= Annote
_ = Bool
True
instance Eq Annote where
      Annote
_ == :: Annote -> Annote -> Bool
== Annote
_ = Bool
True

instance Hashable Annote where
      hashWithSalt :: Int -> Annote -> Int
hashWithSalt Int
s Annote
_ = Int
s

-- | Display metadata invisible to equality, ordering, and hashing: wrapping
--   a field in 'Blind' keeps doc lines and tag tables from perturbing dedupe
--   keys, memo keys, or the optimizer's fixpoint test (the same convention as
--   'Annote' itself, for metadata that isn't an annotation).
newtype Blind a = Blind { forall a. Blind a -> a
unBlind :: a }
      deriving (Int -> Blind a -> ShowS
[Blind a] -> ShowS
Blind a -> FilePath
(Int -> Blind a -> ShowS)
-> (Blind a -> FilePath) -> ([Blind a] -> ShowS) -> Show (Blind a)
forall a. Show a => Int -> Blind a -> ShowS
forall a. Show a => [Blind a] -> ShowS
forall a. Show a => Blind a -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Blind a -> ShowS
showsPrec :: Int -> Blind a -> ShowS
$cshow :: forall a. Show a => Blind a -> FilePath
show :: Blind a -> FilePath
$cshowList :: forall a. Show a => [Blind a] -> ShowS
showList :: [Blind a] -> ShowS
Show, (forall x. Blind a -> Rep (Blind a) x)
-> (forall x. Rep (Blind a) x -> Blind a) -> Generic (Blind a)
forall x. Rep (Blind a) x -> Blind a
forall x. Blind a -> Rep (Blind a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Blind a) x -> Blind a
forall a x. Blind a -> Rep (Blind a) x
$cfrom :: forall a x. Blind a -> Rep (Blind a) x
from :: forall x. Blind a -> Rep (Blind a) x
$cto :: forall a x. Rep (Blind a) x -> Blind a
to :: forall x. Rep (Blind a) x -> Blind a
Generic, Typeable, Typeable (Blind a)
Typeable (Blind a) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Blind a -> c (Blind a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Blind a))
-> (Blind a -> Constr)
-> (Blind a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Blind a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Blind a)))
-> ((forall d. Data d => d -> d) -> Blind a -> Blind a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Blind a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Blind a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Blind a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Blind a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Blind a -> m (Blind a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Blind a -> m (Blind a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Blind a -> m (Blind a))
-> Data (Blind a)
Blind a -> Constr
Blind a -> DataType
(forall d. Data d => d -> d) -> Blind a -> Blind a
forall a. Data a => Typeable (Blind a)
forall a. Data a => Blind a -> Constr
forall a. Data a => Blind a -> DataType
forall a.
Data a =>
(forall d. Data d => d -> d) -> Blind a -> Blind a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Blind a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> Blind a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Blind a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Blind a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Blind a -> m (Blind a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Blind a -> m (Blind a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Blind a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Blind a -> c (Blind a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Blind a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Blind a))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall d. Data d => d -> d) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Blind a -> u
forall u. (forall d. Data d => d -> u) -> Blind a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Blind a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Blind a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Blind a -> m (Blind a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Blind a -> m (Blind a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Blind a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Blind a -> c (Blind a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Blind a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Blind a))
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Blind a -> c (Blind a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Blind a -> c (Blind a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Blind a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Blind a)
$ctoConstr :: forall a. Data a => Blind a -> Constr
toConstr :: Blind a -> Constr
$cdataTypeOf :: forall a. Data a => Blind a -> DataType
dataTypeOf :: Blind a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Blind a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Blind a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Blind a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Blind a))
$cgmapT :: forall a.
Data a =>
(forall d. Data d => d -> d) -> Blind a -> Blind a
gmapT :: (forall d. Data d => d -> d) -> Blind a -> Blind a
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Blind a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Blind a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Blind a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Blind a -> r
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> Blind a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Blind a -> [u]
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Blind a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Blind a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Blind a -> m (Blind a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Blind a -> m (Blind a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Blind a -> m (Blind a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Blind a -> m (Blind a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Blind a -> m (Blind a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Blind a -> m (Blind a)
Data)

instance Eq (Blind a) where
      Blind a
_ == :: Blind a -> Blind a -> Bool
== Blind a
_ = Bool
True

instance Ord (Blind a) where
      compare :: Blind a -> Blind a -> Ordering
compare Blind a
_ Blind a
_ = Ordering
EQ

instance Hashable (Blind a) where
      hashWithSalt :: Int -> Blind a -> Int
hashWithSalt Int
s Blind a
_ = Int
s

instance NFData a => NFData (Blind a) where
      rnf :: Blind a -> ()
rnf (Blind a
a) = a -> ()
forall a. NFData a => a -> ()
rnf a
a

instance Show a => TextShow (Blind a) where
      showb :: Blind a -> Builder
showb = FilePath -> Builder
fromString (FilePath -> Builder)
-> (Blind a -> FilePath) -> Blind a -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Blind a -> FilePath
forall a. Show a => a -> FilePath
show

instance NFData Span where
      rnf :: Span -> ()
rnf (Span FilePath
f (Int, Int)
a (Int, Int)
b) = FilePath -> ()
forall a. NFData a => a -> ()
rnf FilePath
f () -> () -> ()
forall a b. a -> b -> b
`seq` (Int, Int) -> ()
forall a. NFData a => a -> ()
rnf (Int, Int)
a () -> () -> ()
forall a b. a -> b -> b
`seq` (Int, Int) -> ()
forall a. NFData a => a -> ()
rnf (Int, Int)
b
instance NFData Provenance where
      rnf :: Provenance -> ()
rnf (FromSource Span
s)    = Span -> ()
forall a. NFData a => a -> ()
rnf Span
s
      rnf (Synthesized Text
t [Span]
s) = Text -> ()
forall a. NFData a => a -> ()
rnf Text
t () -> () -> ()
forall a b. a -> b -> b
`seq` [Span] -> ()
forall a. NFData a => a -> ()
rnf [Span]
s
      rnf Provenance
NoProvenance      = ()
instance NFData Annote where
      rnf :: Annote -> ()
rnf (Annote Provenance
p [Text]
c) = Provenance -> ()
forall a. NFData a => a -> ()
rnf Provenance
p () -> () -> ()
forall a b. a -> b -> b
`seq` [Text] -> ()
forall a. NFData a => a -> ()
rnf [Text]
c

noAnn :: Annote
noAnn :: Annote
noAnn = Annote
NoAnnote