retrie-1.2.2: A powerful, easy-to-use codemodding tool for Haskell.

Safe Haskell | Safe-Inferred
Language | Haskell2010

Retrie.Rewrites

Synopsis

- data RewriteSpec
  - = Adhoc String
  - | AdhocPattern String
  - | AdhocType String
  - | Fold QualifiedName
  - | RuleBackward QualifiedName
  - | RuleForward QualifiedName
  - | TypeBackward QualifiedName
  - | TypeForward QualifiedName
  - | Unfold QualifiedName
  - | PatternForward QualifiedName
  - | PatternBackward QualifiedName
- type QualifiedName = String
- parseRewriteSpecs :: LibDir -> (FilePath -> IO (CPP AnnotatedModule)) -> FixityEnv -> [RewriteSpec] -> IO [Rewrite Universe]
- parseQualified :: String -> Either String (FilePath, FastString)
- parseAdhocs :: LibDir -> FixityEnv -> [String] -> IO [Rewrite Universe]

# Documentation

data RewriteSpec #

Possible ways to specify rewrites to `parseRewrites`.

Constructors

Adhoc String | Equation in RULES-format. (e.g. `"forall x. succ (pred x) = x"`) Will be applied left-to-right.
AdhocPattern String | Equation in pattern-synonym format, _without_ the keyword `pattern`.
AdhocType String | Equation in type-synonym format, _without_ the keyword 'type'.
Fold QualifiedName | Fold a function definition. The inverse of unfolding/inlining. Replaces instances of the function body with calls to the function.
RuleBackward QualifiedName | Apply a GHC RULE right-to-left.
RuleForward QualifiedName | Apply a GHC RULE left-to-right.
TypeBackward QualifiedName | Apply a type synonym right-to-left.
TypeForward QualifiedName | Apply a type synonym left-to-right.
Unfold QualifiedName | Unfold, or inline, a function definition.
PatternForward QualifiedName | Unfold a pattern synonym
PatternBackward QualifiedName | Fold a pattern synonym, replacing instances of the rhs with the synonym

type QualifiedName = String #

A qualified name. (e.g. `"Module.Name.functionName"`)

parseRewriteSpecs :: LibDir -> (FilePath -> IO (CPP AnnotatedModule)) -> FixityEnv -> [RewriteSpec] -> IO [Rewrite Universe] #

parseQualified :: String -> Either String (FilePath, FastString) #

parseAdhocs :: LibDir -> FixityEnv -> [String] -> IO [Rewrite Universe] #