Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Development.IDE
Synopsis
- (<>) :: Semigroup a => a -> a -> a
- data ParseResult a
- action :: Action a -> Rules ()
- type family RuleResult key
- data Rules a
- data Action a
- data Range = Range {}
- data Position = Position {
- _line :: UInt
- _character :: UInt
- data Doc ann
- pipe :: Doc ann
- equals :: Doc ann
- backslash :: Doc ann
- slash :: Doc ann
- dot :: Doc ann
- space :: Doc ann
- comma :: Doc ann
- colon :: Doc ann
- semi :: Doc ann
- rbrace :: Doc ann
- lbrace :: Doc ann
- rbracket :: Doc ann
- lbracket :: Doc ann
- rangle :: Doc ann
- langle :: Doc ann
- rparen :: Doc ann
- lparen :: Doc ann
- dquote :: Doc ann
- squote :: Doc ann
- braces :: Doc ann -> Doc ann
- brackets :: Doc ann -> Doc ann
- angles :: Doc ann -> Doc ann
- parens :: Doc ann -> Doc ann
- dquotes :: Doc ann -> Doc ann
- squotes :: Doc ann -> Doc ann
- layoutCompact :: Doc ann1 -> SimpleDocStream ann2
- layoutSmart :: LayoutOptions -> Doc ann -> SimpleDocStream ann
- layoutPretty :: LayoutOptions -> Doc ann -> SimpleDocStream ann
- defaultLayoutOptions :: LayoutOptions
- removeTrailingWhitespace :: SimpleDocStream ann -> SimpleDocStream ann
- fuse :: FusionDepth -> Doc ann -> Doc ann
- alterAnnotationsS :: (ann -> Maybe ann') -> SimpleDocStream ann -> SimpleDocStream ann'
- reAnnotateS :: (ann -> ann') -> SimpleDocStream ann -> SimpleDocStream ann'
- unAnnotateS :: SimpleDocStream ann -> SimpleDocStream xxx
- alterAnnotations :: (ann -> [ann']) -> Doc ann -> Doc ann'
- reAnnotate :: (ann -> ann') -> Doc ann -> Doc ann'
- unAnnotate :: Doc ann -> Doc xxx
- annotate :: ann -> Doc ann -> Doc ann
- surround :: Doc ann -> Doc ann -> Doc ann -> Doc ann
- enclose :: Doc ann -> Doc ann -> Doc ann -> Doc ann
- plural :: (Num amount, Eq amount) => doc -> doc -> amount -> doc
- fillBreak :: Int -> Doc ann -> Doc ann
- fill :: Int -> Doc ann -> Doc ann
- pageWidth :: (PageWidth -> Doc ann) -> Doc ann
- width :: Doc ann -> (Int -> Doc ann) -> Doc ann
- nesting :: (Int -> Doc ann) -> Doc ann
- column :: (Int -> Doc ann) -> Doc ann
- punctuate :: Doc ann -> [Doc ann] -> [Doc ann]
- cat :: [Doc ann] -> Doc ann
- fillCat :: [Doc ann] -> Doc ann
- vcat :: [Doc ann] -> Doc ann
- hcat :: [Doc ann] -> Doc ann
- sep :: [Doc ann] -> Doc ann
- fillSep :: [Doc ann] -> Doc ann
- vsep :: [Doc ann] -> Doc ann
- hsep :: [Doc ann] -> Doc ann
- concatWith :: Foldable t => (Doc ann -> Doc ann -> Doc ann) -> t (Doc ann) -> Doc ann
- (<+>) :: Doc ann -> Doc ann -> Doc ann
- tupled :: [Doc ann] -> Doc ann
- list :: [Doc ann] -> Doc ann
- encloseSep :: Doc ann -> Doc ann -> Doc ann -> [Doc ann] -> Doc ann
- indent :: Int -> Doc ann -> Doc ann
- hang :: Int -> Doc ann -> Doc ann
- align :: Doc ann -> Doc ann
- flatAlt :: Doc ann -> Doc ann -> Doc ann
- group :: Doc ann -> Doc ann
- hardline :: Doc ann
- softline' :: Doc ann
- softline :: Doc ann
- line' :: Doc ann
- line :: Doc ann
- nest :: Int -> Doc ann -> Doc ann
- emptyDoc :: Doc ann
- unsafeViaShow :: Show a => a -> Doc ann
- viaShow :: Show a => a -> Doc ann
- class Pretty a where
- pretty :: a -> Doc ann
- prettyList :: [a] -> Doc ann
- data FusionDepth
- data SimpleDocStream ann
- = SFail
- | SEmpty
- | SChar !Char (SimpleDocStream ann)
- | SText !Int !Text (SimpleDocStream ann)
- | SLine !Int (SimpleDocStream ann)
- | SAnnPush ann (SimpleDocStream ann)
- | SAnnPop (SimpleDocStream ann)
- data PageWidth
- newtype LayoutOptions = LayoutOptions {}
- getClientConfig :: MonadLsp Config m => m Config
- toCologActionWithPrio :: forall (m :: Type -> Type) msg. (MonadIO m, HasCallStack) => Recorder (WithPriority msg) -> LogAction m (WithSeverity msg)
- lspClientLogRecorder :: LanguageContextEnv config -> Recorder (WithPriority Text)
- lspClientMessageRecorder :: LanguageContextEnv config -> Recorder (WithPriority Text)
- withBacklog :: (v -> Recorder a) -> IO (Recorder a, v -> IO ())
- makeDefaultHandleRecorder :: MonadIO m => Maybe [LoggingColumn] -> Lock -> Handle -> m (Recorder (WithPriority (Doc a)))
- withFileRecorder :: MonadUnliftIO m => FilePath -> Maybe [LoggingColumn] -> (Either IOException (Recorder (WithPriority (Doc d))) -> m a) -> m a
- makeDefaultStderrRecorder :: MonadIO m => Maybe [LoggingColumn] -> m (Recorder (WithPriority (Doc a)))
- cfilter :: (a -> Bool) -> Recorder a -> Recorder a
- cmapIO :: (a -> IO b) -> Recorder b -> Recorder a
- cmapWithPrio :: (a -> b) -> Recorder (WithPriority b) -> Recorder (WithPriority a)
- cmap :: (a -> b) -> Recorder b -> Recorder a
- logWith :: (HasCallStack, MonadIO m) => Recorder (WithPriority msg) -> Priority -> msg -> m ()
- noLogging :: Logger
- logDebug :: Logger -> Text -> IO ()
- logInfo :: Logger -> Text -> IO ()
- logWarning :: Logger -> Text -> IO ()
- logError :: Logger -> Text -> IO ()
- data Priority
- newtype Logger = Logger {
- logPriority :: Priority -> Text -> IO ()
- data WithPriority a = WithPriority {
- priority :: Priority
- callStack_ :: CallStack
- payload :: a
- newtype Recorder msg = Recorder {}
- data LoggingColumn
- renderStrict :: SimpleDocStream ann -> Text
- data NormalizedUri
- type DiagnosticStore = HashMap NormalizedUri StoreItem
- data Diagnostic = Diagnostic {}
- data DiagnosticSeverity
- data Location = Location {}
- fromNormalizedFilePath :: NormalizedFilePath -> FilePath
- fromNormalizedUri :: NormalizedUri -> Uri
- toNormalizedUri :: Uri -> NormalizedUri
- newtype Uri = Uri {}
- data NormalizedFilePath
- data GhcVersion
- setHieDir :: FilePath -> DynFlags -> DynFlags
- dontWriteHieFiles :: DynFlags -> DynFlags
- disableWarningsAsErrors :: DynFlags -> DynFlags
- ghcVersion :: GhcVersion
- toNormalizedFilePath' :: FilePath -> NormalizedFilePath
- emptyFilePath :: NormalizedFilePath
- uriToFilePath' :: Uri -> Maybe FilePath
- emptyPathUri :: NormalizedUri
- filePathToUri' :: NormalizedFilePath -> NormalizedUri
- fromUri :: NormalizedUri -> NormalizedFilePath
- noFilePath :: FilePath
- noRange :: Range
- showPosition :: Position -> String
- readSrcSpan :: ReadS RealSrcSpan
- type FileDiagnostic = (NormalizedFilePath, ShowDiagnostic, Diagnostic)
- data ShowDiagnostic
- type IdeResultNoDiagnosticsEarlyCutoff v = (Maybe ByteString, Maybe v)
- type IdeResult v = ([FileDiagnostic], Maybe v)
- ideErrorText :: NormalizedFilePath -> Text -> FileDiagnostic
- ideErrorWithSource :: Maybe Text -> Maybe DiagnosticSeverity -> a -> Text -> (a, ShowDiagnostic, Diagnostic)
- showDiagnostics :: [FileDiagnostic] -> Text
- showDiagnosticsColored :: [FileDiagnostic] -> Text
- modifyDynFlags :: GhcMonad m => (DynFlags -> DynFlags) -> m ()
- lookupPackageConfig :: Unit -> HscEnv -> Maybe UnitInfo
- textToStringBuffer :: Text -> StringBuffer
- runParser :: DynFlags -> String -> P a -> ParseResult a
- stringBufferToByteString :: StringBuffer -> ByteString
- bytestringToStringBuffer :: ByteString -> StringBuffer
- printRdrName :: RdrName -> String
- printName :: Name -> String
- evalGhcEnv :: HscEnv -> Ghc b -> IO b
- moduleImportPath :: NormalizedFilePath -> ModuleName -> Maybe FilePath
- readFileUtf8 :: FilePath -> IO Text
- cgGutsToCoreModule :: SafeHaskellMode -> CgGuts -> ModDetails -> CoreModule
- fingerprintToBS :: Fingerprint -> ByteString
- fingerprintFromStringBuffer :: StringBuffer -> IO Fingerprint
- fingerprintFromByteString :: ByteString -> IO Fingerprint
- fingerprintFromPut :: Put -> IO Fingerprint
- hDuplicateTo' :: Handle -> Handle -> IO ()
- printOutputable :: Outputable a => a -> Text
- getExtensions :: ParsedModule -> [Extension]
- diagFromErrMsg :: Text -> DynFlags -> MsgEnvelope DecoratedSDoc -> [FileDiagnostic]
- diagFromErrMsgs :: Text -> DynFlags -> Bag (MsgEnvelope DecoratedSDoc) -> [FileDiagnostic]
- srcSpanToRange :: SrcSpan -> Maybe Range
- realSrcSpanToRange :: RealSrcSpan -> Range
- realSrcLocToPosition :: RealSrcLoc -> Position
- srcSpanToFilename :: SrcSpan -> Maybe FilePath
- realSrcSpanToLocation :: RealSrcSpan -> Location
- srcSpanToLocation :: SrcSpan -> Maybe Location
- rangeToSrcSpan :: NormalizedFilePath -> Range -> SrcSpan
- rangeToRealSrcSpan :: NormalizedFilePath -> Range -> RealSrcSpan
- positionToRealSrcLoc :: NormalizedFilePath -> Position -> RealSrcLoc
- isInsideSrcSpan :: Position -> SrcSpan -> Bool
- spanContainsRange :: SrcSpan -> Range -> Maybe Bool
- toDSeverity :: Severity -> Maybe DiagnosticSeverity
- diagFromStrings :: Text -> DiagnosticSeverity -> [(SrcSpan, String)] -> [FileDiagnostic]
- diagFromString :: Text -> DiagnosticSeverity -> SrcSpan -> String -> [FileDiagnostic]
- noSpan :: String -> SrcSpan
- zeroSpan :: FastString -> RealSrcSpan
- realSpan :: SrcSpan -> Maybe RealSrcSpan
- catchSrcErrors :: DynFlags -> Text -> IO a -> IO (Either [FileDiagnostic] a)
- diagFromGhcException :: Text -> DynFlags -> GhcException -> [FileDiagnostic]
- data HscEnvEq
- hscEnvWithImportPaths :: HscEnvEq -> HscEnv
- data GhcSessionIO = GhcSessionIO
- data IdeGhcSession = IdeGhcSession {
- loadSessionFun :: FilePath -> IO (IdeResult HscEnvEq, [FilePath])
- sessionVersion :: !Int
- data AddWatchedFile = AddWatchedFile
- data GetClientSettings = GetClientSettings
- data GetModSummary = GetModSummary
- data GetModSummaryWithoutTimestamps = GetModSummaryWithoutTimestamps
- data IsFileOfInterest = IsFileOfInterest
- data GetModIface = GetModIface
- data GetModIfaceFromDiskAndIndex = GetModIfaceFromDiskAndIndex
- data GetModIfaceFromDisk = GetModIfaceFromDisk
- newtype GhcSessionDeps where
- GhcSessionDeps_ { }
- pattern GhcSessionDeps :: GhcSessionDeps
- data GhcSession = GhcSession
- data GetBindings = GetBindings
- data GetHieAst = GetHieAst
- data GetDocMap = GetDocMap
- data TypeCheck = TypeCheck
- data ReportImportCycles = ReportImportCycles
- data GetModuleGraph = GetModuleGraph
- data NeedsCompilation = NeedsCompilation
- data GetLocatedImports = GetLocatedImports
- data GetParsedModuleWithComments = GetParsedModuleWithComments
- data GetParsedModule = GetParsedModule
- data ModSummaryResult = ModSummaryResult {}
- data IsFileOfInterestResult
- data FileOfInterestStatus
- data GetFileExists = GetFileExists
- data GetFileContents = GetFileContents
- data FileVersion
- newtype GetModificationTime = GetModificationTime_ {}
- data DocAndKindMap = DKMap {
- getDocMap :: !DocMap
- getKindMap :: !KindMap
- data HieKind a where
- data HieAstResult = forall a.Typeable a => HAR {}
- data HiFileResult = HiFileResult {
- hirModSummary :: !ModSummary
- hirModIface :: !ModIface
- hirModDetails :: ModDetails
- hirIfaceFp :: !ByteString
- hirRuntimeModules :: !(ModuleEnv ByteString)
- hirCoreFp :: !(Maybe (CoreFile, ByteString))
- data TcModuleResult = TcModuleResult {}
- data Splices = Splices {
- exprSplices :: [(LHsExpr GhcTc, LHsExpr GhcPs)]
- patSplices :: [(LHsExpr GhcTc, LPat GhcPs)]
- typeSplices :: [(LHsExpr GhcTc, LHsType GhcPs)]
- declSplices :: [(LHsExpr GhcTc, [LHsDecl GhcPs])]
- awSplices :: [(LHsExpr GhcTc, Serialized)]
- newtype ImportMap = ImportMap {}
- data GetImportMap = GetImportMap
- data GetLinkable = GetLinkable
- data LinkableResult = LinkableResult {}
- data GenerateCore = GenerateCore
- data GetKnownTargets = GetKnownTargets
- data LinkableType
- pattern GetModificationTime :: GetModificationTime
- encodeLinkableType :: Maybe LinkableType -> ByteString
- tmrModSummary :: TcModuleResult -> ModSummary
- hiFileFingerPrint :: HiFileResult -> ByteString
- mkHiFileResult :: ModSummary -> ModIface -> ModDetails -> ModuleEnv ByteString -> Maybe (CoreFile, ByteString) -> HiFileResult
- vfsVersion :: FileVersion -> Maybe Int32
- awSplicesL :: Lens' Splices [(LHsExpr GhcTc, Serialized)]
- declSplicesL :: Lens' Splices [(LHsExpr GhcTc, [LHsDecl GhcPs])]
- exprSplicesL :: Lens' Splices [(LHsExpr GhcTc, LHsExpr GhcPs)]
- patSplicesL :: Lens' Splices [(LHsExpr GhcTc, LPat GhcPs)]
- typeSplicesL :: Lens' Splices [(LHsExpr GhcTc, LHsType GhcPs)]
- data RuleBody k v
- = Rule (k -> NormalizedFilePath -> Action (Maybe ByteString, IdeResult v))
- | RuleNoDiagnostics (k -> NormalizedFilePath -> Action (Maybe ByteString, Maybe v))
- | RuleWithCustomNewnessCheck {
- newnessCheck :: ByteString -> ByteString -> Bool
- build :: k -> NormalizedFilePath -> Action (Maybe ByteString, Maybe v)
- | RuleWithOldValue (k -> NormalizedFilePath -> Value v -> Action (Maybe ByteString, IdeResult v))
- data FastResult a = FastResult {}
- newtype IdeAction a = IdeAction {}
- data VFSModified
- data IdeState
- type IdeRule k v = (RuleResult k ~ v, ShakeValue k, Show v, Typeable v, NFData v)
- data ShakeExtras
- getClientConfigAction :: Action Config
- getPluginConfigAction :: PluginId -> Action PluginConfig
- define :: IdeRule k v => Recorder (WithPriority Log) -> (k -> NormalizedFilePath -> Action (IdeResult v)) -> Rules ()
- defineNoDiagnostics :: IdeRule k v => Recorder (WithPriority Log) -> (k -> NormalizedFilePath -> Action (Maybe v)) -> Rules ()
- use :: IdeRule k v => k -> NormalizedFilePath -> Action (Maybe v)
- useWithStale :: IdeRule k v => k -> NormalizedFilePath -> Action (Maybe (v, PositionMapping))
- useWithStale_ :: IdeRule k v => k -> NormalizedFilePath -> Action (v, PositionMapping)
- runIdeAction :: String -> ShakeExtras -> IdeAction a -> IO a
- useWithStaleFast :: IdeRule k v => k -> NormalizedFilePath -> IdeAction (Maybe (v, PositionMapping))
- useWithStaleFast' :: IdeRule k v => k -> NormalizedFilePath -> IdeAction (FastResult v)
- useNoFile :: IdeRule k v => k -> Action (Maybe v)
- use_ :: IdeRule k v => k -> NormalizedFilePath -> Action v
- useNoFile_ :: IdeRule k v => k -> Action v
- uses_ :: (Traversable f, IdeRule k v) => k -> f NormalizedFilePath -> Action (f v)
- uses :: (Traversable f, IdeRule k v) => k -> f NormalizedFilePath -> Action (f (Maybe v))
- defineEarlyCutoff :: IdeRule k v => Recorder (WithPriority Log) -> RuleBody k v -> Rules ()
- ideLogger :: IdeState -> Logger
- actionLogger :: Action Logger
- data Plugin c = Plugin {
- pluginRules :: Rules ()
- pluginHandlers :: Handlers (ServerM c)
- pluginModifyDynflags :: c -> DynFlagsModifications
- getFilesOfInterestUntracked :: Action (HashMap NormalizedFilePath FileOfInterestStatus)
- data IdeConfiguration = IdeConfiguration {}
- isWorkspaceFile :: NormalizedFilePath -> Action Bool
- getFileContents :: NormalizedFilePath -> Action (UTCTime, Maybe Text)
- getFileExists :: NormalizedFilePath -> Action Bool
- runAction :: String -> IdeState -> Action a -> IO a
- getAtPoint :: NormalizedFilePath -> Position -> IdeAction (Maybe (Maybe Range, [Text]))
- getDefinition :: NormalizedFilePath -> Position -> IdeAction (Maybe [Location])
- getTypeDefinition :: NormalizedFilePath -> Position -> IdeAction (Maybe [Location])
- getParsedModule :: NormalizedFilePath -> Action (Maybe ParsedModule)
- usePropertyAction :: HasProperty s k t r => KeyNameProxy s -> PluginId -> Properties r -> Action (ToHsType t)
Documentation
(<>) :: Semigroup a => a -> a -> a infixr 6 #
An associative operation.
>>>
[1,2,3] <> [4,5,6]
[1,2,3,4,5,6]
data ParseResult a #
The result of running a parser.
Constructors
POk | The parser has consumed a (possibly empty) prefix
of the input and produced a result. Use |
Fields
| |
PFailed | The parser has consumed a (possibly empty) prefix of the input and failed. |
Fields
|
type family RuleResult key #
The type mapping between the key
or a rule and the resulting value
.
Instances
type RuleResult AddWatchedFile Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GenerateCore Source # | Convert to Core, requires TypeCheck* |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetBindings Source # | A IntervalMap telling us what is in scope at each point |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetClientSettings Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetDocMap Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetFileContents Source # | Get the contents of a file, either dirty (if the buffer is modified) or Nothing to mean use from disk. |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetFileExists Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetHieAst Source # | The uncompressed HieAST |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetImportMap Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetKnownTargets Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetLinkable Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetLocatedImports Source # | Resolve the imports in a module to the file path of a module in the same package |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetModIface Source # | Get a module interface details, either from an interface file or a typechecked module |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetModIfaceFromDisk Source # | Read the module interface file from disk. Throws an error for VFS files.
This is an internal rule, use |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetModIfaceFromDiskAndIndex Source # | GetModIfaceFromDisk and index the `.hie` file into the database.
This is an internal rule, use |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetModSummary Source # | Generate a ModSummary that has enough information to be used to get .hi and .hie files. without needing to parse the entire source |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetModSummaryWithoutTimestamps Source # | Generate a ModSummary with the timestamps and preprocessed content elided, for more successful early cutoff |
type RuleResult GetModificationTime Source # | Get the modification time of a file. |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetModuleGraph Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetParsedModule Source # | The parse tree for the file using GetFileContents |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GetParsedModuleWithComments Source # | The parse tree for the file using GetFileContents, all comments included using Opt_KeepRawTokenStream |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GhcSession Source # | A GHC session that we reuse. |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GhcSessionDeps Source # | A GHC session preloaded with all the dependencies This rule is also responsible for calling ReportImportCycles for the direct dependencies |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GhcSessionIO Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult IsFileOfInterest Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult NeedsCompilation Source # | Does this module need to be compiled? |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult ReportImportCycles Source # | This rule is used to report import cycles. It depends on GetModuleGraph. We cannot report the cycles directly from GetModuleGraph since we can only report diagnostics for the current file. |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult TypeCheck Source # | The type checked version of this file, requires TypeCheck+ |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult LocalCompletions Source # | Produce completions info for a file |
Defined in Development.IDE.Plugin.Completions.Types | |
type RuleResult NonLocalCompletions Source # | |
type RuleResult GetGlobalBindingTypeSigs Source # | |
type RuleResult (Q k) Source # | |
Defined in Development.IDE.Types.Shake |
A computation that defines all the rules that form part of the computation graph.
Rules
has access to IO
through MonadIO
. Use of IO
is at your own risk: if
you write Rules
that throw exceptions, then you need to make sure to handle them
yourself when you run the resulting Rules
.
An action representing something that can be run as part of a Rule
.
Action
s can be pure functions but also have access to IO
via MonadIO
and 'MonadUnliftIO.
It should be assumed that actions throw exceptions, these can be caught with
actionCatch
. In particular, it is
permissible to use the MonadFail
instance, which will lead to an IOException
.
Instances
A range in a text document expressed as (zero-based) start and end positions.
If you want to specify a range that contains a line including the line ending character(s) then use an end position denoting the start of the next line. For example: ```ts { start: { line: 5, character: 23 } end : { line 6, character : 0 } } ```
Constructors
Range | |
Instances
Position in a text document expressed as zero-based line and character
offset. Prior to 3.17 the offsets were always based on a UTF-16 string
representation. So a string of the form a𐐀b
the character offset of the
character a
is 0, the character offset of 𐐀
is 1 and the character
offset of b is 3 since 𐐀
is represented using two code units in UTF-16.
Since 3.17 clients and servers can agree on a different string encoding
representation (e.g. UTF-8). The client announces it's supported encoding
via the client capability `general.positionEncodings`.
The value is an array of position encodings the client supports, with
decreasing preference (e.g. the encoding at index `0` is the most preferred
one). To stay backwards compatible the only mandatory encoding is UTF-16
represented via the string `utf-16`. The server can pick one of the
encodings offered by the client and signals that encoding back to the
client via the initialize result's property
[`capabilities.positionEncoding`](#serverCapabilities). If the string value
`utf-16` is missing from the client's capability `general.positionEncodings`
servers can safely assume that the client supports UTF-16. If the server
omits the position encoding in its initialize result the encoding defaults
to the string value `utf-16`. Implementation considerations: since the
conversion from one encoding into another requires the content of the
file / line the conversion is best done where the file is read which is
usually on the server side.
Positions are line end character agnostic. So you can not specify a position that denotes `r|n` or `n|` where `|` represents the character offset.
@since 3.17.0 - support for negotiated position encoding.
Constructors
Position | |
Fields
|
Instances
The abstract data type
represents pretty documents that have
been annotated with data of type Doc
annann
.
More specifically, a value of type
represents a non-empty set of
possible layouts of a document. The layout functions select one of these
possibilities, taking into account things like the width of the output
document.Doc
The annotation is an arbitrary piece of data associated with (part of) a document. Annotations may be used by the rendering backends in order to display output differently, such as
- color information (e.g. when rendering to the terminal)
- mouseover text (e.g. when rendering to rich HTML)
- whether to show something or not (to allow simple or detailed versions)
The simplest way to display a Doc
is via the Show
class.
>>>
putStrLn (show (vsep ["hello", "world"]))
hello world
Instances
layoutCompact :: Doc ann1 -> SimpleDocStream ann2 #
(layoutCompact x)
lays out the document x
without adding any
indentation and without preserving annotations.
Since no 'pretty' printing is involved, this layouter is very
fast. The resulting output contains fewer characters than a prettyprinted
version and can be used for output that is read by other programs.
>>>
let doc = hang 4 (vsep ["lorem", "ipsum", hang 4 (vsep ["dolor", "sit"])])
>>>
doc
lorem ipsum dolor sit
>>>
let putDocCompact = renderIO System.IO.stdout . layoutCompact
>>>
putDocCompact doc
lorem ipsum dolor sit
layoutSmart :: LayoutOptions -> Doc ann -> SimpleDocStream ann #
A layout algorithm with more lookahead than layoutPretty
, that introduces
line breaks earlier if the content does not (or will not, rather) fit into
one line.
Consider the following python-ish document,
>>>
let fun x = hang 2 ("fun(" <> softline' <> x) <> ")"
>>>
let doc = (fun . fun . fun . fun . fun) (align (list ["abcdef", "ghijklm"]))
which we’ll be rendering using the following pipeline (where the layout algorithm has been left open):
>>>
import Data.Text.IO as T
>>>
import Prettyprinter.Render.Text
>>>
let hr = pipe <> pretty (replicate (26-2) '-') <> pipe
>>>
let go layouter x = (T.putStrLn . renderStrict . layouter (LayoutOptions (AvailablePerLine 26 1))) (vsep [hr, x, hr])
If we render this using layoutPretty
with a page width of 26 characters
per line, all the fun
calls fit into the first line so they will be put
there:
>>>
go layoutPretty doc
|------------------------| fun(fun(fun(fun(fun( [ abcdef , ghijklm ]))))) |------------------------|
Note that this exceeds the desired 26 character page width. The same
document, rendered with
, fits the layout contstraints:layoutSmart
>>>
go layoutSmart doc
|------------------------| fun( fun( fun( fun( fun( [ abcdef , ghijklm ]))))) |------------------------|
The key difference between layoutPretty
and layoutSmart
is that the
latter will check the potential document until it encounters a line with the
same indentation or less than the start of the document. Any line encountered
earlier is assumed to belong to the same syntactic structure.
layoutPretty
checks only the first line.
Consider for example the question of whether the A
s fit into the document
below:
1 A 2 A 3 A 4 B 5 B
layoutPretty
will check only line 1, ignoring whether e.g. line 2 might
already be too wide.
By contrast, layoutSmart
stops only once it reaches line 4, where the B
has the same indentation as the first A
.
layoutPretty :: LayoutOptions -> Doc ann -> SimpleDocStream ann #
This is the default layout algorithm, and it is used by show
, putDoc
and hPutDoc
.
commits to rendering something in a certain way if the next
element fits the layout constraints; in other words, it has one
layoutPretty
SimpleDocStream
element lookahead when rendering. Consider using the
smarter, but a bit less performant,
algorithm if the results
seem to run off to the right before having lots of line breaks.layoutSmart
defaultLayoutOptions :: LayoutOptions #
The default layout options, suitable when you just want some output, and
don’t particularly care about the details. Used by the Show
instance, for
example.
>>>
defaultLayoutOptions
LayoutOptions {layoutPageWidth = AvailablePerLine 80 1.0}
removeTrailingWhitespace :: SimpleDocStream ann -> SimpleDocStream ann #
Remove all trailing space characters.
This has some performance impact, because it does an entire additional pass
over the SimpleDocStream
.
No trimming will be done inside annotations, which are considered to contain
no (trimmable) whitespace, since the annotation might actually be about the
whitespace, for example a renderer that colors the background of trailing
whitespace, as e.g. git diff
can be configured to do.
Historical note: Since v1.7.0, layoutPretty
and layoutSmart
avoid
producing the trailing whitespace that was the original motivation for
creating removeTrailingWhitespace
.
See https://github.com/quchen/prettyprinter/pull/139 for some background
info.
fuse :: FusionDepth -> Doc ann -> Doc ann #
(
combines text nodes so they can be rendered more
efficiently. A fused document is always laid out identical to its unfused
version.fuse
depth doc)
When laying a Doc
ument out to a SimpleDocStream
, every component of the
input is translated directly to the simpler output format. This sometimes
yields undesirable chunking when many pieces have been concatenated together.
For example
>>>
"a" <> "b" <> pretty 'c' <> "d"
abcd
results in a chain of four entries in a SimpleDocStream
, although this is fully
equivalent to the tightly packed
>>>
"abcd" :: Doc ann
abcd
which is only a single SimpleDocStream
entry, and can be processed faster.
It is therefore a good idea to run fuse
on concatenations of lots of small
strings that are used many times:
>>>
let oftenUsed = fuse Shallow ("a" <> "b" <> pretty 'c' <> "d")
>>>
hsep (replicate 5 oftenUsed)
abcd abcd abcd abcd abcd
alterAnnotationsS :: (ann -> Maybe ann') -> SimpleDocStream ann -> SimpleDocStream ann' #
Change the annotation of a document to a different annotation, or none at
all. alterAnnotations
for SimpleDocStream
.
Note that the Doc
version is more flexible, since it allows changing a
single annotation to multiple ones.
(SimpleDocTree
restores
this flexibility again.)
reAnnotateS :: (ann -> ann') -> SimpleDocStream ann -> SimpleDocStream ann' #
Change the annotation of a document. reAnnotate
for SimpleDocStream
.
unAnnotateS :: SimpleDocStream ann -> SimpleDocStream xxx #
Remove all annotations. unAnnotate
for SimpleDocStream
.
alterAnnotations :: (ann -> [ann']) -> Doc ann -> Doc ann' #
Change the annotations of a Doc
ument. Individual annotations can be
removed, changed, or replaced by multiple ones.
This is a general function that combines unAnnotate
and reAnnotate
, and
it is useful for mapping semantic annotations (such as »this is a keyword«)
to display annotations (such as »this is red and underlined«), because some
backends may not care about certain annotations, while others may.
Annotations earlier in the new list will be applied earlier, i.e. returning
[Bold, Green]
will result in a bold document that contains green text, and
not vice-versa.
Since this traverses the entire
tree, including parts that are not
rendered due to other layouts fitting better, it is preferrable to reannotate
after producing the layout by using Doc
.alterAnnotationsS
reAnnotate :: (ann -> ann') -> Doc ann -> Doc ann' #
Change the annotation of a Doc
ument.
Useful in particular to embed documents with one form of annotation in a more generally annotated document.
Since this traverses the entire
tree, including parts that are not
rendered due to other layouts fitting better, it is preferrable to reannotate
after producing the layout by using Doc
.reAnnotateS
Since
has the right type and satisfies reAnnotate
'reAnnotate id = id'
,
it is used to define the
instance of Functor
.Doc
unAnnotate :: Doc ann -> Doc xxx #
Remove all annotations.
Although unAnnotate
is idempotent with respect to rendering,
unAnnotate
.unAnnotate
=unAnnotate
it should not be used without caution, for each invocation traverses the
entire contained document. If possible, it is preferrable to unannotate after
producing the layout by using unAnnotateS
.
annotate :: ann -> Doc ann -> Doc ann #
Add an annotation to a
. This annotation can then be used by the
renderer to e.g. add color to certain parts of the output. For a full
tutorial example on how to use it, see the
Prettyprinter.Render.Tutorials.StackMachineTutorial or
Prettyprinter.Render.Tutorials.TreeRenderingTutorial modules.Doc
This function is only relevant for custom formats with their own annotations, and not relevant for basic prettyprinting. The predefined renderers, e.g. Prettyprinter.Render.Text, should be enough for the most common needs.
(
is plural
n one many)one
if n
is 1
, and many
otherwise. A
typical use case is adding a plural "s".
>>>
let things = [True]
>>>
let amount = length things
>>>
pretty things <+> "has" <+> pretty amount <+> plural "entry" "entries" amount
[True] has 1 entry
(
first lays out the document fillBreak
i x)x
. It then appends space
s
until the width is equal to i
. If the width of x
is already larger than
i
, the nesting level is increased by i
and a line
is appended. When we
redefine ptype
in the example given in fill
to use
, we get
a useful variation of the output:fillBreak
>>>
let types = [("empty","Doc"), ("nest","Int -> Doc -> Doc"), ("fillSep","[Doc] -> Doc")]
>>>
let ptype (name, tp) = fillBreak 5 (pretty name) <+> "::" <+> pretty tp
>>>
"let" <+> align (vcat (map ptype types))
let empty :: Doc nest :: Int -> Doc -> Doc fillSep :: [Doc] -> Doc
(
lays out the document fill
i x)x
. It then appends space
s until
the width is equal to i
. If the width of x
is already larger, nothing is
appended.
This function is quite useful in practice to output a list of bindings:
>>>
let types = [("empty","Doc"), ("nest","Int -> Doc -> Doc"), ("fillSep","[Doc] -> Doc")]
>>>
let ptype (name, tp) = fill 5 (pretty name) <+> "::" <+> pretty tp
>>>
"let" <+> align (vcat (map ptype types))
let empty :: Doc nest :: Int -> Doc -> Doc fillSep :: [Doc] -> Doc
pageWidth :: (PageWidth -> Doc ann) -> Doc ann #
Layout a document depending on the page width, if one has been specified.
>>>
let prettyPageWidth (AvailablePerLine l r) = "Width:" <+> pretty l <> ", ribbon fraction:" <+> pretty r
>>>
let doc = "prefix" <+> pageWidth (brackets . prettyPageWidth)
>>>
putDocW 32 (vsep [indent n doc | n <- [0,4,8]])
prefix [Width: 32, ribbon fraction: 1.0] prefix [Width: 32, ribbon fraction: 1.0] prefix [Width: 32, ribbon fraction: 1.0]
width :: Doc ann -> (Int -> Doc ann) -> Doc ann #
(
lays out the document width
doc f)doc
, and makes the column width
of it available to a function.
>>>
let annotate doc = width (brackets doc) (\w -> " <- width:" <+> pretty w)
>>>
align (vsep (map annotate ["---", "------", indent 3 "---", vsep ["---", indent 4 "---"]]))
[---] <- width: 5 [------] <- width: 8 [ ---] <- width: 8 [--- ---] <- width: 8
column :: (Int -> Doc ann) -> Doc ann #
Layout a document depending on which column it starts at. align
is
implemented in terms of column
.
>>>
column (\l -> "Columns are" <+> pretty l <> "-based.")
Columns are 0-based.
>>>
let doc = "prefix" <+> column (\l -> "| <- column" <+> pretty l)
>>>
vsep [indent n doc | n <- [0,4,8]]
prefix | <- column 7 prefix | <- column 11 prefix | <- column 15
(
appends punctuate
p xs)p
to all but the last document in xs
.
>>>
let docs = punctuate comma (Util.words "lorem ipsum dolor sit amet")
>>>
putDocW 80 (hsep docs)
lorem, ipsum, dolor, sit, amet
The separators are put at the end of the entries, which we can see if we position the result vertically:
>>>
putDocW 20 (vsep docs)
lorem, ipsum, dolor, sit, amet
If you want put the commas in front of their elements instead of at the end,
you should use tupled
or, in general, encloseSep
.
(
tries laying out the documents cat
xs)xs
separated with nothing,
and if this does not fit the page, separates them with newlines. This is what
differentiates it from vcat
, which always lays out its contents beneath
each other.
>>>
let docs = Util.words "lorem ipsum dolor"
>>>
putDocW 80 ("Docs:" <+> cat docs)
Docs: loremipsumdolor
When there is enough space, the documents are put above one another:
>>>
putDocW 10 ("Docs:" <+> cat docs)
Docs: lorem ipsum dolor
cat
=group
.vcat
fillCat :: [Doc ann] -> Doc ann #
(
concatenates documents fillCat
xs)xs
horizontally with
as
long as it fits the page, then inserts a <>
and continues doing that
for all documents in line'
xs
. This is similar to how an ordinary word processor
lays out the text if you just keep typing after you hit the maximum line
length.
(
means that if line'
group
ed, the documents are separated with nothing
instead of newlines. See fillSep
if you want a space
instead.)
Observe the difference between fillSep
and fillCat
. fillSep
concatenates the entries space
d when group
ed:
>>>
let docs = take 20 (cycle (["lorem", "ipsum", "dolor", "sit", "amet"]))
>>>
putDocW 40 ("Grouped:" <+> group (fillSep docs))
Grouped: lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet
On the other hand, fillCat
concatenates the entries directly when
group
ed:
>>>
putDocW 40 ("Grouped:" <+> group (fillCat docs))
Grouped: loremipsumdolorsitametlorem ipsumdolorsitametloremipsumdolorsitamet loremipsumdolorsitamet
vcat :: [Doc ann] -> Doc ann #
(
vertically concatenates the documents vcat
xs)xs
. If it is
group
ed, the line breaks are removed.
In other words
is like vcat
, with newlines removed instead of
replaced by vsep
space
s.
>>>
let docs = Util.words "lorem ipsum dolor"
>>>
vcat docs
lorem ipsum dolor>>>
group (vcat docs)
loremipsumdolor
Since group
ing a vcat
is rather common, cat
is a built-in shortcut for
it.
(
tries laying out the documents sep
xs)xs
separated with space
s,
and if this does not fit the page, separates them with newlines. This is what
differentiates it from vsep
, which always lays out its contents beneath
each other.
>>>
let doc = "prefix" <+> sep ["text", "to", "lay", "out"]
>>>
putDocW 80 doc
prefix text to lay out
With a narrower layout, the entries are separated by newlines:
>>>
putDocW 20 doc
prefix text to lay out
sep
=group
.vsep
fillSep :: [Doc ann] -> Doc ann #
(
concatenates the documents fillSep
xs)xs
horizontally with
as long as it fits the page, then inserts a <+>
and continues doing that
for all documents in line
xs
. (
means that if line
group
ed, the documents
are separated with a space
instead of newlines. Use fillCat
if you do not
want a space
.)
Let's print some words to fill the line:
>>>
let docs = take 20 (cycle ["lorem", "ipsum", "dolor", "sit", "amet"])
>>>
putDocW 80 ("Docs:" <+> fillSep docs)
Docs: lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet
The same document, printed at a width of only 40, yields
>>>
putDocW 40 ("Docs:" <+> fillSep docs)
Docs: lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet
vsep :: [Doc ann] -> Doc ann #
(
concatenates all documents vsep
xs)xs
above each other. If a
group
undoes the line breaks inserted by vsep
, the documents are
separated with a space
instead.
Using vsep
alone yields
>>>
"prefix" <+> vsep ["text", "to", "lay", "out"]
prefix text to lay out
group
ing a vsep
separates the documents with a space
if it fits the
page (and does nothing otherwise). See the
convenience function for
this use case.sep
The align
function can be used to align the documents under their first
element:
>>>
"prefix" <+> align (vsep ["text", "to", "lay", "out"])
prefix text to lay out
Since group
ing a vsep
is rather common, sep
is a built-in for doing
that.
hsep :: [Doc ann] -> Doc ann #
(
concatenates all documents hsep
xs)xs
horizontally with
,
i.e. it puts a space between all entries.<+>
>>>
let docs = Util.words "lorem ipsum dolor sit amet"
>>>
hsep docs
lorem ipsum dolor sit amet
does not introduce line breaks on its own, even when the page is too
narrow:hsep
>>>
putDocW 5 (hsep docs)
lorem ipsum dolor sit amet
For automatic line breaks, consider using fillSep
instead.
concatWith :: Foldable t => (Doc ann -> Doc ann -> Doc ann) -> t (Doc ann) -> Doc ann #
Concatenate all documents element-wise with a binary function.
concatWith
_ [] =mempty
concatWith
(**) [x,y,z] = x ** y ** z
Multiple convenience definitions based on concatWith
are already predefined,
for example:
hsep
=concatWith
(<+>
)fillSep
=concatWith
(\x y -> x<>
softline
<>
y)
This is also useful to define customized joiners:
>>>
concatWith (surround dot) ["Prettyprinter", "Render", "Text"]
Prettyprinter.Render.Text
tupled :: [Doc ann] -> Doc ann #
Haskell-inspired variant of encloseSep
with parentheses and comma as
separator.
>>>
let doc = tupled (map pretty [1,20,300,4000])
>>>
putDocW 80 doc
(1, 20, 300, 4000)
>>>
putDocW 10 doc
( 1 , 20 , 300 , 4000 )
list :: [Doc ann] -> Doc ann #
Haskell-inspired variant of encloseSep
with braces and comma as
separator.
>>>
let doc = list (map pretty [1,20,300,4000])
>>>
putDocW 80 doc
[1, 20, 300, 4000]
>>>
putDocW 10 doc
[ 1 , 20 , 300 , 4000 ]
Arguments
:: Doc ann | left delimiter |
-> Doc ann | right delimiter |
-> Doc ann | separator |
-> [Doc ann] | input documents |
-> Doc ann |
(
concatenates the documents encloseSep
l r sep xs)xs
separated by
sep
, and encloses the resulting document by l
and r
.
The documents are laid out horizontally if that fits the page:
>>>
let doc = "list" <+> align (encloseSep lbracket rbracket comma (map pretty [1,20,300,4000]))
>>>
putDocW 80 doc
list [1,20,300,4000]
If there is not enough space, then the input is split into lines entry-wise therwise they are laid out vertically, with separators put in the front:
>>>
putDocW 10 doc
list [1 ,20 ,300 ,4000]
Note that doc
contains an explicit call to align
so that the list items
are aligned vertically.
For putting separators at the end of entries instead, have a look at
punctuate
.
Arguments
:: Int | Change of nesting level, relative to the start of the first line |
-> Doc ann | |
-> Doc ann |
(
lays out the document hang
i x)x
with a nesting level set to the
current column plus i
. Negative values are allowed, and decrease the
nesting level accordingly.
>>>
let doc = reflow "Indenting these words with hang"
>>>
putDocW 24 ("prefix" <+> hang 4 doc)
prefix Indenting these words with hang
This differs from nest
, which is based on the current nesting level plus
i
. When you're not sure, try the more efficient nest
first. In our
example, this would yield
>>>
let doc = reflow "Indenting these words with nest"
>>>
putDocW 24 ("prefix" <+> nest 4 doc)
prefix Indenting these words with nest
hang
i doc =align
(nest
i doc)
(
lays out the document align
x)x
with the nesting level set to the
current column. It is used for example to implement hang
.
As an example, we will put a document right above another one, regardless of
the current nesting level. Without align
ment, the second line is put simply
below everything we've had so far:
>>>
"lorem" <+> vsep ["ipsum", "dolor"]
lorem ipsum dolor
If we add an align
to the mix, the
's contents all start in the
same column:vsep
>>>
"lorem" <+> align (vsep ["ipsum", "dolor"])
lorem ipsum dolor
By default, (
renders as flatAlt
x y)x
. However when group
ed,
y
will be preferred, with x
as the fallback for the case when y
doesn't fit.
>>>
let doc = flatAlt "a" "b"
>>>
putDoc doc
a>>>
putDoc (group doc)
b>>>
putDocW 0 (group doc)
a
flatAlt
is particularly useful for defining conditional separators such as
softline =group
(flatAlt
hardline
" ")
>>>
let hello = "Hello" <> softline <> "world!"
>>>
putDocW 12 hello
Hello world!>>>
putDocW 11 hello
Hello world!
Example: Haskell's do-notation
We can use this to render Haskell's do-notation nicely:
>>>
let open = flatAlt "" "{ "
>>>
let close = flatAlt "" " }"
>>>
let separator = flatAlt "" "; "
>>>
let prettyDo xs = group ("do" <+> align (encloseSep open close separator xs))
>>>
let statements = ["name:_ <- getArgs", "let greet = \"Hello, \" <> name", "putStrLn greet"]
This is put into a single line with {;}
style if it fits:
>>>
putDocW 80 (prettyDo statements)
do { name:_ <- getArgs; let greet = "Hello, " <> name; putStrLn greet }
When there is not enough space the statements are broken up into lines nicely:
>>>
putDocW 10 (prettyDo statements)
do name:_ <- getArgs let greet = "Hello, " <> name putStrLn greet
Notes
Users should be careful to choose x
to be less wide than y
.
Otherwise, if y
turns out not to fit the page, we fall back on an even
wider layout:
>>>
let ugly = group (flatAlt "even wider" "too wide")
>>>
putDocW 7 ugly
even wider
Also note that group
will flatten y
:
>>>
putDoc (group (flatAlt "x" ("y" <> line <> "y")))
y y
This also means that an "unflattenable" y
which contains a hard linebreak
will never be rendered:
>>>
putDoc (group (flatAlt "x" ("y" <> hardline <> "y")))
x
(
tries laying out group
x)x
into a single line by removing the
contained line breaks; if this does not fit the page, or when a hardline
within x
prevents it from being flattened, x
is laid out without any
changes.
The group
function is key to layouts that adapt to available space nicely.
See vcat
, line
, or flatAlt
for examples that are related, or make good
use of it.
A
is always laid out as a line break, even when hardline
group
ed or
when there is plenty of space. Note that it might still be simply discarded
if it is part of a flatAlt
inside a group
.
>>>
let doc = "lorem ipsum" <> hardline <> "dolor sit amet"
>>>
putDocW 1000 doc
lorem ipsum dolor sit amet
>>>
group doc
lorem ipsum dolor sit amet
is like softline'
, but behaves like softline
if the
resulting output does not fit on the page (instead of mempty
). In other
words, space
is to line
how line'
is to softline
.softline'
With enough space, we get direct concatenation:
>>>
let doc = "ThisWord" <> softline' <> "IsWayTooLong"
>>>
putDocW 80 doc
ThisWordIsWayTooLong
If we narrow the page to width 10, the layouter produces a line break:
>>>
putDocW 10 doc
ThisWord IsWayTooLong
softline'
=group
line'
softline
behaves like
if the resulting output fits the page,
otherwise like space
.line
Here, we have enough space to put everything in one line:
>>>
let doc = "lorem ipsum" <> softline <> "dolor sit amet"
>>>
putDocW 80 doc
lorem ipsum dolor sit amet
If we narrow the page to width 10, the layouter produces a line break:
>>>
putDocW 10 doc
lorem ipsum dolor sit amet
softline
=group
line
(
lays out the document nest
i x)x
with the current nesting level
(indentation of the following lines) increased by i
. Negative values are
allowed, and decrease the nesting level accordingly.
>>>
vsep [nest 4 (vsep ["lorem", "ipsum", "dolor"]), "sit", "amet"]
lorem ipsum dolor sit amet
See also
unsafeViaShow :: Show a => a -> Doc ann #
viaShow :: Show a => a -> Doc ann #
Convenience function to convert a Show
able value to a Doc
. If the
String
does not contain newlines, consider using the more performant
unsafeViaShow
.
Minimal complete definition
Methods
>>>
pretty 1 <+> pretty "hello" <+> pretty 1.234
1 hello 1.234
prettyList :: [a] -> Doc ann #
is only used to define the prettyList
instance
. In normal circumstances only the Pretty
a => Pretty
[a]
function is used.pretty
>>>
prettyList [1, 23, 456]
[1, 23, 456]
Instances
data FusionDepth #
Fusion depth parameter, used by fuse
.
Constructors
Shallow | Do not dive deep into nested documents, fusing mostly concatenations of text nodes together. |
Deep | Recurse into all parts of the This value should only be used if profiling shows it is significantly
faster than using |
Instances
Show FusionDepth | |
Defined in Prettyprinter.Internal Methods showsPrec :: Int -> FusionDepth -> ShowS # show :: FusionDepth -> String # showList :: [FusionDepth] -> ShowS # | |
Eq FusionDepth | |
Defined in Prettyprinter.Internal | |
Ord FusionDepth | |
Defined in Prettyprinter.Internal Methods compare :: FusionDepth -> FusionDepth -> Ordering # (<) :: FusionDepth -> FusionDepth -> Bool # (<=) :: FusionDepth -> FusionDepth -> Bool # (>) :: FusionDepth -> FusionDepth -> Bool # (>=) :: FusionDepth -> FusionDepth -> Bool # max :: FusionDepth -> FusionDepth -> FusionDepth # min :: FusionDepth -> FusionDepth -> FusionDepth # |
data SimpleDocStream ann #
The data type SimpleDocStream
represents laid out documents and is used
by the display functions.
A simplified view is that
, and the layout
functions pick one of the Doc
= [SimpleDocStream
]SimpleDocStream
s based on which one fits the
layout constraints best. This means that SimpleDocStream
has all complexity
contained in Doc
resolved, making it very easy to convert it to other
formats, such as plain text or terminal output.
To write your own
to X converter, it is therefore sufficient to
convert from Doc
. The »Render« submodules provide some
built-in converters to do so, and helpers to create own ones.SimpleDocStream
Constructors
SFail | |
SEmpty | |
SChar !Char (SimpleDocStream ann) | |
SText !Int !Text (SimpleDocStream ann) | |
SLine !Int (SimpleDocStream ann) |
|
SAnnPush ann (SimpleDocStream ann) | Add an annotation to the remaining document. |
SAnnPop (SimpleDocStream ann) | Remove a previously pushed annotation. |
Instances
Maximum number of characters that fit in one line. The layout algorithms
will try not to exceed the set limit by inserting line breaks when applicable
(e.g. via softline'
).
Constructors
AvailablePerLine !Int !Double | Layouters should not exceed the specified space per line.
|
Unbounded | Layouters should not introduce line breaks on their own. |
Instances
Show PageWidth | |
Eq PageWidth | |
Ord PageWidth | |
newtype LayoutOptions #
Options to influence the layout algorithms.
Constructors
LayoutOptions | |
Fields |
Instances
Show LayoutOptions | |
Defined in Prettyprinter.Internal Methods showsPrec :: Int -> LayoutOptions -> ShowS # show :: LayoutOptions -> String # showList :: [LayoutOptions] -> ShowS # | |
Eq LayoutOptions | |
Defined in Prettyprinter.Internal Methods (==) :: LayoutOptions -> LayoutOptions -> Bool # (/=) :: LayoutOptions -> LayoutOptions -> Bool # | |
Ord LayoutOptions | |
Defined in Prettyprinter.Internal Methods compare :: LayoutOptions -> LayoutOptions -> Ordering # (<) :: LayoutOptions -> LayoutOptions -> Bool # (<=) :: LayoutOptions -> LayoutOptions -> Bool # (>) :: LayoutOptions -> LayoutOptions -> Bool # (>=) :: LayoutOptions -> LayoutOptions -> Bool # max :: LayoutOptions -> LayoutOptions -> LayoutOptions # min :: LayoutOptions -> LayoutOptions -> LayoutOptions # |
getClientConfig :: MonadLsp Config m => m Config #
Returns the current client configuration. It is not wise to permanently cache the returned value of this function, as clients can at runtime change their configuration.
toCologActionWithPrio :: forall (m :: Type -> Type) msg. (MonadIO m, HasCallStack) => Recorder (WithPriority msg) -> LogAction m (WithSeverity msg) #
lspClientLogRecorder :: LanguageContextEnv config -> Recorder (WithPriority Text) #
Creates a recorder that sends logs to the LSP client via window/logMessage
notifications.
lspClientMessageRecorder :: LanguageContextEnv config -> Recorder (WithPriority Text) #
Creates a recorder that sends logs to the LSP client via window/showMessage
notifications.
Arguments
:: MonadIO m | |
=> Maybe [LoggingColumn] | built-in logging columns to display. Nothing uses the default |
-> Lock | lock to take when outputting to handle |
-> Handle | handle to output to |
-> m (Recorder (WithPriority (Doc a))) |
Arguments
:: MonadUnliftIO m | |
=> FilePath | Log file path. |
-> Maybe [LoggingColumn] | logging columns to display. |
-> (Either IOException (Recorder (WithPriority (Doc d))) -> m a) | action given a recorder, or the exception if we failed to open the file |
-> m a |
makeDefaultStderrRecorder :: MonadIO m => Maybe [LoggingColumn] -> m (Recorder (WithPriority (Doc a))) #
cmapWithPrio :: (a -> b) -> Recorder (WithPriority b) -> Recorder (WithPriority a) #
logWith :: (HasCallStack, MonadIO m) => Recorder (WithPriority msg) -> Priority -> msg -> m () #
logWarning :: Logger -> Text -> IO () #
Constructors
Debug | Verbose debug logging. |
Info | Useful information in case an error has to be understood. |
Warning | These error messages should not occur in a expected usage, and should be investigated. |
Error | Such log messages must never occur in expected usage. |
Instances
Bounded Priority | |
Enum Priority | |
Read Priority | |
Show Priority | |
Eq Priority | |
Ord Priority | |
Defined in Ide.Logger |
Note that this is logging actions _of the program_, not of the user. You shouldn't call warning/error if the user has caused an error, only if our code has gone wrong and is itself erroneous (e.g. we threw an exception).
Constructors
Logger | |
Fields
|
Instances
data WithPriority a #
Constructors
WithPriority | |
Fields
|
Instances
Functor WithPriority | |
Defined in Ide.Logger Methods fmap :: (a -> b) -> WithPriority a -> WithPriority b # (<$) :: a -> WithPriority b -> WithPriority a # |
Note that this is logging actions _of the program_, not of the user. You shouldn't call warning/error if the user has caused an error, only if our code has gone wrong and is itself erroneous (e.g. we threw an exception).
data LoggingColumn #
Constructors
TimeColumn | |
ThreadIdColumn | |
PriorityColumn | |
DataColumn | |
SourceLocColumn |
renderStrict :: SimpleDocStream ann -> Text #
(
takes the output renderStrict
sdoc)sdoc
from a rendering function
and transforms it to strict text.
data NormalizedUri #
A normalized Uri
.
If you want to use a URI as a map key, use this type. It is important to normalize the percent encoding in the URI since URIs that only differ when it comes to the percent-encoding should be treated as equivalent.
NormalizedUri
has a cached hash in order to make it especially fast in a hash map.
Instances
data Diagnostic #
Represents a diagnostic, such as a compiler error or warning. Diagnostic objects are only valid in the scope of a resource.
Constructors
Diagnostic | |
Fields
|
Instances
data DiagnosticSeverity #
The diagnostic's severity.
Constructors
DiagnosticSeverity_Error | Reports an error. |
DiagnosticSeverity_Warning | Reports a warning. |
DiagnosticSeverity_Information | Reports an information. |
DiagnosticSeverity_Hint | Reports a hint. |
Instances
Represents a location inside a resource, such as a line inside a text file.
Instances
FromJSON Location | |
ToJSON Location | |
Generic Location | |
Show Location | |
NFData Location | |
Eq Location | |
Ord Location | |
Hashable Location | |
Pretty Location | |
HasLocation DiagnosticRelatedInformation Location | |
Defined in Language.LSP.Protocol.Internal.Lens Methods | |
HasLocation SymbolInformation Location | |
Defined in Language.LSP.Protocol.Internal.Lens Methods | |
HasRange Location Range | |
HasUri Location Uri | |
HasLocation InlayHintLabelPart (Maybe Location) | |
Defined in Language.LSP.Protocol.Internal.Lens | |
type Rep Location | |
Defined in Language.LSP.Protocol.Internal.Types.Location type Rep Location = D1 ('MetaData "Location" "Language.LSP.Protocol.Internal.Types.Location" "lsp-types-2.1.0.0-4XLhOyhXn16LNWGw0cjrdM" 'False) (C1 ('MetaCons "Location" 'PrefixI 'True) (S1 ('MetaSel ('Just "_uri") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Uri) :*: S1 ('MetaSel ('Just "_range") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Range))) |
fromNormalizedFilePath :: NormalizedFilePath -> FilePath #
Extracts FilePath
from NormalizedFilePath
.
fromNormalizedUri :: NormalizedUri -> Uri #
toNormalizedUri :: Uri -> NormalizedUri #
The Uri
type in the LSP specification.
Instances
data NormalizedFilePath #
A file path that is already normalized.
The NormalizedUri
is cached to avoided
repeated normalisation when we need to compute them (which is a lot).
This is one of the most performance critical parts of HLS, do not modify it without profiling.
Instances
data GhcVersion Source #
Instances
Show GhcVersion Source # | |
Defined in Development.IDE.GHC.Compat Methods showsPrec :: Int -> GhcVersion -> ShowS # show :: GhcVersion -> String # showList :: [GhcVersion] -> ShowS # | |
Eq GhcVersion Source # | |
Defined in Development.IDE.GHC.Compat | |
Ord GhcVersion Source # | |
Defined in Development.IDE.GHC.Compat Methods compare :: GhcVersion -> GhcVersion -> Ordering # (<) :: GhcVersion -> GhcVersion -> Bool # (<=) :: GhcVersion -> GhcVersion -> Bool # (>) :: GhcVersion -> GhcVersion -> Bool # (>=) :: GhcVersion -> GhcVersion -> Bool # max :: GhcVersion -> GhcVersion -> GhcVersion # min :: GhcVersion -> GhcVersion -> GhcVersion # |
dontWriteHieFiles :: DynFlags -> DynFlags Source #
uriToFilePath' :: Uri -> Maybe FilePath Source #
We use an empty string as a filepath when we don’t have a file. However, haskell-lsp doesn’t support that in uriToFilePath and given that it is not a valid filepath it does not make sense to upstream a fix. So we have our own wrapper here that supports empty filepaths.
showPosition :: Position -> String Source #
readSrcSpan :: ReadS RealSrcSpan Source #
Parser for the GHC output format
type FileDiagnostic = (NormalizedFilePath, ShowDiagnostic, Diagnostic) Source #
Human readable diagnostics for a specific file.
This type packages a pretty printed, human readable error message along with the related source location so that we can display the error on either the console or in the IDE at the right source location.
data ShowDiagnostic Source #
Defines whether a particular diagnostic should be reported back to the user.
One important use case is "missing signature" code lenses, for which we need to enable the corresponding warning during type checking. However, we do not want to show the warning unless the programmer asks for it (#261).
Instances
Show ShowDiagnostic Source # | |
Defined in Development.IDE.Types.Diagnostics Methods showsPrec :: Int -> ShowDiagnostic -> ShowS # show :: ShowDiagnostic -> String # showList :: [ShowDiagnostic] -> ShowS # | |
NFData ShowDiagnostic Source # | |
Defined in Development.IDE.Types.Diagnostics Methods rnf :: ShowDiagnostic -> () # | |
Eq ShowDiagnostic Source # | |
Defined in Development.IDE.Types.Diagnostics Methods (==) :: ShowDiagnostic -> ShowDiagnostic -> Bool # (/=) :: ShowDiagnostic -> ShowDiagnostic -> Bool # | |
Ord ShowDiagnostic Source # | |
Defined in Development.IDE.Types.Diagnostics Methods compare :: ShowDiagnostic -> ShowDiagnostic -> Ordering # (<) :: ShowDiagnostic -> ShowDiagnostic -> Bool # (<=) :: ShowDiagnostic -> ShowDiagnostic -> Bool # (>) :: ShowDiagnostic -> ShowDiagnostic -> Bool # (>=) :: ShowDiagnostic -> ShowDiagnostic -> Bool # max :: ShowDiagnostic -> ShowDiagnostic -> ShowDiagnostic # min :: ShowDiagnostic -> ShowDiagnostic -> ShowDiagnostic # |
type IdeResultNoDiagnosticsEarlyCutoff v = (Maybe ByteString, Maybe v) Source #
an IdeResult with a fingerprint
type IdeResult v = ([FileDiagnostic], Maybe v) Source #
The result of an IDE operation. Warnings and errors are in the Diagnostic, and a value is in the Maybe. For operations that throw an error you expect a non-empty list of diagnostics, at least one of which is an error, and a Nothing. For operations that succeed you expect perhaps some warnings and a Just. For operations that depend on other failing operations you may get empty diagnostics and a Nothing, to indicate this phase throws no fresh errors but still failed.
A rule on a file should only return diagnostics for that given file. It should not propagate diagnostic errors through multiple phases.
ideErrorText :: NormalizedFilePath -> Text -> FileDiagnostic Source #
ideErrorWithSource :: Maybe Text -> Maybe DiagnosticSeverity -> a -> Text -> (a, ShowDiagnostic, Diagnostic) Source #
showDiagnostics :: [FileDiagnostic] -> Text Source #
showDiagnosticsColored :: [FileDiagnostic] -> Text Source #
modifyDynFlags :: GhcMonad m => (DynFlags -> DynFlags) -> m () Source #
Used to modify dyn flags in preference to calling setSessionDynFlags
,
since that function also reloads packages (which is very slow).
lookupPackageConfig :: Unit -> HscEnv -> Maybe UnitInfo Source #
Given a Unit
try and find the associated PackageConfig
in the environment.
textToStringBuffer :: Text -> StringBuffer Source #
Convert from the text
package to the GHC
StringBuffer
.
Currently implemented somewhat inefficiently (if it ever comes up in a profile).
moduleImportPath :: NormalizedFilePath -> ModuleName -> Maybe FilePath Source #
Given a module location, and its parse tree, figure out what is the include directory implied by it.
For example, given the file /usr/Test/Foo/Bar.hs
with the module name Foo.Bar
the directory
/usr/Test
should be on the include path to find sibling modules.
readFileUtf8 :: FilePath -> IO Text Source #
Read a UTF8 file, with lenient decoding, so it will never raise a decoding error.
cgGutsToCoreModule :: SafeHaskellMode -> CgGuts -> ModDetails -> CoreModule Source #
Convert from a CgGuts
to a CoreModule
.
fingerprintToBS :: Fingerprint -> ByteString Source #
Convert a Fingerprint
to a ByteString
by copying the byte across.
Will produce an 8 byte unreadable ByteString.
fingerprintFromStringBuffer :: StringBuffer -> IO Fingerprint Source #
Take the Fingerprint
of a StringBuffer
.
fingerprintFromPut :: Put -> IO Fingerprint Source #
hDuplicateTo' :: Handle -> Handle -> IO () Source #
A slightly modified version of hDuplicateTo
from GHC.
Importantly, it avoids the bug listed in https://gitlab.haskell.org/ghc/ghc/merge_requests/2318.
printOutputable :: Outputable a => a -> Text Source #
Print a GHC value in defaultUserStyle
without unique symbols.
It uses showSDocUnsafe
with unsafeGlobalDynFlags
internally.
This is the most common print utility.
It will do something additionally compared to what the Outputable
instance does.
- print with a user-friendly style:
a_a4ME
asa
. - unescape escape sequences of printable unicode characters within a pair of double quotes
getExtensions :: ParsedModule -> [Extension] Source #
diagFromErrMsg :: Text -> DynFlags -> MsgEnvelope DecoratedSDoc -> [FileDiagnostic] Source #
Produce a GHC-style error from a source span and a message.
diagFromErrMsgs :: Text -> DynFlags -> Bag (MsgEnvelope DecoratedSDoc) -> [FileDiagnostic] Source #
srcSpanToFilename :: SrcSpan -> Maybe FilePath Source #
Extract a file name from a GHC SrcSpan (use message for unhelpful ones) FIXME This may not be an _absolute_ file name, needs fixing.
rangeToSrcSpan :: NormalizedFilePath -> Range -> SrcSpan Source #
toDSeverity :: Severity -> Maybe DiagnosticSeverity Source #
Convert a GHC severity to a DAML compiler Severity. Severities below Warning level are dropped (returning Nothing).
diagFromStrings :: Text -> DiagnosticSeverity -> [(SrcSpan, String)] -> [FileDiagnostic] Source #
Produce a bag of GHC-style errors (ErrorMessages
) from the given
(optional) locations and message strings.
diagFromString :: Text -> DiagnosticSeverity -> SrcSpan -> String -> [FileDiagnostic] Source #
Produce a GHC-style error from a source span and a message.
Arguments
:: FastString | file path of span |
-> RealSrcSpan |
creates a span with zero length in the filename of the argument passed
catchSrcErrors :: DynFlags -> Text -> IO a -> IO (Either [FileDiagnostic] a) Source #
Catch the errors thrown by GHC (SourceErrors and compiler-internal exceptions like Panic or InstallationError), and turn them into diagnostics
diagFromGhcException :: Text -> DynFlags -> GhcException -> [FileDiagnostic] Source #
An HscEnv
with equality. Two values are considered equal
if they are created with the same call to newHscEnvEq
or
updateHscEnvEq
.
hscEnvWithImportPaths :: HscEnvEq -> HscEnv Source #
Unwrap the HscEnv
with the original import paths.
Used only for locating imports
data GhcSessionIO Source #
Constructors
GhcSessionIO |
Instances
Generic GhcSessionIO Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep GhcSessionIO :: Type -> Type # | |
Show GhcSessionIO Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> GhcSessionIO -> ShowS # show :: GhcSessionIO -> String # showList :: [GhcSessionIO] -> ShowS # | |
NFData GhcSessionIO Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: GhcSessionIO -> () # | |
Eq GhcSessionIO Source # | |
Defined in Development.IDE.Core.RuleTypes | |
Hashable GhcSessionIO Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GhcSessionIO Source # | |
type RuleResult GhcSessionIO Source # | |
Defined in Development.IDE.Core.RuleTypes |
data IdeGhcSession Source #
Constructors
IdeGhcSession | |
Fields
|
Instances
Show IdeGhcSession Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> IdeGhcSession -> ShowS # show :: IdeGhcSession -> String # showList :: [IdeGhcSession] -> ShowS # | |
NFData IdeGhcSession Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: IdeGhcSession -> () # |
data AddWatchedFile Source #
Constructors
AddWatchedFile |
Instances
Generic AddWatchedFile Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep AddWatchedFile :: Type -> Type # Methods from :: AddWatchedFile -> Rep AddWatchedFile x # to :: Rep AddWatchedFile x -> AddWatchedFile # | |
Show AddWatchedFile Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> AddWatchedFile -> ShowS # show :: AddWatchedFile -> String # showList :: [AddWatchedFile] -> ShowS # | |
NFData AddWatchedFile Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: AddWatchedFile -> () # | |
Eq AddWatchedFile Source # | |
Defined in Development.IDE.Core.RuleTypes Methods (==) :: AddWatchedFile -> AddWatchedFile -> Bool # (/=) :: AddWatchedFile -> AddWatchedFile -> Bool # | |
Hashable AddWatchedFile Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep AddWatchedFile Source # | |
type RuleResult AddWatchedFile Source # | |
Defined in Development.IDE.Core.RuleTypes |
data GetClientSettings Source #
Get the client config stored in the ide state
Constructors
GetClientSettings |
Instances
Generic GetClientSettings Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep GetClientSettings :: Type -> Type # Methods from :: GetClientSettings -> Rep GetClientSettings x # to :: Rep GetClientSettings x -> GetClientSettings # | |
Show GetClientSettings Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> GetClientSettings -> ShowS # show :: GetClientSettings -> String # showList :: [GetClientSettings] -> ShowS # | |
NFData GetClientSettings Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: GetClientSettings -> () # | |
Eq GetClientSettings Source # | |
Defined in Development.IDE.Core.RuleTypes Methods (==) :: GetClientSettings -> GetClientSettings -> Bool # (/=) :: GetClientSettings -> GetClientSettings -> Bool # | |
Hashable GetClientSettings Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GetClientSettings Source # | |
type RuleResult GetClientSettings Source # | |
Defined in Development.IDE.Core.RuleTypes |
data GetModSummary Source #
Constructors
GetModSummary |
Instances
Generic GetModSummary Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep GetModSummary :: Type -> Type # | |
Show GetModSummary Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> GetModSummary -> ShowS # show :: GetModSummary -> String # showList :: [GetModSummary] -> ShowS # | |
NFData GetModSummary Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: GetModSummary -> () # | |
Eq GetModSummary Source # | |
Defined in Development.IDE.Core.RuleTypes Methods (==) :: GetModSummary -> GetModSummary -> Bool # (/=) :: GetModSummary -> GetModSummary -> Bool # | |
Hashable GetModSummary Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GetModSummary Source # | |
type RuleResult GetModSummary Source # | Generate a ModSummary that has enough information to be used to get .hi and .hie files. without needing to parse the entire source |
Defined in Development.IDE.Core.RuleTypes |
data GetModSummaryWithoutTimestamps Source #
Constructors
GetModSummaryWithoutTimestamps |
Instances
data IsFileOfInterest Source #
Constructors
IsFileOfInterest |
Instances
Generic IsFileOfInterest Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep IsFileOfInterest :: Type -> Type # Methods from :: IsFileOfInterest -> Rep IsFileOfInterest x # to :: Rep IsFileOfInterest x -> IsFileOfInterest # | |
Show IsFileOfInterest Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> IsFileOfInterest -> ShowS # show :: IsFileOfInterest -> String # showList :: [IsFileOfInterest] -> ShowS # | |
NFData IsFileOfInterest Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: IsFileOfInterest -> () # | |
Eq IsFileOfInterest Source # | |
Defined in Development.IDE.Core.RuleTypes Methods (==) :: IsFileOfInterest -> IsFileOfInterest -> Bool # (/=) :: IsFileOfInterest -> IsFileOfInterest -> Bool # | |
Hashable IsFileOfInterest Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep IsFileOfInterest Source # | |
type RuleResult IsFileOfInterest Source # | |
Defined in Development.IDE.Core.RuleTypes |
data GetModIface Source #
Constructors
GetModIface |
Instances
Generic GetModIface Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep GetModIface :: Type -> Type # | |
Show GetModIface Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> GetModIface -> ShowS # show :: GetModIface -> String # showList :: [GetModIface] -> ShowS # | |
NFData GetModIface Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: GetModIface -> () # | |
Eq GetModIface Source # | |
Defined in Development.IDE.Core.RuleTypes | |
Hashable GetModIface Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GetModIface Source # | |
type RuleResult GetModIface Source # | Get a module interface details, either from an interface file or a typechecked module |
Defined in Development.IDE.Core.RuleTypes |
data GetModIfaceFromDiskAndIndex Source #
Constructors
GetModIfaceFromDiskAndIndex |
Instances
data GetModIfaceFromDisk Source #
Constructors
GetModIfaceFromDisk |
Instances
newtype GhcSessionDeps Source #
Constructors
GhcSessionDeps_ | |
Fields
|
Bundled Patterns
pattern GhcSessionDeps :: GhcSessionDeps |
Instances
Show GhcSessionDeps Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> GhcSessionDeps -> ShowS # show :: GhcSessionDeps -> String # showList :: [GhcSessionDeps] -> ShowS # | |
NFData GhcSessionDeps Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: GhcSessionDeps -> () # | |
Eq GhcSessionDeps Source # | |
Defined in Development.IDE.Core.RuleTypes Methods (==) :: GhcSessionDeps -> GhcSessionDeps -> Bool # (/=) :: GhcSessionDeps -> GhcSessionDeps -> Bool # | |
Hashable GhcSessionDeps Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type RuleResult GhcSessionDeps Source # | A GHC session preloaded with all the dependencies This rule is also responsible for calling ReportImportCycles for the direct dependencies |
Defined in Development.IDE.Core.RuleTypes |
data GhcSession Source #
Constructors
GhcSession |
Instances
Generic GhcSession Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep GhcSession :: Type -> Type # | |
Show GhcSession Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> GhcSession -> ShowS # show :: GhcSession -> String # showList :: [GhcSession] -> ShowS # | |
NFData GhcSession Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: GhcSession -> () # | |
Eq GhcSession Source # | |
Defined in Development.IDE.Core.RuleTypes | |
Hashable GhcSession Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GhcSession Source # | |
type RuleResult GhcSession Source # | A GHC session that we reuse. |
Defined in Development.IDE.Core.RuleTypes |
data GetBindings Source #
Constructors
GetBindings |
Instances
Generic GetBindings Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep GetBindings :: Type -> Type # | |
Show GetBindings Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> GetBindings -> ShowS # show :: GetBindings -> String # showList :: [GetBindings] -> ShowS # | |
NFData GetBindings Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: GetBindings -> () # | |
Eq GetBindings Source # | |
Defined in Development.IDE.Core.RuleTypes | |
Hashable GetBindings Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GetBindings Source # | |
type RuleResult GetBindings Source # | A IntervalMap telling us what is in scope at each point |
Defined in Development.IDE.Core.RuleTypes |
Constructors
GetHieAst |
Instances
Generic GetHieAst Source # | |
Show GetHieAst Source # | |
NFData GetHieAst Source # | |
Defined in Development.IDE.Core.RuleTypes | |
Eq GetHieAst Source # | |
Hashable GetHieAst Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GetHieAst Source # | |
type RuleResult GetHieAst Source # | The uncompressed HieAST |
Defined in Development.IDE.Core.RuleTypes |
Constructors
GetDocMap |
Instances
Generic GetDocMap Source # | |
Show GetDocMap Source # | |
NFData GetDocMap Source # | |
Defined in Development.IDE.Core.RuleTypes | |
Eq GetDocMap Source # | |
Hashable GetDocMap Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GetDocMap Source # | |
type RuleResult GetDocMap Source # | |
Defined in Development.IDE.Core.RuleTypes |
Constructors
TypeCheck |
Instances
Generic TypeCheck Source # | |
Show TypeCheck Source # | |
NFData TypeCheck Source # | |
Defined in Development.IDE.Core.RuleTypes | |
Eq TypeCheck Source # | |
Hashable TypeCheck Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep TypeCheck Source # | |
type RuleResult TypeCheck Source # | The type checked version of this file, requires TypeCheck+ |
Defined in Development.IDE.Core.RuleTypes |
data ReportImportCycles Source #
Constructors
ReportImportCycles |
Instances
data GetModuleGraph Source #
Constructors
GetModuleGraph |
Instances
Generic GetModuleGraph Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep GetModuleGraph :: Type -> Type # Methods from :: GetModuleGraph -> Rep GetModuleGraph x # to :: Rep GetModuleGraph x -> GetModuleGraph # | |
Show GetModuleGraph Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> GetModuleGraph -> ShowS # show :: GetModuleGraph -> String # showList :: [GetModuleGraph] -> ShowS # | |
NFData GetModuleGraph Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: GetModuleGraph -> () # | |
Eq GetModuleGraph Source # | |
Defined in Development.IDE.Core.RuleTypes Methods (==) :: GetModuleGraph -> GetModuleGraph -> Bool # (/=) :: GetModuleGraph -> GetModuleGraph -> Bool # | |
Hashable GetModuleGraph Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GetModuleGraph Source # | |
type RuleResult GetModuleGraph Source # | |
Defined in Development.IDE.Core.RuleTypes |
data NeedsCompilation Source #
Constructors
NeedsCompilation |
Instances
Generic NeedsCompilation Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep NeedsCompilation :: Type -> Type # Methods from :: NeedsCompilation -> Rep NeedsCompilation x # to :: Rep NeedsCompilation x -> NeedsCompilation # | |
Show NeedsCompilation Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> NeedsCompilation -> ShowS # show :: NeedsCompilation -> String # showList :: [NeedsCompilation] -> ShowS # | |
NFData NeedsCompilation Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: NeedsCompilation -> () # | |
Eq NeedsCompilation Source # | |
Defined in Development.IDE.Core.RuleTypes Methods (==) :: NeedsCompilation -> NeedsCompilation -> Bool # (/=) :: NeedsCompilation -> NeedsCompilation -> Bool # | |
Hashable NeedsCompilation Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep NeedsCompilation Source # | |
type RuleResult NeedsCompilation Source # | Does this module need to be compiled? |
Defined in Development.IDE.Core.RuleTypes |
data GetLocatedImports Source #
Constructors
GetLocatedImports |
Instances
data GetParsedModuleWithComments Source #
Constructors
GetParsedModuleWithComments |
Instances
data GetParsedModule Source #
Constructors
GetParsedModule |
Instances
Generic GetParsedModule Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep GetParsedModule :: Type -> Type # Methods from :: GetParsedModule -> Rep GetParsedModule x # to :: Rep GetParsedModule x -> GetParsedModule # | |
Show GetParsedModule Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> GetParsedModule -> ShowS # show :: GetParsedModule -> String # showList :: [GetParsedModule] -> ShowS # | |
NFData GetParsedModule Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: GetParsedModule -> () # | |
Eq GetParsedModule Source # | |
Defined in Development.IDE.Core.RuleTypes Methods (==) :: GetParsedModule -> GetParsedModule -> Bool # (/=) :: GetParsedModule -> GetParsedModule -> Bool # | |
Hashable GetParsedModule Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GetParsedModule Source # | |
type RuleResult GetParsedModule Source # | The parse tree for the file using GetFileContents |
Defined in Development.IDE.Core.RuleTypes |
data ModSummaryResult Source #
Constructors
ModSummaryResult | |
Fields
|
Instances
Show ModSummaryResult Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> ModSummaryResult -> ShowS # show :: ModSummaryResult -> String # showList :: [ModSummaryResult] -> ShowS # | |
NFData ModSummaryResult Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: ModSummaryResult -> () # |
data IsFileOfInterestResult Source #
Constructors
NotFOI | |
IsFOI FileOfInterestStatus |
Instances
data FileOfInterestStatus Source #
Instances
data GetFileExists Source #
Constructors
GetFileExists |
Instances
Generic GetFileExists Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep GetFileExists :: Type -> Type # | |
Show GetFileExists Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> GetFileExists -> ShowS # show :: GetFileExists -> String # showList :: [GetFileExists] -> ShowS # | |
NFData GetFileExists Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: GetFileExists -> () # | |
Eq GetFileExists Source # | |
Defined in Development.IDE.Core.RuleTypes Methods (==) :: GetFileExists -> GetFileExists -> Bool # (/=) :: GetFileExists -> GetFileExists -> Bool # | |
Hashable GetFileExists Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GetFileExists Source # | |
type RuleResult GetFileExists Source # | |
Defined in Development.IDE.Core.RuleTypes |
data GetFileContents Source #
Constructors
GetFileContents |
Instances
data FileVersion Source #
Either the mtime from disk or an LSP version LSP versions always compare as greater than on disk versions
Constructors
ModificationTime !POSIXTime | |
VFSVersion !Int32 |
Instances
newtype GetModificationTime Source #
Constructors
GetModificationTime_ | |
Fields
|
Instances
data DocAndKindMap Source #
Constructors
DKMap | |
Fields
|
Instances
Show DocAndKindMap Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> DocAndKindMap -> ShowS # show :: DocAndKindMap -> String # showList :: [DocAndKindMap] -> ShowS # | |
NFData DocAndKindMap Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: DocAndKindMap -> () # |
data HieAstResult Source #
Save the uncompressed AST here, we compress it just before writing to disk
Instances
Show HieAstResult Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> HieAstResult -> ShowS # show :: HieAstResult -> String # showList :: [HieAstResult] -> ShowS # | |
NFData HieAstResult Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: HieAstResult -> () # |
data HiFileResult Source #
Constructors
HiFileResult | |
Fields
|
Instances
Show HiFileResult Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> HiFileResult -> ShowS # show :: HiFileResult -> String # showList :: [HiFileResult] -> ShowS # | |
NFData HiFileResult Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: HiFileResult -> () # |
data TcModuleResult Source #
Contains the typechecked module and the OrigNameCache entry for that module.
Constructors
TcModuleResult | |
Fields
|
Instances
Show TcModuleResult Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> TcModuleResult -> ShowS # show :: TcModuleResult -> String # showList :: [TcModuleResult] -> ShowS # | |
NFData TcModuleResult Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: TcModuleResult -> () # |
Constructors
Splices | |
Fields
|
Constructors
ImportMap | |
Fields
|
data GetImportMap Source #
Constructors
GetImportMap |
Instances
Generic GetImportMap Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep GetImportMap :: Type -> Type # | |
Show GetImportMap Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> GetImportMap -> ShowS # show :: GetImportMap -> String # showList :: [GetImportMap] -> ShowS # | |
NFData GetImportMap Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: GetImportMap -> () # | |
Eq GetImportMap Source # | |
Defined in Development.IDE.Core.RuleTypes | |
Hashable GetImportMap Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GetImportMap Source # | |
type RuleResult GetImportMap Source # | |
Defined in Development.IDE.Core.RuleTypes |
data GetLinkable Source #
Constructors
GetLinkable |
Instances
Generic GetLinkable Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep GetLinkable :: Type -> Type # | |
Show GetLinkable Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> GetLinkable -> ShowS # show :: GetLinkable -> String # showList :: [GetLinkable] -> ShowS # | |
NFData GetLinkable Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: GetLinkable -> () # | |
Eq GetLinkable Source # | |
Defined in Development.IDE.Core.RuleTypes | |
Hashable GetLinkable Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GetLinkable Source # | |
type RuleResult GetLinkable Source # | |
Defined in Development.IDE.Core.RuleTypes |
data LinkableResult Source #
Constructors
LinkableResult | |
Fields
|
Instances
Show LinkableResult Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> LinkableResult -> ShowS # show :: LinkableResult -> String # showList :: [LinkableResult] -> ShowS # | |
NFData LinkableResult Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: LinkableResult -> () # |
data GenerateCore Source #
Constructors
GenerateCore |
Instances
Generic GenerateCore Source # | |
Defined in Development.IDE.Core.RuleTypes Associated Types type Rep GenerateCore :: Type -> Type # | |
Show GenerateCore Source # | |
Defined in Development.IDE.Core.RuleTypes Methods showsPrec :: Int -> GenerateCore -> ShowS # show :: GenerateCore -> String # showList :: [GenerateCore] -> ShowS # | |
NFData GenerateCore Source # | |
Defined in Development.IDE.Core.RuleTypes Methods rnf :: GenerateCore -> () # | |
Eq GenerateCore Source # | |
Defined in Development.IDE.Core.RuleTypes | |
Hashable GenerateCore Source # | |
Defined in Development.IDE.Core.RuleTypes | |
type Rep GenerateCore Source # | |
type RuleResult GenerateCore Source # | Convert to Core, requires TypeCheck* |
Defined in Development.IDE.Core.RuleTypes |
data GetKnownTargets Source #
Constructors
GetKnownTargets |
Instances
data LinkableType Source #
Constructors
ObjectLinkable | |
BCOLinkable |
Instances
pattern GetModificationTime :: GetModificationTime Source #
encodeLinkableType :: Maybe LinkableType -> ByteString Source #
Encode the linkable into an ordered bytestring.
This is used to drive an ordered "newness" predicate in the
NeedsCompilation
build rule.
mkHiFileResult :: ModSummary -> ModIface -> ModDetails -> ModuleEnv ByteString -> Maybe (CoreFile, ByteString) -> HiFileResult Source #
vfsVersion :: FileVersion -> Maybe Int32 Source #
awSplicesL :: Lens' Splices [(LHsExpr GhcTc, Serialized)] Source #
Constructors
Rule (k -> NormalizedFilePath -> Action (Maybe ByteString, IdeResult v)) | |
RuleNoDiagnostics (k -> NormalizedFilePath -> Action (Maybe ByteString, Maybe v)) | |
RuleWithCustomNewnessCheck | |
Fields
| |
RuleWithOldValue (k -> NormalizedFilePath -> Value v -> Action (Maybe ByteString, IdeResult v)) |
data FastResult a Source #
A (maybe) stale result now, and an up to date one later
Constructors
FastResult | |
IdeActions are used when we want to return a result immediately, even if it is stale Useful for UI actions like hover, completion where we don't want to block.
Run via runIdeAction
.
Constructors
IdeAction | |
Fields |
Instances
MonadIO IdeAction Source # | |
Defined in Development.IDE.Core.Shake | |
Applicative IdeAction Source # | |
Defined in Development.IDE.Core.Shake | |
Functor IdeAction Source # | |
Monad IdeAction Source # | |
MonadReader ShakeExtras IdeAction Source # | |
Defined in Development.IDE.Core.Shake Methods ask :: IdeAction ShakeExtras # local :: (ShakeExtras -> ShakeExtras) -> IdeAction a -> IdeAction a # reader :: (ShakeExtras -> a) -> IdeAction a # | |
Semigroup a => Semigroup (IdeAction a) Source # | |
data VFSModified Source #
Constructors
VFSUnmodified | |
VFSModified !VFS |
A Shake database plus persistent store. Can be thought of as storing
mappings from (FilePath, k)
to RuleResult k
.
Instances
MonadReader (ReactorChan, IdeState) (ServerM c) Source # | |
Defined in Development.IDE.LSP.Server Methods ask :: ServerM c (ReactorChan, IdeState) # local :: ((ReactorChan, IdeState) -> (ReactorChan, IdeState)) -> ServerM c a -> ServerM c a # reader :: ((ReactorChan, IdeState) -> a) -> ServerM c a # |
type IdeRule k v = (RuleResult k ~ v, ShakeValue k, Show v, Typeable v, NFData v) Source #
data ShakeExtras Source #
Instances
MonadReader ShakeExtras IdeAction Source # | |
Defined in Development.IDE.Core.Shake Methods ask :: IdeAction ShakeExtras # local :: (ShakeExtras -> ShakeExtras) -> IdeAction a -> IdeAction a # reader :: (ShakeExtras -> a) -> IdeAction a # |
getClientConfigAction :: Action Config Source #
Returns the client configuration, creating a build dependency. You should always use this function when accessing client configuration from build rules.
define :: IdeRule k v => Recorder (WithPriority Log) -> (k -> NormalizedFilePath -> Action (IdeResult v)) -> Rules () Source #
Define a new Rule without early cutoff
defineNoDiagnostics :: IdeRule k v => Recorder (WithPriority Log) -> (k -> NormalizedFilePath -> Action (Maybe v)) -> Rules () Source #
use :: IdeRule k v => k -> NormalizedFilePath -> Action (Maybe v) Source #
Request a Rule result if available
useWithStale :: IdeRule k v => k -> NormalizedFilePath -> Action (Maybe (v, PositionMapping)) Source #
Request a Rule result, it not available return the last computed result, if any, which may be stale
useWithStale_ :: IdeRule k v => k -> NormalizedFilePath -> Action (v, PositionMapping) Source #
Request a Rule result, it not available return the last computed result which may be stale.
Throws an BadDependency
exception which is caught by the rule system if
none available.
WARNING: Not suitable for PluginHandlers. Use useWithStaleE
instead.
runIdeAction :: String -> ShakeExtras -> IdeAction a -> IO a Source #
useWithStaleFast :: IdeRule k v => k -> NormalizedFilePath -> IdeAction (Maybe (v, PositionMapping)) Source #
Lookup value in the database and return with the stale value immediately Will queue an action to refresh the value. Might block the first time the rule runs, but never blocks after that.
useWithStaleFast' :: IdeRule k v => k -> NormalizedFilePath -> IdeAction (FastResult v) Source #
Same as useWithStaleFast but lets you wait for an up to date result
useNoFile_ :: IdeRule k v => k -> Action v Source #
uses_ :: (Traversable f, IdeRule k v) => k -> f NormalizedFilePath -> Action (f v) Source #
Plural version of use_
Throws an BadDependency
exception which is caught by the rule system if
none available.
WARNING: Not suitable for PluginHandlers. Use usesE
instead.
uses :: (Traversable f, IdeRule k v) => k -> f NormalizedFilePath -> Action (f (Maybe v)) Source #
Plural version of use
defineEarlyCutoff :: IdeRule k v => Recorder (WithPriority Log) -> RuleBody k v -> Rules () Source #
Define a new Rule with early cutoff
Constructors
Plugin | |
Fields
|
data IdeConfiguration Source #
Lsp client relevant configuration details
Constructors
IdeConfiguration | |
Fields |
Instances
Show IdeConfiguration Source # | |
Defined in Development.IDE.Core.IdeConfiguration Methods showsPrec :: Int -> IdeConfiguration -> ShowS # show :: IdeConfiguration -> String # showList :: [IdeConfiguration] -> ShowS # |
getFileContents :: NormalizedFilePath -> Action (UTCTime, Maybe Text) Source #
Returns the modification time and the contents. For VFS paths, the modification time is the current time.
getFileExists :: NormalizedFilePath -> Action Bool Source #
Returns True if the file exists
getAtPoint :: NormalizedFilePath -> Position -> IdeAction (Maybe (Maybe Range, [Text])) Source #
Try to get hover text for the name under point.
getDefinition :: NormalizedFilePath -> Position -> IdeAction (Maybe [Location]) Source #
Goto Definition.
getTypeDefinition :: NormalizedFilePath -> Position -> IdeAction (Maybe [Location]) Source #
getParsedModule :: NormalizedFilePath -> Action (Maybe ParsedModule) Source #
Parse the contents of a haskell file.
usePropertyAction :: HasProperty s k t r => KeyNameProxy s -> PluginId -> Properties r -> Action (ToHsType t) Source #