or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

ast.mdbuild.mdcli.mdcodegen.mdcorefn.mddocs.mderrors.mdide.mdindex.mdinteractive.mdparser.mdsugar.mdtypes.md
tile.json

ide.mddocs/

IDE Integration

Language server functionality providing completion, type information, case splitting, and incremental rebuilding for comprehensive editor integration.

Capabilities

Core IDE Interface

Main command handling interface for IDE server integration.

-- | Handle IDE command
handleCommand :: IdeEnvironment -> Command -> IO (Either IdeError Success)

-- | Run IDE computation  
runIde :: IdeEnvironment -> Ide a -> IO (Either IdeError a)

-- | IDE environment
data IdeEnvironment = IdeEnvironment
  { ideStateVar :: TVar IdeState
  , ideConfiguration :: IdeConfiguration
  , ideLogger :: Logger
  }

-- | IDE configuration
data IdeConfiguration = IdeConfiguration
  { confOutputPath :: FilePath
  , confLogLevel :: LogLevel
  , confGlobs :: [FilePath]
  , confIgnoreWarnings :: Bool
  , confAddNpmPath :: Bool
  }

Command Types

All supported IDE commands for editor integration.

-- | IDE commands
data Command
  = Load [FilePath]                          -- Load source files
  | Type Text Int Int                        -- Get type at position
  | Complete Text Text Int Int               -- Code completion  
  | CaseSplit Text Int Int WildcardAnns Text -- Case split
  | AddClause Text Int Int                   -- Add clause
  | Import FilePath Text Int Int Text        -- Add import
  | List LoadedModulesFilter                 -- List loaded modules
  | Quit                                     -- Quit server
  | Reset                                    -- Reset server state
  | Pursuit PursuitQuery                     -- Query Pursuit database
  | RebuildFile FilePath                     -- Rebuild single file

-- | Command results
data Success
  = CompletionResult [Completion]
  | TypeResult Text
  | CaseSplitResult Text
  | AddClauseResult Text
  | ImportResult [Import]
  | ListResult [ModuleName]
  | RebuildResult [Either ErrorMessage ExternsFile]
  | PursuitResult [PursuitSearchResult]
  | TextResult Text
  | MultilineTextResult [Text]
  | NoResult

Code Completion

Comprehensive code completion with type information and import suggestions.

-- | Completion item
data Completion = Completion
  { complModule :: Maybe ModuleName
  , complIdentifier :: Text
  , complType :: Maybe Text
  , complLocation :: Maybe SourceSpan
  , complDocumentation :: Maybe Text
  , complKind :: CompletionKind
  , complExportedFrom :: [ModuleName]
  }

-- | Completion kinds
data CompletionKind
  = Value           -- Values and functions
  | Type            -- Types and type constructors
  | Constructor     -- Data constructors
  | Class           -- Type classes
  | Module          -- Modules
  | Keyword         -- Language keywords

-- | Completion filters
data CompletionFilter
  = ExactFilter           -- Exact matches only
  , PrefixFilter Text     -- Prefix matching
  , FlexFilter Text       -- Flexible matching
  , DependencyFilter [ModuleName] -- Filter by dependencies

-- | Get completions at position
getCompletions :: Text -> Text -> Int -> Int -> [CompletionFilter] -> Ide [Completion]

-- | Get available exports from module
getExportsForModule :: ModuleName -> Ide [Completion]

Type Information

Type querying and type hole information.

-- | Get type at cursor position
getTypeAtPosition :: Text -> Int -> Int -> Ide (Maybe Text)

-- | Type information result  
data TypeInfo = TypeInfo
  { tiType :: Text
  , tiRange :: SourceSpan
  , tiConstraints :: [Text]
  , tiKind :: Maybe Text
  }

-- | Get detailed type information
getDetailedTypeInfo :: Text -> Int Int -> Ide (Maybe TypeInfo)

-- | Get type of identifier
getTypeOfIdentifier :: Text -> Ide (Maybe Text)

-- | Type hole suggestions
data TypeHoleSuggestion = TypeHoleSuggestion  
  { thsType :: Text
  , thsText :: Text
  , thsScore :: Int
  }

-- | Get type hole suggestions
getTypeHoleSuggestions :: Text -> Int -> Int -> Ide [TypeHoleSuggestion]

Case Splitting

Automatic case expression generation and pattern completion.

-- | Wildcard annotations for case splitting
data WildcardAnns = WildcardAnns [WildcardData]

-- | Wildcard data
data WildcardData = WildcardData
  { wdName :: Text
  , wdType :: Text
  , wdRange :: SourceSpan
  }

-- | Perform case split at position
caseSplitAtPosition :: Text -> Int -> Int -> WildcardAnns -> Text -> Ide Text

-- | Generate case alternatives for type
generateCaseAlternatives :: SourceType -> Ide [Text]

-- | Add missing patterns to case expression  
addMissingPatterns :: Text -> Int -> Int -> Ide Text

Import Management

Automatic import suggestions and import list management.

-- | Import suggestion
data Import = Import
  { importModule :: ModuleName
  , importType :: ImportType
  , importQualifier :: Maybe ModuleName
  }

-- | Import types
data ImportType
  = ImplicitImport                    -- import Module
  | ExplicitImport [DeclarationRef]   -- import Module (foo, bar)
  | QualifiedImport (Maybe ModuleName) -- import Module as M

-- | Add import for identifier
addImportForIdentifier :: FilePath -> Text -> Int -> Int -> Text -> Ide [Import]

-- | Get import suggestions
getImportSuggestions :: Text -> Ide [Import]

-- | Organize imports
organizeImports :: Text -> Ide Text

-- | Remove unused imports
removeUnusedImports :: Text -> Ide Text

Incremental Rebuilding

Fast rebuilding for IDE workflows with minimal recompilation.

-- | Rebuild file synchronously
rebuildFileSync :: FilePath -> Ide (Either MultipleErrors ExternsFile)

-- | Rebuild file asynchronously
rebuildFileAsync :: FilePath -> Ide ()

-- | Rebuild result
data RebuildResult
  = RebuildSucceeded ExternsFile
  | RebuildFailed MultipleErrors
  | RebuildSkipped Text

-- | Check if file needs rebuilding
fileNeedsRebuild :: FilePath -> Ide Bool

-- | Get rebuild dependencies
getRebuildDependencies :: FilePath -> Ide [FilePath]

-- | Incremental build with change detection
incrementalBuild :: [FilePath] -> Ide [RebuildResult]

Module Loading

Module loading and caching for IDE state management.

-- | Load modules into IDE state
loadModules :: [FilePath] -> Ide ()

-- | Loaded module filter
data LoadedModulesFilter
  = LoadedModulesAll                -- All loaded modules
  | LoadedModulesPrefix Text        -- Modules with name prefix
  | LoadedModulesImportedBy ModuleName -- Modules imported by given module

-- | List loaded modules
listLoadedModules :: LoadedModulesFilter -> Ide [ModuleName]

-- | Get module information
getModuleInfo :: ModuleName -> Ide (Maybe IdeDeclaration)

-- | Unload module
unloadModule :: ModuleName -> Ide ()

-- | Reload all modules
reloadModules :: Ide ()

Source File Analysis

Source file parsing and analysis for IDE features.

-- | Parse source file
parseSourceFile :: FilePath -> Text -> Ide (Either MultipleErrors (Module, [Comment]))

-- | Get source file info
getSourceFileInfo :: FilePath -> Ide (Maybe SourceFileInfo)

-- | Source file information
data SourceFileInfo = SourceFileInfo
  { sfiPath :: FilePath
  , sfiModuleName :: ModuleName
  , sfiImports :: [ImportDeclaration]
  , sfiExports :: [DeclarationRef]
  , sfiDeclarations :: [IdeDeclaration]
  }

-- | Find declaration at position
findDeclarationAtPosition :: FilePath -> Int -> Int -> Ide (Maybe IdeDeclaration)

-- | Get references to identifier
getReferences :: FilePath -> Int -> Int -> Ide [SourceSpan]

Pursuit Integration

Integration with Pursuit package database for external module information.

-- | Pursuit query types
data PursuitQuery
  = PursuitSearchText Text              -- Text search
  | PursuitSearchType Text              -- Type search
  | PursuitSearchPackage Text           -- Package search
  | PursuitSearchModule ModuleName      -- Module search

-- | Pursuit search result
data PursuitSearchResult = PursuitSearchResult
  { psrPackage :: Text
  , psrVersion :: Text  
  , psrModule :: ModuleName
  , psrItem :: Text
  , psrType :: Maybe Text
  , psrURL :: Text
  }

-- | Search Pursuit database
searchPursuit :: PursuitQuery -> Ide [PursuitSearchResult]

-- | Get module documentation from Pursuit
getPursuitModuleDocs :: Text -> ModuleName -> Ide (Maybe Text)

Error Handling

IDE-specific error types and handling.

-- | IDE errors
data IdeError
  = GeneralError Text
  | FileNotFound FilePath
  | ModuleNotFound ModuleName  
  | ParseError MultipleErrors
  | RebuildError MultipleErrors
  | NotLoaded ModuleName
  | PositionOutOfRange Int Int
  | InvalidCommand Text

-- | Convert IDE error to message
ideErrorMessage :: IdeError -> Text

-- | Log IDE error
logIdeError :: IdeError -> Ide ()

-- | Handle IDE errors gracefully
handleIdeError :: Ide a -> Ide (Either IdeError a)

Types

IDE State

-- | IDE server state
data IdeState = IdeState
  { ideStateModules :: M.Map ModuleName IdeModule
  , ideStateEnvironment :: Environment
  , ideStateExterns :: M.Map ModuleName ExternsFile
  , ideStateSourceFiles :: M.Map FilePath SourceFileInfo
  , ideStateLoadedModules :: S.Set ModuleName
  }

-- | IDE module information
data IdeModule = IdeModule
  { ideModuleName :: ModuleName
  , ideModuleFilePath :: FilePath
  , ideModuleSourceTime :: UTCTime
  , ideModuleBuildTime :: Maybe UTCTime
  , ideModuleDeclations :: [IdeDeclaration]
  }

-- | Initialize empty IDE state
emptyIdeState :: IdeState

-- | Update IDE state with new module
updateModule :: ModuleName -> IdeModule -> IdeState -> IdeState

IDE Declarations

-- | IDE declaration with enriched information
data IdeDeclaration = IdeDeclaration
  { ideDeclName :: Text
  , ideDeclKind :: IdeDeclarationKind
  , ideDeclType :: Maybe Text
  , ideDeclModule :: ModuleName
  , ideDeclLocation :: SourceSpan
  , ideDeclDocumentation :: Maybe Text
  }

-- | IDE declaration kinds
data IdeDeclarationKind
  = IdeValue ValueDeclarationKind
  | IdeType
  | IdeTypeConstructor
  | IdeDataConstructor
  | IdeTypeClass
  | IdeTypeClassMember
  | IdeTypeClassInstance

-- | Value declaration kinds
data ValueDeclarationKind
  = ValueDeclaration
  | ExternDeclaration
  | FixityDeclaration

Communication Protocol

-- | IDE command protocol
data CommandProtocol = CommandProtocol
  { cpCommand :: Command
  , cpId :: Maybe Int
  , cpVersion :: Text
  }

-- | IDE response protocol
data ResponseProtocol = ResponseProtocol
  { rpResult :: Either IdeError Success
  , rpId :: Maybe Int
  , rpVersion :: Text
  }

-- | Serialize command to JSON
encodeCommand :: Command -> Value

-- | Deserialize command from JSON
decodeCommand :: Value -> Either String Command

-- | Protocol version
protocolVersion :: Text