stan-0.1.2.1: Haskell STatic ANalyser

Copyright | (c) 2020 Kowainik
License | MPL-2.0
Maintainer | Kowainik <xrom.xkov@gmail.com>
Safe Haskell | None
Language | Haskell2010

Stan.Analysis.Visitor

Description

HIE AST visitor for single-pass traversal.

Synopsis

- data VisitorState = VisitorState {
  - visitorStateObservations :: !Observations
  - visitorStateFixities :: !(HashMap Text ())
  - visitorStateOpDecls :: !(HashMap Text RealSrcSpan)
  }
- getFinalObservations :: HieFile -> Visitor -> Observations
- addObservation :: Observation -> State VisitorState ()
- addObservations :: Observations -> State VisitorState ()
- addFixity :: Text -> State VisitorState ()
- addOpDecl :: Text -> RealSrcSpan -> State VisitorState ()
- newtype Visitor = Visitor {
  - unVisitor :: HieAST TypeIndex -> State VisitorState ()
  }
- visitAst :: Visitor -> HieAST TypeIndex -> State VisitorState ()

# Documentation

data VisitorState #

State for the `Visitor` object that stores all values during a single HIE AST traversal.

Constructors

VisitorState |

Fields

- visitorStateObservations :: !Observations
- visitorStateFixities :: !(HashMap Text ())
- visitorStateOpDecls :: !(HashMap Text RealSrcSpan)

getFinalObservations :: HieFile -> Visitor -> Observations #

Get sized list of all `Observations` from the given HIE file using the created `Visitor`.

addObservation :: Observation -> State VisitorState () #

Add single `Observation` to the existing `VisitorState`.

addObservations :: Observations -> State VisitorState () #

Add `Observations` to the existing `VisitorState`.

addFixity :: Text -> State VisitorState () #

Add single operator infix declaration.

addOpDecl :: Text -> RealSrcSpan -> State VisitorState () #

Add single operator top-level defintion with its position.

newtype Visitor #

Object that implements the Visitor pattern.

Constructors

Visitor |

Fields

- unVisitor :: HieAST TypeIndex -> State VisitorState ()

visitAst :: Visitor -> HieAST TypeIndex -> State VisitorState () #

Traverse HIE AST starting from a given node using `Visitor`.