我正在尝试将几个项目转换classy-prelude
为目前。虽然大多数行为对我来说似乎很简单,但(head . head)
在简单的 2D 列表中会出现神秘错误。
考虑以下 GHCi 会话:
Prelude> (head . head) [[1,2],[3,4]]
1
ghci -XNoImplicitPrelude
让我们用and试试这个classy-prelude
:
> import ClassyPrelude
ClassyPrelude> (head . head) [[1,2],[3,4]]
<interactive>:10:1:
Couldn't match type `MinLen (Succ nat1) mono1' with `[[t0]]'
Expected type: [[t0]] -> Element mono0
Actual type: MinLen (Succ nat1) mono1 -> Element mono0
The function `head . head' is applied to one argument,
but its type `MinLen (Succ nat1) mono1 -> Element mono0'
has only one
In the expression: (head . head) [[1, 2], [3, 4]]
In an equation for `it': it = (head . head) [[1, 2], [3, 4]]
我假设 GHC 根本无法正确解析多维列表的类型。有什么办法可以帮助它而不求助于它(Prelude.head . Prelude.head)
?