默认约束种类被忽略

Bor*_*ris 9 haskell default type-constraints

定义默认约束时遇到了一个奇怪的问题.如果约束是单位,则不选择默认实例.在所有其他情况下,它按预期工作.

{-# LANGUAGE TypeFamilies, ConstraintKinds #-}
import qualified GHC.Exts as E

class Expression a where
  type Constr a v :: E.Constraint
  --type Constr a v = ()         -- with this line compilation fails
  --type Constr a v = v ~ v      -- compiles
  wrap :: Constr a v => a -> Maybe v

instance Expression () where
  wrap () = Just undefined

main = print (wrap () :: Maybe Int)
Run Code Online (Sandbox Code Playgroud)

有人可以澄清类型检测器行为的原因吗?

Ant*_*ony 4

这是 7.4.1 中与相关类型默认值相关的错误。几周前,我在 #haskell 上被告知这是一个已知的错误,已被修复,但我在 GHC trac 上找不到提及它。