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.Pattern.Type

Contents

- Type
- eDSL
- Common `PatternType`s
  - Textual types
- Foldable patterns

Description

Patterns for types and type search.

Synopsis

- data PatternType
  - = PatternTypeName !NameMeta ![PatternType]
  - | PatternTypeFun !PatternType !PatternType
  - | PatternTypeAnything
  - | PatternTypeOr !PatternType !PatternType
  - | PatternTypeAnd !PatternType !PatternType
  - | PatternTypeNeg !PatternType
- (|->) :: PatternType -> PatternType -> PatternType
- (|::) :: NameMeta -> [PatternType] -> PatternType
- listPattern :: PatternType
- nonEmptyPattern :: PatternType
- listFunPattern :: PatternType
- integerPattern :: PatternType
- naturalPattern :: PatternType
- rationalPattern :: PatternType
- scientificPattern :: PatternType
- charPattern :: PatternType
- stringPattern :: PatternType
- textPattern :: PatternType
- foldableTypesPatterns :: NonEmpty PatternType
- foldableMethodsPatterns :: NonEmpty (NameMeta, PatternType -> PatternType)

# Type

data PatternType #

Query pattern used to search types in HIE AST.

Constructors

PatternTypeName !NameMeta ![PatternType]

Argument, type or constructor:

`a` | `PatternName (NameMeta ... "a") []`
`[a]` | `PatternName (NameMeta ... "List") [aPattern]` (after GHC 9.6) `PatternName (NameMeta ... "[]") [aPattern]` (before GHC 9.6)
`Either Int String` | `PatternName (NameMeta ... "Either") [intPattern, stringPattern]`

PatternTypeFun !PatternType !PatternType | Function pattern.
PatternTypeAnything | Type wildcard, matches anything.
PatternTypeOr !PatternType !PatternType | Choice between patterns. Should match either of them.
PatternTypeAnd !PatternType !PatternType | Union of patterns. Should match both of them.
PatternTypeNeg !PatternType | Negation of pattern. Should match everything except this pattern.

#### Instances

Instances details

Show PatternType # |
Instance details Defined in Stan.Pattern.Type Methods showsPrec :: Int -> PatternType -> ShowS # show :: PatternType -> String # showList :: [PatternType] -> ShowS #
Eq PatternType # |
Instance details Defined in Stan.Pattern.Type Methods (==) :: PatternType -> PatternType -> Bool # (/=) :: PatternType -> PatternType -> Bool #
PatternBool PatternType # |
Instance details Defined in Stan.Pattern.Type Methods (?) :: PatternType # neg :: PatternType -> PatternType # (|||) :: PatternType -> PatternType -> PatternType # (&&&) :: PatternType -> PatternType -> PatternType #

# eDSL

(|->) :: PatternType -> PatternType -> PatternType infixr 4 #

Short operator alias for `PatternFun`.

(|::) :: NameMeta -> [PatternType] -> PatternType infix 5 #

Short operator alias for `PatternTypeName`.

# Common `PatternType`s

listPattern :: PatternType #

`PatternType` for list `[a]` or ``String``.

nonEmptyPattern :: PatternType #

`PatternType` for `NonEmpty`.

listFunPattern :: PatternType #

`PatternType` for `[a] -> _` or `String -> _`.

integerPattern :: PatternType #

`PatternType` for `Integer`.

naturalPattern :: PatternType #

`PatternType` for `Natural`.

rationalPattern :: PatternType #

scientificPattern :: PatternType #

## Textual types

charPattern :: PatternType #

stringPattern :: PatternType #

`PatternType` for `String`.

textPattern :: PatternType #

`PatternType` for `Text`.

# Foldable patterns

foldableTypesPatterns :: NonEmpty PatternType #

List of types for `STAN-0207`.

foldableMethodsPatterns :: NonEmpty (NameMeta, PatternType -> PatternType) #

Type patterns for the `Foldable` typeclass methods. Represented as a non-empty list of pairs:

- Method name
- Function from type to pattern (where things like `Maybe`, `Either` should be)