| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Temporary.API
Description
WARNING: This module represents the evolving API of HLint, do not use.
This module provides a way to apply HLint hints. To replicate the full hlint experience you would:
- Use
findSettingsto find and load the HLint settings files. - Use
readSettingsto interpret the settings files, producingHintRulevalues (LHS ==> RHSreplacements) andClassifyvalues to assignSeverityratings to hints. - Use
builtinHintsandhintRulesto generate aHintvalue. - Use
parseModuleExto parse the input files, using any fixity declarations fromfindSettings. - Use
applyHintsto execute the hints on the modules, generatingIdeas.
- applyHints :: [Classify] -> Hint -> [Module SrcSpanInfo] -> [Idea]
- data Idea = Idea {}
- data Severity
- data Note
- data Classify = Classify {}
- findSettings :: FilePath -> FilePath -> Maybe String -> IO ([String], [ParseError], [Module SrcSpanInfo])
- readSettings :: Module SrcSpanInfo -> ([Classify], [HintRule])
- data Hint = Hint {
- hintModules :: [(Scope, Module SrcSpanInfo)] -> [Idea]
- hintModule :: Scope -> Module SrcSpanInfo -> [Idea]
- hintDecl :: Scope -> Module SrcSpanInfo -> Decl SrcSpanInfo -> [Idea]
- builtinHints :: [(String, Hint)]
- data HintRule = HintRule {}
- hintRules :: [HintRule] -> Hint
- data Scope
- scopeCreate :: Module SrcSpanInfo -> Scope
- scopeMatch :: (Scope, QName SrcSpanInfo) -> (Scope, QName SrcSpanInfo) -> Bool
- scopeMove :: (Scope, QName SrcSpanInfo) -> Scope -> QName SrcSpanInfo
- parseModuleEx :: ParseFlags -> FilePath -> Maybe String -> IO (Either ParseError (Module SrcSpanInfo))
- defaultParseFlags :: ParseFlags
- data ParseError = ParseError {}
- data ParseFlags = ParseFlags {}
- data CppFlags
- data Encoding
- defaultEncoding :: Encoding
- readEncoding :: String -> IO Encoding
- useEncoding :: Handle -> Encoding -> IO ()
Documentation
applyHints :: [Classify] -> Hint -> [Module SrcSpanInfo] -> [Idea]
Idea data type
data Idea
An idea suggest by a Hint.
Constructors
| Idea | |
Fields
| |
data Severity
How severe an issue is.
data Note
A note describing the impact of the replacement.
Constructors
| IncreasesLaziness | The replacement is increases laziness, for example replacing |
| DecreasesLaziness | The replacement is decreases laziness, for example replacing |
| RemovesError String | The replacement removes errors, for example replacing |
| ValidInstance String String | The replacement assumes standard type class lemmas, a hint with the note |
| Note String | An arbitrary note. |
Settings
data Classify
How to classify an Idea. If any matching field is "" then it matches everything.
Constructors
| Classify | |
Fields
| |
findSettings :: FilePath -> FilePath -> Maybe String -> IO ([String], [ParseError], [Module SrcSpanInfo])
Given the data directory (where the hlint data files reside), and a filename to read, and optionally that file's
contents, produce a triple containing:
- Builtin hints to use, e.g.
List, which should be resolved usingbuiltinHints. - A list of parse errors produced while parsing settings files.
- A list of modules containing hints, suitable for processing with
readSettings.
readSettings :: Module SrcSpanInfo -> ([Classify], [HintRule])
Hints
data Hint
Functions to generate hints, combined using the Monoid instance.
Constructors
| Hint | |
Fields
| |
builtinHints :: [(String, Hint)]
A list of builtin hints, currently including entries such as "List" and "Bracket".
data HintRule
A LHS ==> RHS style hint rule.
Constructors
| HintRule | |
Fields
| |
Scopes
data Scope
Data type representing the modules in scope within a module.
Created with scopeCreate and queried with scopeMatch and scopeMove.
scopeCreate :: Module SrcSpanInfo -> Scope
Create a Scope value from a module, based on the modules imports.
scopeMatch :: (Scope, QName SrcSpanInfo) -> (Scope, QName SrcSpanInfo) -> Bool
Given a two names in scopes, could they possibly refer to the same thing. This property is reflexive.
scopeMove :: (Scope, QName SrcSpanInfo) -> Scope -> QName SrcSpanInfo
Given a name in a scope, and a new scope, create a name for the new scope that will refer to the same thing. If the resulting name is ambiguous, it picks a plausible candidate.
Haskell-src-exts
parseModuleEx :: ParseFlags -> FilePath -> Maybe String -> IO (Either ParseError (Module SrcSpanInfo))
Parse a Haskell module. Applies the C pre processor, and uses best-guess fixity resolution if there are ambiguities.
The filename - is treated as stdin. Requires some flags (often defaultParseFlags), the filename, and optionally the contents of that file.
defaultParseFlags :: ParseFlags
Default values for ParseFlags.
data ParseError
A parse error from parseModuleEx.
Constructors
| ParseError | |
Fields
| |
data CppFlags
What C pre processor should be used.
Constructors
| NoCpp | No pre processing is done. |
| CppSimple | Lines prefixed with |
| Cpphs CpphsOptions | The |
File encodings
data Encoding
An Encoding represents how characters are stored in a file. Created with
defaultEncoding or readEncoding and used with useEncoding.
The system default encoding.
readEncoding :: String -> IO Encoding
Create an encoding from a string, or throw an error if the encoding is not known.
Accepts many encodings including locale, utf-8 and all those supported by the
GHC mkTextEncoding function.
useEncoding :: Handle -> Encoding -> IO ()
Apply an encoding to a Handle.