기본 제약 조건을 정의 할 때 이상한 문제가 발생했습니다. 제한 조건이 단위이면 기본 인스턴스가 선택되지 않습니다. 다른 모든 경우에는 예상대로 작동합니다.기본 제약 조건 종류가 무시됩니다.
{-# 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)
누군가 유형 검사기 동작의 이유를 명확히 할 수 있습니까?
'v' 유형과 연관 유형 매핑이 해결되는 항목이 없기 때문에 추측 하시겠습니까? – ivanm
아마도 : [ConstraintKinds 및 기본 관련 빈 제약 조건] (http://comments.gmane.org/gmane.comp.lang.haskell.glasgow.user/21058) – hammar