Qual è la sintassi dei tipi di vincoli per GHC 7.4.1?
-
13-11-2019 - |
Domanda
Sto ricevendo un errore che Constraint
non è in portata, quando provo a scrivere un semplice esempio,
{-# LANGUAGE UndecidableInstances,
MultiParamTypeClasses,
KindSignatures,
Rank2Types,
ConstraintKinds,
FlexibleInstances,
OverlappingInstances,
TypeFamilies #-}
type family A a :: Constraint
L'errore è,
> 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.
I sinonimi del vincolo sembrano funzionare come previsto,
type ShowOrd a = (Ord a, Show a)
Grazie in anticipo.
Soluzione
Il tuo errore sembra essere causato da Constraint
Essere, non sorprende, non nella portata. Ti consigliamo di importarlo da GHC.Prim
o da GHC.Exts
.
Sembra un po 'strano che abilitare ConstraintKinds
Non lo porta automaticamente in portata, come in una build di istantanea 7.3.2 che avevo in giro, ma eccoti.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow