stan-0.2.0.0: Haskell STatic ANalyser

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

Stan.Observation

Contents

- Smart constructors
- Pretty print

Description

Observation — a suggestion found in the target project by `Stan`.

Synopsis

- data Observation = Observation {
  - observationId :: !(Id Observation)
  - observationInspectionId :: !(Id Inspection)
  - observationSrcSpan :: !RealSrcSpan
  - observationFile :: !FilePath
  - observationModuleName :: !ModuleName
  - observationFileContent :: !ByteString
  }
- type Observations = Slist Observation
- mkObservation :: Id Inspection -> HieFile -> RealSrcSpan -> Observation
- mkObservationId :: Id Inspection -> ModuleName -> RealSrcSpan -> Id Observation
- ignoredObservations :: [Id Observation] -> Observations -> ([Id Observation], [Id Observation])
- prettyShowObservation :: OutputSettings -> Observation -> Text
- prettyShowIgnoredObservations :: [Id Observation] -> Observations -> Text
- prettyObservationSource :: Bool -> Observation -> [Text]

# Documentation

data Observation #

Data type to represent discovered by Stan suggestions.

Constructors

Observation |
Fields observationId :: !(Id Observation) observationInspectionId :: !(Id Inspection) observationSrcSpan :: !RealSrcSpan observationFile :: !FilePath observationModuleName :: !ModuleName observationFileContent :: !ByteString

#### Instances

Instances details

Show Observation # |
Instance details Defined in Stan.Observation Methods showsPrec :: Int -> Observation -> ShowS # show :: Observation -> String # showList :: [Observation] -> ShowS #
Eq Observation # |
Instance details Defined in Stan.Observation Methods (==) :: Observation -> Observation -> Bool # (/=) :: Observation -> Observation -> Bool #
ToJSON Observation # |
Instance details Defined in Stan.Observation Methods toJSON :: Observation -> Value #

type Observations = Slist Observation #

Type alias for the sized list of `Observation`s.

# Smart constructors

mkObservation #

Arguments

:: Id Inspection | Corresponding `Inspection`s `Id`.
-> HieFile |
-> RealSrcSpan | Position.
-> Observation |

Smart constructor for `Observation`s from `HieFile`s.

mkObservationId :: Id Inspection -> ModuleName -> RealSrcSpan -> Id Observation #

Create a stable `Observation` `Id` in a such way that:

1. `Id` doesn't depend on other inspections in this file.
2. `Id` uniquely identifies `Observation` location.
3. `Id`s are guaranteed to be the same if the module content didn't change between different `stan` runs.

The `Observation` `Id` should look like this:

    OBS-STAN-XXXX-module-name-hash-10:42

ignoredObservations #

Arguments

:: [Id Observation] |
-> Observations |
-> ([Id Observation], [Id Observation]) | Ignored ^ Unknown

# Pretty print

prettyShowObservation :: OutputSettings -> Observation -> Text #

Show `Observation` in a human-friendly format.

prettyShowIgnoredObservations :: [Id Observation] -> Observations -> Text #

prettyObservationSource #

Arguments

:: Bool | Use colouring
-> Observation |
-> [Text] |