问题描述
在评论ghci的新功能时,我希望ghci能够声明类型声明和声明新的ADT类型,但有人告知这确实可行,在搜索后我发现此页面,它告诉了我可以做到
While commenting on new features in ghci I wished that ghci had the ability to declare type declaration and declaring new ADT types, someone informed that it was indeed possible, and after searching I found this page which told me I could do
let numUniques' :: (Eq a) => [a] -> Int; numUniques' = length . nub
显然,相同的语法也适用于模式匹配(例如,让1 = True; 2 = False).
Apparently that same sort of syntax works for pattern matching (ex. let a 1=True;a 2=False).
创建ADT将使它变得几乎完美吗?有谁知道当前是否可行?我应该只制作一个ADT暂存文件并重新加载吗?
Creating ADTs would make it almost perfect? Does anyone know if it is currently possible?Should I just make an ADT scratch file and reload it?
P.S.有人知道是否有任何计划吗?是否有对ghc(i)的功能要求?
P.S. Does anyone know if there are any plans to do so? Are there feature requests for ghc(i)?
我也知道它的开源性,但是我目前还不够聪明,无法攻克ghc(i).
Also I know its open source but I'm not currently smart enough to hack on ghc(i).
推荐答案
否,但是您可以在hbi(较早的解释器)中定义新类型.正在讨论有关通过hack上的ghci库将其带回来的问题.
No, but you could define new types in hbi (an earlier interpreter). There's discussion about bringing this back, via a ghci library on hackage.
这篇关于是否可以在GHCi中定义新的ADT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!