haskell - 如何设置 GHCi 提示以显示由自定义分隔符分隔的模块?
问题描述
目前这是我的 ghci 提示符的样子:
我想让它看起来像这样:
或者像这样
关于如何做到这一点的任何想法?我的配置(ghci.conf)文件的内容如下所示
:set prompt "\ESC[33m\STX[%s]\ESC[38;5;86m\STX \x03BB > \ESC[0m\STX"
在其中我遵循了以下语法:
解决方案
您可以使用prompt-function
而不是prompt
为提示运行更高级的 Haskell 函数。ghci.conf
这是您的第二个提示的示例:
:{
prompter :: [String] -> Int -> IO String
prompter modules line = return $
concat [ "\ESC[33m\STX["
, Data.List.intercalate ", " modules
, "]\ESC[38;5;86m\STX \x03BB > \ESC[0m\STX"
]
:}
:set prompt-function prompter
或者,对于数字,您可以使用zipWith
:
:{
prompter :: [String] -> Int -> IO String
prompter modules line = return $
concat [ "\ESC[33m\STX["
-- this is the only line that changed
, Data.List.intercalate ", " $ zipWith (\n m -> concat [show n, ".", m]) [1..] modules
, "]\ESC[38;5;86m\STX \x03BB > \ESC[0m\STX"
]
:}
:set prompt-function prompter
我将把它作为编写续行的练习,但它非常相似,只涉及prompt-cont-function
.
推荐阅读
- python - Python 套接字模块错误:WinError 10057
- python - 如何获得与 0 和 1 分类不同的结果,keras
- awk - sed 或 awk:从选定的多行替换 \n
- android - 约束布局使应用程序太慢
- python - 不可排序的类型:NoneType() < NoneType()
- javascript - React Js-看不到html标签内的prop值作为键
- vba - “else without if”在 excel vba 中出现此错误
- javascript - 使用 React 在同一个 Signed Url 上用新图像刷新图像
- opengl - Premiere pro 般的动态渲染效果如何工作?
- java - 执行jsp页面时出现HTML代码