GHC 7.4.1的约束种类语法是什么?

时间:2012-02-26 04:31:16

标签: haskell typeclass constraint-kinds

当我尝试编写一个简单的示例时,我收到Constraint不在范围内的错误,

{-# LANGUAGE UndecidableInstances,
            MultiParamTypeClasses,
            KindSignatures,
            Rank2Types,
            ConstraintKinds,
            FlexibleInstances,
            OverlappingInstances,
            TypeFamilies #-}

type family A a :: Constraint

错误是,

> ghci test.hs
[1 of 1] Compiling Main             ( test.hs, interpreted )

test.hs:10:20: Not in scope: type constructor or class `Constraint'
Failed, modules loaded: none.

约束同义词似乎按预期工作,

type ShowOrd a = (Ord a, Show a)

提前致谢。

1 个答案:

答案 0 :(得分:26)

您的错误似乎是由Constraint造成的,不出所料,不在范围内。您需要从GHC.Primfrom GHC.Exts导入。

似乎有点奇怪的是,启用ConstraintKinds并不会自动将其带入范围,就像我在一个7.3.2快照构建中所做的那样,但是你去了。

相关问题