如何正确访问“约束”类型?
How do I access the `Constraint` kind properly?
我正在使用 GHCi 中的 ConstraintKinds
。在链接 post 中,我找到了一个很好的例子:
type NoConstraint = (() :: Constraint)
但我无法让它工作。 GHCi 自由输出 Constraint
种类,不允许我同时使用它。 IE。这是我的完整 GHCi session(我不太确定我知道正确的词;如果有合适的术语,我将不胜感激 reader 的编辑):
GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help
Prelude> :set -XConstraintKinds -XKindSignatures
Prelude> type NoConstraint = (() :: Constraint)
<interactive>:2:28: error:
Not in scope: type constructor or class `Constraint'
Perhaps you meant `NoConstraint' (line 2)
如何正确访问 Constraint
类型?
如docs中所述,Constraint
类需要从Data.Kind
模块导入。请参阅下面我的 GHCi 会话:
Prelude> :set -XConstraintKinds -XKindSignatures
Prelude> type NoConstraint = (() :: Constraint)
<interactive>:2:28: error:
Not in scope: type constructor or class `Constraint'
Perhaps you meant `NoConstraint' (line 2)
Prelude> :m +Data.Kind
Prelude Data.Kind> type NoConstraint = (() :: Constraint)
Prelude Data.Kind>
我正在使用 GHCi 中的 ConstraintKinds
。在链接 post 中,我找到了一个很好的例子:
type NoConstraint = (() :: Constraint)
但我无法让它工作。 GHCi 自由输出 Constraint
种类,不允许我同时使用它。 IE。这是我的完整 GHCi session(我不太确定我知道正确的词;如果有合适的术语,我将不胜感激 reader 的编辑):
GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help
Prelude> :set -XConstraintKinds -XKindSignatures
Prelude> type NoConstraint = (() :: Constraint)
<interactive>:2:28: error:
Not in scope: type constructor or class `Constraint'
Perhaps you meant `NoConstraint' (line 2)
如何正确访问 Constraint
类型?
如docs中所述,Constraint
类需要从Data.Kind
模块导入。请参阅下面我的 GHCi 会话:
Prelude> :set -XConstraintKinds -XKindSignatures
Prelude> type NoConstraint = (() :: Constraint)
<interactive>:2:28: error:
Not in scope: type constructor or class `Constraint'
Perhaps you meant `NoConstraint' (line 2)
Prelude> :m +Data.Kind
Prelude Data.Kind> type NoConstraint = (() :: Constraint)
Prelude Data.Kind>