-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Source code suggestions
--
-- HLint gives suggestions on how to improve your source code.
@package hlint
@version 1.9.21
-- | WARNING: This module represents the evolving second version of the
-- HLint API. It will be deleted in favour of
-- Language.Haskell.HLint3 in the next major version.
--
-- This module provides a way to apply HLint hints. As an example of
-- approximating the hlint experience:
--
--
-- (flags, classify, hint) <- autoSettings
-- Right m <- parseModuleEx flags "MyFile.hs" Nothing
-- print $ applyHints classify hint [m]
--
module Language.Haskell.HLint2
-- | Given a way of classifying results, and a Hint, apply to a set
-- of modules generating a list of Ideas. The Idea values
-- will be ordered within a file.
applyHints :: [Classify] -> Hint -> [(Module SrcSpanInfo, [Comment])] -> [Idea]
-- | An idea suggest by a Hint.
data Idea
Idea :: String -> String -> Severity -> String -> SrcSpan -> String -> Maybe String -> [Note] -> Idea
-- | The module the idea applies to, may be "" if the module
-- cannot be determined or is a result of cross-module hints.
ideaModule :: Idea -> String
-- | The declaration the idea applies to, typically the function name, but
-- may be a type name.
ideaDecl :: Idea -> String
-- | The severity of the idea, e.g. Warning.
ideaSeverity :: Idea -> Severity
-- | The name of the hint that generated the idea, e.g. "Use
-- reverse".
ideaHint :: Idea -> String
-- | The source code the idea relates to.
ideaSpan :: Idea -> SrcSpan
-- | The contents of the source code the idea relates to.
ideaFrom :: Idea -> String
-- | The suggested replacement, or Nothing for no replacement (e.g.
-- on parse errors).
ideaTo :: Idea -> Maybe String
-- | Notes about the effect of applying the replacement.
ideaNote :: Idea -> [Note]
-- | How severe an issue is.
data Severity
-- | The issue has been explicitly ignored and will usually be hidden (pass
-- --show on the command line to see ignored ideas).
Ignore :: Severity
-- | Warnings are things that some people may consider improvements, but
-- some may not.
Warning :: Severity
-- | Errors are suggestions that are nearly always a good idea to apply.
Error :: Severity
-- | A note describing the impact of the replacement.
data Note
-- | The replacement is increases laziness, for example replacing
-- reverse (reverse x) with x makes the code lazier.
IncreasesLaziness :: Note
-- | The replacement is decreases laziness, for example replacing (fst
-- x, snd x) with x makes the code stricter.
DecreasesLaziness :: Note
-- | The replacement removes errors, for example replacing foldr1
-- (+) with sum removes an error on [], and might
-- contain the text "on []".
RemovesError :: String -> Note
-- | The replacement assumes standard type class lemmas, a hint with the
-- note ValidInstance "Eq" "x" might only be valid if the
-- x variable has a reflexive Eq instance.
ValidInstance :: String -> String -> Note
-- | An arbitrary note.
Note :: String -> Note
-- | How to classify an Idea. If any matching field is ""
-- then it matches everything.
data Classify
Classify :: Severity -> String -> String -> String -> Classify
-- | Severity to set the Idea to.
classifySeverity :: Classify -> Severity
-- | Match on Idea field ideaHint.
classifyHint :: Classify -> String
-- | Match on Idea field ideaModule.
classifyModule :: Classify -> String
-- | Match on Idea field ideaDecl.
classifyDecl :: Classify -> String
-- | Get the Cabal configured data directory of HLint
getHLintDataDir :: IO FilePath
-- | The function produces a tuple containg ParseFlags (for
-- parseModuleEx), and Classify and Hint for
-- applyHints. It approximates the normal HLint configuration
-- steps, roughly:
--
--
-- - Use findSettings to find and load the HLint settings
-- files.
-- - Use readSettings to interpret the settings files, producing
-- HintRule values (LHS ==> RHS replacements) and
-- Classify values to assign Severity ratings to
-- hints.
-- - Use builtinHints and hintRules to generate a
-- Hint value.
-- - Take all fixities from the findSettings modules and put
-- them in the ParseFlags.
--
autoSettings :: IO (ParseFlags, [Classify], Hint)
autoSettings' :: FilePath -> IO (ParseFlags, [Classify], Hint)
-- | Given the data directory (where the hlint data files reside,
-- see getHLintDataDir), and a filename to read, and optionally
-- that file's contents, produce a pair containing:
--
--
-- - Builtin hints to use, e.g. List, which should be
-- resolved using builtinHints.
-- - A list of modules containing hints, suitable for processing with
-- readSettings.
--
--
-- Any parse failures will result in an exception.
findSettings :: FilePath -> FilePath -> Maybe String -> IO ([String], [Module SrcSpanInfo])
-- | Given a module containing HLint settings information return the
-- Classify rules and the HintRule expressions. Any fixity
-- declarations will be discarded, but any other unrecognised elements
-- will result in an exception.
readSettings :: Module SrcSpanInfo -> ([Classify], [HintRule])
-- | Functions to generate hints, combined using the Monoid
-- instance.
data Hint
Hint :: ([(Scope, Module SrcSpanInfo)] -> [Idea]) -> (Scope -> Module SrcSpanInfo -> [Idea]) -> (Scope -> Module SrcSpanInfo -> Decl SrcSpanInfo -> [Idea]) -> (Comment -> [Idea]) -> Hint
-- | Given a list of modules (and their scope information) generate some
-- Ideas.
hintModules :: Hint -> [(Scope, Module SrcSpanInfo)] -> [Idea]
-- | Given a single module and its scope information generate some
-- Ideas.
hintModule :: Hint -> Scope -> Module SrcSpanInfo -> [Idea]
-- | Given a declaration (with a module and scope) generate some
-- Ideas. This function will be partially applied with one
-- module/scope, then used on multiple Decl values.
hintDecl :: Hint -> Scope -> Module SrcSpanInfo -> Decl SrcSpanInfo -> [Idea]
-- | Given a comment generate some Ideas.
hintComment :: Hint -> Comment -> [Idea]
-- | A list of builtin hints, currently including entries such as
-- "List" and "Bracket".
builtinHints :: [(String, Hint)]
-- | A LHS ==> RHS style hint rule.
data HintRule
HintRule :: Severity -> String -> Scope -> Exp SrcSpanInfo -> Exp SrcSpanInfo -> Maybe (Exp SrcSpanInfo) -> [Note] -> HintRule
-- | Default severity for the hint.
hintRuleSeverity :: HintRule -> Severity
-- | Name for the hint.
hintRuleName :: HintRule -> String
-- | Module scope in which the hint operates.
hintRuleScope :: HintRule -> Scope
-- | LHS
hintRuleLHS :: HintRule -> Exp SrcSpanInfo
-- | RHS
hintRuleRHS :: HintRule -> Exp SrcSpanInfo
-- | Side condition, typically specified with where _ = ....
hintRuleSide :: HintRule -> Maybe (Exp SrcSpanInfo)
-- | Notes about application of the hint.
hintRuleNotes :: HintRule -> [Note]
hintRules :: [HintRule] -> Hint
-- | Data type representing the modules in scope within a module. Created
-- with scopeCreate and queried with scopeMatch and
-- scopeMove. Note that the mempty Scope is not
-- equivalent to scopeCreate on an empty module, due to the
-- implicit import of Prelude.
data Scope
-- | Create a Scope value from a module, based on the modules
-- imports.
scopeCreate :: Module SrcSpanInfo -> Scope
-- | Given a two names in scopes, could they possibly refer to the same
-- thing. This property is reflexive.
scopeMatch :: (Scope, QName SrcSpanInfo) -> (Scope, QName SrcSpanInfo) -> Bool
-- | 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.
scopeMove :: (Scope, QName SrcSpanInfo) -> Scope -> QName 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.
parseModuleEx :: ParseFlags -> FilePath -> Maybe String -> IO (Either ParseError (Module SrcSpanInfo, [Comment]))
-- | Default value for ParseFlags.
defaultParseFlags :: ParseFlags
-- | A parse error from parseModuleEx.
data ParseError
ParseError :: SrcLoc -> String -> String -> ParseError
-- | Location of the error.
parseErrorLocation :: ParseError -> SrcLoc
-- | Message about the cause of the error.
parseErrorMessage :: ParseError -> String
-- | Snippet of several lines (typically 5) including a >
-- character pointing at the faulty line.
parseErrorContents :: ParseError -> String
-- | Created with defaultParseFlags, used by parseModuleEx.
data ParseFlags
ParseFlags :: TextEncoding -> CppFlags -> ParseMode -> ParseFlags
-- | How the file is read in (defaults to utf8).
encoding :: ParseFlags -> TextEncoding
-- | How the file is preprocessed (defaults to NoCpp).
cppFlags :: ParseFlags -> CppFlags
-- | How the file is parsed (defaults to all fixities in the base
-- package and most non-conflicting extensions).
hseFlags :: ParseFlags -> ParseMode
-- | What C pre processor should be used.
data CppFlags
-- | No pre processing is done.
NoCpp :: CppFlags
-- | Lines prefixed with # are stripped.
CppSimple :: CppFlags
-- | The cpphs library is used.
Cpphs :: CpphsOptions -> CppFlags
-- | An Encoding represents how characters are stored in a file.
-- Created with defaultEncoding or readEncoding and used
-- with useEncoding.
type Encoding = TextEncoding
-- | The system default encoding.
defaultEncoding :: 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.
readEncoding :: String -> IO Encoding
-- | Apply an encoding to a Handle.
useEncoding :: Handle -> Encoding -> IO ()
-- | WARNING: This module represents the evolving second version of the
-- HLint API. It will be renamed to drop the "3" in the next major
-- version.
--
-- This module provides a way to apply HLint hints. As an example of
-- approximating the hlint experience:
--
--
-- (flags, classify, hint) <- autoSettings
-- Right m <- parseModuleEx flags "MyFile.hs" Nothing
-- print $ applyHints classify hint [m]
--
module Language.Haskell.HLint3
-- | Given a way of classifying results, and a Hint, apply to a set
-- of modules generating a list of Ideas. The Idea values
-- will be ordered within a file.
applyHints :: [Classify] -> Hint -> [(Module SrcSpanInfo, [Comment])] -> [Idea]
-- | An idea suggest by a Hint.
data Idea
Idea :: String -> String -> Severity -> String -> SrcSpan -> String -> Maybe String -> [Note] -> Idea
-- | The module the idea applies to, may be "" if the module
-- cannot be determined or is a result of cross-module hints.
ideaModule :: Idea -> String
-- | The declaration the idea applies to, typically the function name, but
-- may be a type name.
ideaDecl :: Idea -> String
-- | The severity of the idea, e.g. Warning.
ideaSeverity :: Idea -> Severity
-- | The name of the hint that generated the idea, e.g. "Use
-- reverse".
ideaHint :: Idea -> String
-- | The source code the idea relates to.
ideaSpan :: Idea -> SrcSpan
-- | The contents of the source code the idea relates to.
ideaFrom :: Idea -> String
-- | The suggested replacement, or Nothing for no replacement (e.g.
-- on parse errors).
ideaTo :: Idea -> Maybe String
-- | Notes about the effect of applying the replacement.
ideaNote :: Idea -> [Note]
-- | How severe an issue is.
data Severity
-- | The issue has been explicitly ignored and will usually be hidden (pass
-- --show on the command line to see ignored ideas).
Ignore :: Severity
-- | Warnings are things that some people may consider improvements, but
-- some may not.
Warning :: Severity
-- | Errors are suggestions that are nearly always a good idea to apply.
Error :: Severity
-- | A note describing the impact of the replacement.
data Note
-- | The replacement is increases laziness, for example replacing
-- reverse (reverse x) with x makes the code lazier.
IncreasesLaziness :: Note
-- | The replacement is decreases laziness, for example replacing (fst
-- x, snd x) with x makes the code stricter.
DecreasesLaziness :: Note
-- | The replacement removes errors, for example replacing foldr1
-- (+) with sum removes an error on [], and might
-- contain the text "on []".
RemovesError :: String -> Note
-- | The replacement assumes standard type class lemmas, a hint with the
-- note ValidInstance "Eq" "x" might only be valid if the
-- x variable has a reflexive Eq instance.
ValidInstance :: String -> String -> Note
-- | An arbitrary note.
Note :: String -> Note
-- | How to classify an Idea. If any matching field is ""
-- then it matches everything.
data Classify
Classify :: Severity -> String -> String -> String -> Classify
-- | Severity to set the Idea to.
classifySeverity :: Classify -> Severity
-- | Match on Idea field ideaHint.
classifyHint :: Classify -> String
-- | Match on Idea field ideaModule.
classifyModule :: Classify -> String
-- | Match on Idea field ideaDecl.
classifyDecl :: Classify -> String
-- | Get the Cabal configured data directory of HLint.
getHLintDataDir :: IO FilePath
-- | The function produces a tuple containg ParseFlags (for
-- parseModuleEx), and Classify and Hint for
-- applyHints. It approximates the normal HLint configuration
-- steps, roughly:
--
--
-- - Use findSettings with readSettingsFile to find and
-- load the HLint settings files.
-- - Use parseFlagsAddFixities and resolveHints to
-- transform the outputs of findSettings.
--
--
-- If you want to do anything custom (e.g. using a different data
-- directory, storing intermediate outputs, loading hints from a
-- database) you are expected to copy and paste this function, then
-- change it to your needs.
autoSettings :: IO (ParseFlags, [Classify], Hint)
-- | Given a function to load a module (typically readSettingsFile),
-- and a module to start from (defaults to HLint.HLint) find the
-- information from all settings files.
findSettings :: (String -> IO (FilePath, Maybe String)) -> Maybe String -> IO ([Fixity], [Classify], [Either HintBuiltin HintRule])
-- | Given a directory (or Nothing to imply getHLintDataDir),
-- and a mdoule name (e.g. HLint.Default), find the settings
-- file associated with it, returning the name of the file, and
-- (optionally) the contents.
--
-- This function looks for all settings files starting with
-- HLint. in the directory argument, and all other files
-- relative to the current directory.
readSettingsFile :: Maybe FilePath -> String -> IO (FilePath, Maybe String)
-- | A list of the builtin hints wired into HLint. This list is likely to
-- grow over time.
data HintBuiltin
HintList :: HintBuiltin
HintListRec :: HintBuiltin
HintMonad :: HintBuiltin
HintLambda :: HintBuiltin
HintBracket :: HintBuiltin
HintNaming :: HintBuiltin
HintStructure :: HintBuiltin
HintImport :: HintBuiltin
HintPragma :: HintBuiltin
HintExtensions :: HintBuiltin
HintUnsafe :: HintBuiltin
HintDuplicate :: HintBuiltin
HintComment :: HintBuiltin
-- | A LHS ==> RHS style hint rule.
data HintRule
HintRule :: Severity -> String -> Scope -> Exp SrcSpanInfo -> Exp SrcSpanInfo -> Maybe (Exp SrcSpanInfo) -> [Note] -> HintRule
-- | Default severity for the hint.
hintRuleSeverity :: HintRule -> Severity
-- | Name for the hint.
hintRuleName :: HintRule -> String
-- | Module scope in which the hint operates.
hintRuleScope :: HintRule -> Scope
-- | LHS
hintRuleLHS :: HintRule -> Exp SrcSpanInfo
-- | RHS
hintRuleRHS :: HintRule -> Exp SrcSpanInfo
-- | Side condition, typically specified with where _ = ....
hintRuleSide :: HintRule -> Maybe (Exp SrcSpanInfo)
-- | Notes about application of the hint.
hintRuleNotes :: HintRule -> [Note]
-- | Functions to generate hints, combined using the Monoid
-- instance.
data Hint
Hint :: ([(Scope, Module SrcSpanInfo)] -> [Idea]) -> (Scope -> Module SrcSpanInfo -> [Idea]) -> (Scope -> Module SrcSpanInfo -> Decl SrcSpanInfo -> [Idea]) -> (Comment -> [Idea]) -> Hint
-- | Given a list of modules (and their scope information) generate some
-- Ideas.
hintModules :: Hint -> [(Scope, Module SrcSpanInfo)] -> [Idea]
-- | Given a single module and its scope information generate some
-- Ideas.
hintModule :: Hint -> Scope -> Module SrcSpanInfo -> [Idea]
-- | Given a declaration (with a module and scope) generate some
-- Ideas. This function will be partially applied with one
-- module/scope, then used on multiple Decl values.
hintDecl :: Hint -> Scope -> Module SrcSpanInfo -> Decl SrcSpanInfo -> [Idea]
-- | Given a comment generate some Ideas.
hintComment :: Hint -> Comment -> [Idea]
-- | Transform a list of HintRule into a Hint.
resolveHints :: [Either HintBuiltin HintRule] -> Hint
-- | Data type representing the modules in scope within a module. Created
-- with scopeCreate and queried with scopeMatch and
-- scopeMove. Note that the mempty Scope is not
-- equivalent to scopeCreate on an empty module, due to the
-- implicit import of Prelude.
data Scope
-- | Create a Scope value from a module, based on the modules
-- imports.
scopeCreate :: Module SrcSpanInfo -> Scope
-- | Given a two names in scopes, could they possibly refer to the same
-- thing. This property is reflexive.
scopeMatch :: (Scope, QName SrcSpanInfo) -> (Scope, QName SrcSpanInfo) -> Bool
-- | 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.
scopeMove :: (Scope, QName SrcSpanInfo) -> Scope -> QName 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.
parseModuleEx :: ParseFlags -> FilePath -> Maybe String -> IO (Either ParseError (Module SrcSpanInfo, [Comment]))
-- | Default value for ParseFlags.
defaultParseFlags :: ParseFlags
parseFlagsAddFixities :: [Fixity] -> ParseFlags -> ParseFlags
-- | A parse error from parseModuleEx.
data ParseError
ParseError :: SrcLoc -> String -> String -> ParseError
-- | Location of the error.
parseErrorLocation :: ParseError -> SrcLoc
-- | Message about the cause of the error.
parseErrorMessage :: ParseError -> String
-- | Snippet of several lines (typically 5) including a >
-- character pointing at the faulty line.
parseErrorContents :: ParseError -> String
-- | Created with defaultParseFlags, used by parseModuleEx.
data ParseFlags
ParseFlags :: TextEncoding -> CppFlags -> ParseMode -> ParseFlags
-- | How the file is read in (defaults to utf8).
encoding :: ParseFlags -> TextEncoding
-- | How the file is preprocessed (defaults to NoCpp).
cppFlags :: ParseFlags -> CppFlags
-- | How the file is parsed (defaults to all fixities in the base
-- package and most non-conflicting extensions).
hseFlags :: ParseFlags -> ParseMode
-- | What C pre processor should be used.
data CppFlags
-- | No pre processing is done.
NoCpp :: CppFlags
-- | Lines prefixed with # are stripped.
CppSimple :: CppFlags
-- | The cpphs library is used.
Cpphs :: CpphsOptions -> CppFlags
-- | WARNING: This module represents the old version of the HLint
-- API. It will be deleted in favour of
-- Language.Haskell.HLint3 in the next major version.
--
-- This module provides a library interface to HLint, strongly modelled
-- on the command line interface.
module Language.Haskell.HLint
-- | This function takes a list of command line arguments, and returns the
-- given suggestions. To see a list of arguments type hlint
-- --help at the console. This function writes to the stdout/stderr
-- streams, unless --quiet is specified.
--
-- As an example:
--
--
-- do hints <- hlint ["src", "--ignore=Use map","--quiet"]
-- when (length hints > 3) $ error "Too many hints!"
--
hlint :: [String] -> IO [Suggestion]
-- | A suggestion - the Show instance is of particular use.
data Suggestion
-- | From a suggestion, extract the file location it refers to.
suggestionLocation :: Suggestion -> SrcLoc
-- | From a suggestion, determine how severe it is.
suggestionSeverity :: Suggestion -> Severity
-- | How severe an issue is.
data Severity
-- | The issue has been explicitly ignored and will usually be hidden (pass
-- --show on the command line to see ignored ideas).
Ignore :: Severity
-- | Warnings are things that some people may consider improvements, but
-- some may not.
Warning :: Severity
-- | Errors are suggestions that are nearly always a good idea to apply.
Error :: Severity