怎么能代表空约束?
对于以下文件
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE KindSignatures #-}
import Data.Kind(Type, Constraint)
type Empty = (() :: Type -> Constraint)
main :: IO ()
main = return ()
ghc 8.2.2 答案
constraint.hs:6:15: error:
• Expected kind ‘* -> Constraint’, but ‘()’ has kind ‘*’
• In the type ‘(() :: Type -> Constraint)’
In the type declaration for ‘Empty’
|
6 | type Empty = (() :: Type -> Constraint)
|
我想念什么?
我知道以下解决方案
{-# LANGUAGE FlexibleInstances #-}
class Empty x
instance Empty x
但我想知道为什么 () 不起作用