What's the constraint kinds syntax for GHC 7.4.1?
Asked Answered
H

1

20

I'm getting an error that Constraint is not in scope, when I try to write a simple example,

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

type family A a :: Constraint

The error is,

> 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.

Constraint synonyms seem to work as expected,

type ShowOrd a = (Ord a, Show a)

Thanks in advance.

Hamachi answered 26/2, 2012 at 4:31 Comment(0)
N
26

Your error appears to be caused by Constraint being, unsurprisingly, not in scope. You'll want to import it from GHC.Prim or from GHC.Exts.

It seems a bit odd that enabling ConstraintKinds doesn't bring it into scope automatically, as it does in a 7.3.2 snapshot build I had lying around, but there you go.

Nausea answered 26/2, 2012 at 5:22 Comment(1)
Is there an official place to import it from instead of GHC.Prim. One that might allow it to work on other compilers that support those extensions.Geanticline

© 2022 - 2024 — McMap. All rights reserved.