将堆栈与 lts-9.2(和 singletons-2.1)一起使用,我有这个:
$(singletons [d|
data EventScans
= PassThrough
| SuiteProgress
-- cn :: EventScans -> [Char]
cn PassThrough = "all-events"
cn SuiteProgress = "suite-progress"
|])
我不能给这个函数一个类型签名,推断的类型签名是
cn :: IsString t => EventScans -> t
. AFAIK IsString
不单调。没有
cn
上的类型签名我收到了 Cn
按预期键入家庭。如果我尝试添加类型签名,我会得到:* Expected kind `[Char]', but `"all-events"' has kind `Symbol'
* In the type `"all-events"'
In the type family declaration for `Cn' (haskell-stack-ghc)
这样做的正确方法是什么?
编辑 如果我尝试包含类型签名
cn :: IsString t => EventScans -> t
我收到以下错误:Variable `a_agPb' used as both a kind and a type
Did you intend to use TypeInType? (haskell-stack-ghc)
Not in scope: type constructor or class `SIsString'
Perhaps you meant `IsString' (imported from Data.String) (haskell-stack-ghc)
最佳答案
从我在 github 上打开的相关问题来看,这是因为 IsString
还没有单调。见 https://github.com/goldfirere/singletons/issues/267详情。
关于haskell - 如何提升返回带有单例的字符串的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46834285/