Whine.Types
- Package
- purescript-whine-core
- Repository
- collegevine/purescript-whine
#Rule Source
newtype RuleA linting rule is just a function that takes a PureScript module and
performs effects in the MonadRules monad. Some of these effects may be
reportViolation - that's how rule violations are reported.
The type variable e is a peculiarity of how the language-cst-parser
library is structured: the whole AST is parametrized by this type, which
represents possible errors with parsing. When the tree is fully parsed
successfully, e is set to Void. Otherwise it's some error type.
Because for the purposes of this library we don't actually care whether the
parsing was successful, the handler function is polymorphic in e. But we
have to have a RangeOf instance for it, because it's a prerequisite for
other RangeOf instances for AST nodes, and we do need those, because we
need to report a source location for every violation.
Constructors
Rule (forall e m. MonadRules () m => RangeOf e => Module e -> m Unit)
#Violation Source
type Violation :: Row Type -> Typetype Violation r = { message :: String, source :: Maybe SourceRange | r }
Violation is an open record. When generated by a rule implementation, it
starts out with just source and message, but at higher stack levels
gets annotated with ID of the rule that created the violation (see
WithRule), with the file whence the violation came (see WithFile), and
with a flag showing if this particular violation was muted (see
WithMuted).
#Violations Source
type Violations :: Row Type -> Typetype Violations r = Array (Violation r)
#RuleFactories Source
type RuleFactories = Array (RuleId /\ RuleFactory)See comments on ruleFactory
#MonadReport Source
class MonadReport :: Row Type -> (Type -> Type) -> Constraintclass (Monad m) <= MonadReport v m | m -> v where
Members
reportViolation :: Violation v -> m Unit
#MonadRules Source
class MonadRules :: Row Type -> (Type -> Type) -> Constraintclass (Monad m, MonadLog m, MonadReport v m) <= MonadRules v m | m -> v
The monad in which each individual rule is run.
#ruleFactory Source
ruleFactory :: forall args. RuleId -> Codec args -> (args -> Rule) -> RuleId /\ RuleFactoryThis function is intended to pair rules with their IDs. Every rule would
take its own args and provide a JSON codec to decode the args, and the
list of possible rules and their IDs would be constructed like this:
factories :: ∀ m. RuleFactories m
factories =
[ ruleFactory "RuleOne" ruleOneArgsCodec ruleOne
, ruleFactory "RuleTwo" ruleTwoArgsCodec ruleTwo
]
ruleOne :: { arg :: Int, anotherArg :: String } -> Rule m
ruleTwo :: {} -> Rule m
ruleFactory takes care of parsing the arguments and reporting any errors,
so that the actual rule implementation only has to deal with strongly typed
arguments.
- Modules
- Vscode.
Client - Vscode.
Client. Configuration - Vscode.
Client. Executable - Vscode.
Client. FileSystemWatcher - Vscode.
Client. Workspace - Vscode.
Context - Vscode.
Events - Vscode.
Server. Capabilities - Vscode.
Server. Connection - Vscode.
Server. Diagnostic - Vscode.
Server. TextDocuments - Whine
- Whine.
Core. CaseBranchIndentation - Whine.
Core. CommaFirst - Whine.
Core. CommaFirstArrays - Whine.
Core. CommaFirstRecords - Whine.
Core. ModuleQualifiers - Whine.
Core. UndesirableFunctions - Whine.
Core. UndesirableModules - Whine.
Core. WhineRules - Whine.
Log - Whine.
Muting - Whine.
Prelude - Whine.
Print - Whine.
Runner - Whine.
Runner. Cli - Whine.
Runner. Config - Whine.
Runner. FS - Whine.
Runner. Glob - Whine.
Runner. LanguageServer - Whine.
Runner. PackageVersion - Whine.
Runner. Prelude - Whine.
Runner. Yaml - Whine.
Test - Whine.
Traversals - Whine.
Types - WhineM