如何在 ghci 提示符下不显示重复的模块
目前,这就是我的GHCI提示的样子:
,我想做到这一点,以便我的提示不显示重复模块,如下所示:
T真的弄清楚了如何。我的配置(ghci.conf)文件的内容如下所示:
:set +m
import qualified IPPrint
import qualified Language.Haskell.HsColour as HsColour
import qualified Language.Haskell.HsColour.Colourise as HsColour
import qualified Language.Haskell.HsColour.Output as HsColour
let myColourPrefs = HsColour.defaultColourPrefs { HsColour.conid = [HsColour.Foreground HsColour.Yellow, HsColour.Bold], HsColour.conop = [HsColour.Foreground HsColour.Yellow], HsColour.string = [HsColour.Foreground HsColour.Green], HsColour.char = [HsColour.Foreground HsColour.Cyan], HsColour.number = [HsColour.Foreground HsColour.Red, HsColour.Bold], HsColour.layout = [HsColour.Foreground HsColour.White], HsColour.keyglyph = [HsColour.Foreground HsColour.White] }
let myPrint = putStrLn . HsColour.hscolour (HsColour.TTYg HsColour.XTerm256Compatible) myColourPrefs False False "" False . IPPrint.pshow
:set -interactive-print=myPrint
:{
prompter :: [String] -> Int -> IO String
prompter modules line = return $
concat [ "\ESC[33m\STX[Module(s): "
-- this is the only line that changed
, Data.List.intercalate ", " $ zipWith (\n m -> concat [show n, ".", m]) [1..] modules
, "]\ESC[0m\STX\n \ESC[38;5;86m\STX\x03BB > \ESC[0m\STX"
]
:}
:set prompt-function prompter
clear = putStr "\ESC[2J\ESC[H"
谢谢您。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过使用
nub
从列表中删除重复元素(请参阅:),我能够从模块列表中删除重复元素,如下所示:为了做代码,代码也必须必须被修改为:
并且由于
nub
是数据的一部分。清单模块,我还必须包括:By using
nub
which removes duplicate elements from a list (see: https://hoogle.haskell.org/?hoogle=nub), I was able to remove duplicate elements from the module list as shown below:In order to do that the code also has to be modified to:
and since
nub
is part of the Data.List module, I had to also include: