rewire-base-2.8: A Haskell-to-Verilog/VHDL compiler, shared base utilities
Safe HaskellSafe
LanguageHaskell2010

ReWire.Annotation

Synopsis

Documentation

data Annote Source #

The annotation carried by every IR node: its provenance plus any human-readable context breadcrumbs accumulated as it travels through the passes.

Constructors

Annote !Provenance ![Text] 

Bundled Patterns

pattern NoAnnote :: Annote

The empty annotation: a node with no known origin.

pattern MsgAnnote :: Text -> Annote

A locationless annotation carrying a single explanatory message. Matches the first context message of any annotation.

Instances

Instances details
NFData Annote Source # 
Instance details

Defined in ReWire.Annotation

Methods

rnf :: Annote -> () #

Data Annote Source #

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 details

Defined in ReWire.Annotation

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Annote -> c Annote #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Annote #

toConstr :: Annote -> Constr #

dataTypeOf :: Annote -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Annote) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Annote) #

gmapT :: (forall b. Data b => b -> b) -> Annote -> Annote #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Annote -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Annote -> r #

gmapQ :: (forall d. Data d => d -> u) -> Annote -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Annote -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Annote -> m Annote #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Annote -> m Annote #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Annote -> m Annote #

Show Annote Source # 
Instance details

Defined in ReWire.Annotation

Eq Annote Source # 
Instance details

Defined in ReWire.Annotation

Methods

(==) :: Annote -> Annote -> Bool #

(/=) :: Annote -> Annote -> Bool #

Ord Annote Source #

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 details

Defined in ReWire.Annotation

Hashable Annote Source # 
Instance details

Defined in ReWire.Annotation

Methods

hashWithSalt :: Int -> Annote -> Int

hash :: Annote -> Int

Annotation Annote Source # 
Instance details

Defined in ReWire.Annotation

TextShow Annote Source # 
Instance details

Defined in ReWire.Annotation

data Provenance Source #

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).

Instances

Instances details
NFData Provenance Source # 
Instance details

Defined in ReWire.Annotation

Methods

rnf :: Provenance -> () #

Generic Provenance Source # 
Instance details

Defined in ReWire.Annotation

Associated Types

type Rep Provenance 
Instance details

Defined in ReWire.Annotation

type Rep Provenance = D1 ('MetaData "Provenance" "ReWire.Annotation" "rewire-base-2.8-FlLB0CaWUZ0C08bXxr65qo" 'False) (C1 ('MetaCons "FromSource" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Span)) :+: (C1 ('MetaCons "Synthesized" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Span])) :+: C1 ('MetaCons "NoProvenance" 'PrefixI 'False) (U1 :: Type -> Type)))
Show Provenance Source # 
Instance details

Defined in ReWire.Annotation

Eq Provenance Source # 
Instance details

Defined in ReWire.Annotation

Ord Provenance Source # 
Instance details

Defined in ReWire.Annotation

type Rep Provenance Source # 
Instance details

Defined in ReWire.Annotation

type Rep Provenance = D1 ('MetaData "Provenance" "ReWire.Annotation" "rewire-base-2.8-FlLB0CaWUZ0C08bXxr65qo" 'False) (C1 ('MetaCons "FromSource" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Span)) :+: (C1 ('MetaCons "Synthesized" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Span])) :+: C1 ('MetaCons "NoProvenance" 'PrefixI 'False) (U1 :: Type -> Type)))

data Span Source #

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.

Constructors

Span 

Fields

Instances

Instances details
NFData Span Source # 
Instance details

Defined in ReWire.Annotation

Methods

rnf :: Span -> () #

Generic Span Source # 
Instance details

Defined in ReWire.Annotation

Associated Types

type Rep Span 
Instance details

Defined in ReWire.Annotation

type Rep Span = D1 ('MetaData "Span" "ReWire.Annotation" "rewire-base-2.8-FlLB0CaWUZ0C08bXxr65qo" 'False) (C1 ('MetaCons "Span" 'PrefixI 'True) (S1 ('MetaSel ('Just "spanFile") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FilePath) :*: (S1 ('MetaSel ('Just "spanStart") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Int, Int)) :*: S1 ('MetaSel ('Just "spanEnd") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Int, Int)))))

Methods

from :: Span -> Rep Span x #

to :: Rep Span x -> Span #

Show Span Source # 
Instance details

Defined in ReWire.Annotation

Methods

showsPrec :: Int -> Span -> ShowS #

show :: Span -> String #

showList :: [Span] -> ShowS #

Eq Span Source # 
Instance details

Defined in ReWire.Annotation

Methods

(==) :: Span -> Span -> Bool #

(/=) :: Span -> Span -> Bool #

Ord Span Source # 
Instance details

Defined in ReWire.Annotation

Methods

compare :: Span -> Span -> Ordering #

(<) :: Span -> Span -> Bool #

(<=) :: Span -> Span -> Bool #

(>) :: Span -> Span -> Bool #

(>=) :: Span -> Span -> Bool #

max :: Span -> Span -> Span #

min :: Span -> Span -> Span #

type Rep Span Source # 
Instance details

Defined in ReWire.Annotation

type Rep Span = D1 ('MetaData "Span" "ReWire.Annotation" "rewire-base-2.8-FlLB0CaWUZ0C08bXxr65qo" 'False) (C1 ('MetaCons "Span" 'PrefixI 'True) (S1 ('MetaSel ('Just "spanFile") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FilePath) :*: (S1 ('MetaSel ('Just "spanStart") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Int, Int)) :*: S1 ('MetaSel ('Just "spanEnd") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Int, Int)))))

class Annotation a where Source #

Methods

toAnnote :: a -> Annote Source #

Instances

Instances details
Annotation Annote Source # 
Instance details

Defined in ReWire.Annotation

class Annotated a where Source #

Methods

ann :: a -> Annote Source #

newtype Blind a Source #

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).

Constructors

Blind 

Fields

Instances

Instances details
NFData a => NFData (Blind a) Source # 
Instance details

Defined in ReWire.Annotation

Methods

rnf :: Blind a -> () #

Data a => Data (Blind a) Source # 
Instance details

Defined in ReWire.Annotation

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Blind a -> c (Blind a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Blind a) #

toConstr :: Blind a -> Constr #

dataTypeOf :: Blind a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Blind a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Blind a)) #

gmapT :: (forall b. Data b => b -> b) -> Blind a -> Blind a #

gmapQl :: (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 #

gmapQ :: (forall d. Data d => d -> u) -> Blind a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Blind a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Blind a -> m (Blind a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Blind a -> m (Blind a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Blind a -> m (Blind a) #

Generic (Blind a) Source # 
Instance details

Defined in ReWire.Annotation

Associated Types

type Rep (Blind a) 
Instance details

Defined in ReWire.Annotation

type Rep (Blind a) = D1 ('MetaData "Blind" "ReWire.Annotation" "rewire-base-2.8-FlLB0CaWUZ0C08bXxr65qo" 'True) (C1 ('MetaCons "Blind" 'PrefixI 'True) (S1 ('MetaSel ('Just "unBlind") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

from :: Blind a -> Rep (Blind a) x #

to :: Rep (Blind a) x -> Blind a #

Show a => Show (Blind a) Source # 
Instance details

Defined in ReWire.Annotation

Methods

showsPrec :: Int -> Blind a -> ShowS #

show :: Blind a -> String #

showList :: [Blind a] -> ShowS #

Eq (Blind a) Source # 
Instance details

Defined in ReWire.Annotation

Methods

(==) :: Blind a -> Blind a -> Bool #

(/=) :: Blind a -> Blind a -> Bool #

Ord (Blind a) Source # 
Instance details

Defined in ReWire.Annotation

Methods

compare :: Blind a -> Blind a -> Ordering #

(<) :: Blind a -> Blind a -> Bool #

(<=) :: Blind a -> Blind a -> Bool #

(>) :: Blind a -> Blind a -> Bool #

(>=) :: Blind a -> Blind a -> Bool #

max :: Blind a -> Blind a -> Blind a #

min :: Blind a -> Blind a -> Blind a #

Hashable (Blind a) Source # 
Instance details

Defined in ReWire.Annotation

Methods

hashWithSalt :: Int -> Blind a -> Int

hash :: Blind a -> Int

Show a => TextShow (Blind a) Source # 
Instance details

Defined in ReWire.Annotation

Methods

showbPrec :: Int -> Blind a -> Builder #

showb :: Blind a -> Builder #

showbList :: [Blind a] -> Builder

showtPrec :: Int -> Blind a -> Text

showt :: Blind a -> Text #

showtList :: [Blind a] -> Text

showtlPrec :: Int -> Blind a -> Text

showtl :: Blind a -> Text

showtlList :: [Blind a] -> Text

type Rep (Blind a) Source # 
Instance details

Defined in ReWire.Annotation

type Rep (Blind a) = D1 ('MetaData "Blind" "ReWire.Annotation" "rewire-base-2.8-FlLB0CaWUZ0C08bXxr65qo" 'True) (C1 ('MetaCons "Blind" 'PrefixI 'True) (S1 ('MetaSel ('Just "unBlind") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

srcAnnote :: FilePath -> (Int, Int) -> (Int, Int) -> Annote Source #

Build an annotation for an explicit source region: a file with 1-based (line, column) start and end positions.

primSpan :: Annote -> Maybe Span Source #

The source span underlying an annotation, if it has one. Synthesized nodes yield the span of their first input.

unAnn :: Data d => d -> d Source #

Strip every annotation from a value, replacing each with noAnn. Used to make dumps readable and to compare terms structurally.