haskell - 有 ghci 缩写命令列表吗?

标签 haskell ghc ghci

document写道,

The command name may be abbreviated, with ambiguities being resolved in favour of the more commonly used commands

但我找不到确切的列表。

我知道其中一些,但我想知道是否有完整的列表。带有 ? 的命令表示制表符补全时有多个建议。

:a -> ?
:b -> ?
:c -> ?
:de -> ?
:e -> :edit
:for -> ?
:h -> :help
:i -> :info
:l -> :load
:m -> :module
:r -> :reload
:s -> :script
:t -> :type
:un -> ?
:where -> undocumented, found by completion, don't know what it is for

最佳答案

我检查了ghc source file ,发现stdin输入是由

处理的
runGHIC -> runGHCiInput -> ghciCompleteWord -> lookupCompletion -> lookupCommand'

lookupCommand结尾

  -- first, look for exact match (while preferring macros); then, look
  -- for first prefix match (preferring builtins), *unless* a macro
  -- overrides the builtin; see #8305 for motivation
  return $ lookupExact str xcmds <|>
           lookupExact str ghci_cmds <|>
           (builtinPfxMatch >>= \c -> lookupExact (cmdName c) xcmds) <|>
           builtinPfxMatch <|>
           lookupPrefix str xcmds

基本上,它首先查找完全匹配,然后按顺序添加前缀匹配。所以对于普通的 :xxx 命令,它遵循 ghci_cmds 顺序,即 availableCommandsGhciSettings 中,即

  ("?",         keepGoing help,                 noCompletion),
  ("add",       keepGoingPaths addModule,       completeFilename),
  ("abandon",   keepGoing abandonCmd,           noCompletion),
  ("break",     keepGoing breakCmd,             completeIdentifier),
  ("back",      keepGoing backCmd,              noCompletion),
  ("browse",    keepGoing' (browseCmd False),   completeModule),
  ("browse!",   keepGoing' (browseCmd True),    completeModule),
  ("cd",        keepGoing' changeDirectory,     completeFilename),
  ("check",     keepGoing' checkModule,         completeHomeModule),
  ("continue",  keepGoing continueCmd,          noCompletion),
  ("cmd",       keepGoing cmdCmd,               completeExpression),
  ("ctags",     keepGoing createCTagsWithLineNumbersCmd, completeFilename),
  ("ctags!",    keepGoing createCTagsWithRegExesCmd, completeFilename),
  ("def",       keepGoing (defineMacro False),  completeExpression),
  ("def!",      keepGoing (defineMacro True),   completeExpression),
  ("delete",    keepGoing deleteCmd,            noCompletion),
  ("edit",      keepGoing' editFile,            completeFilename),
  ("etags",     keepGoing createETagsFileCmd,   completeFilename),
  ("force",     keepGoing forceCmd,             completeExpression),
  ("forward",   keepGoing forwardCmd,           noCompletion),
  ("help",      keepGoing help,                 noCompletion),
  ("history",   keepGoing historyCmd,           noCompletion),
  ("info",      keepGoing' (info False),        completeIdentifier),
  ("info!",     keepGoing' (info True),         completeIdentifier),
  ("issafe",    keepGoing' isSafeCmd,           completeModule),
  ("kind",      keepGoing' (kindOfType False),  completeIdentifier),
  ("kind!",     keepGoing' (kindOfType True),   completeIdentifier),
  ("load",      keepGoingPaths loadModule_,     completeHomeModuleOrFile),
  ("load!",     keepGoingPaths loadModuleDefer, completeHomeModuleOrFile),
  ("list",      keepGoing' listCmd,             noCompletion),
  ("module",    keepGoing moduleCmd,            completeSetModule),
  ("main",      keepGoing runMain,              completeFilename),
  ("print",     keepGoing printCmd,             completeExpression),
  ("quit",      quit,                           noCompletion),
  ("reload",    keepGoing' reloadModule,        noCompletion),
  ("reload!",   keepGoing' reloadModuleDefer,   noCompletion),
  ("run",       keepGoing runRun,               completeFilename),
  ("script",    keepGoing' scriptCmd,           completeFilename),
  ("set",       keepGoing setCmd,               completeSetOptions),
  ("seti",      keepGoing setiCmd,              completeSeti),
  ("show",      keepGoing showCmd,              completeShowOptions),
  ("showi",     keepGoing showiCmd,             completeShowiOptions),
  ("sprint",    keepGoing sprintCmd,            completeExpression),
  ("step",      keepGoing stepCmd,              completeIdentifier),
  ("steplocal", keepGoing stepLocalCmd,         completeIdentifier),
  ("stepmodule",keepGoing stepModuleCmd,        completeIdentifier),
  ("type",      keepGoing' typeOfExpr,          completeExpression),
  ("trace",     keepGoing traceCmd,             completeExpression),
  ("undef",     keepGoing undefineMacro,        completeMacro),
  ("unset",     keepGoing unsetOptions,         completeSetOptions),
  ("where",     keepGoing whereCmd,             noCompletion)

所以:c表示:cd:d表示:def,遵循顺序。

关于haskell - 有 ghci 缩写命令列表吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47265489/

相关文章:

haskell - 为什么我不能用 Haskell 端口号中相同值的变量替换某个值?

haskell - 使用颜色设置 ghci 提示

haskell - 没有 Prelude 的 ghci session

haskell - 为什么类型类难以实现?

haskell - 为什么全新安装的 Haskell-Stack 和 GHC 如此大/大?

haskell - GHC 垃圾收集器/运行时如何知道它可以创建数组 `inplace'

haskell - GHCI 环境转储

performance - GHC 产生冗余核心操作

haskell - Haskell中的嵌套三角形循环?

Haskell - 构造一个使用存在量化的类型