-XIncoherentInstances不起作用

时间:2014-04-28 03:59:45

标签: haskell ghc

我一直在搞乱syntactic库(github上的版本2.0),我有一个小例子导致GHC(i)7.6.2抱怨IncoherentInstances

{-# LANGUAGE FlexibleInstances, 
TypeFamilies,
TypeOperators,
OverlappingInstances, 
UndecidableInstances,
GADTs,
FlexibleContexts,
IncoherentInstances #-}

import Data.Syntactic
import Data.Syntactic.Functional

type family FunToAST (dom :: * -> *) f
type instance FunToAST dom (Full a) = ASTF dom a
type instance FunToAST dom (a :-> fi) = ASTF dom a -> FunToAST dom fi

data Let a where
    Let :: Let (a :-> (a -> b) :-> Full b)

share :: (Let :<: dom,
          ApplySym sig fi dom, 
          SyntacticN (Denotation sig) fi, 
          fi ~ FunToAST dom sig)
          => Denotation sig
share = sugarSym Let

精细。我问我为什么需要IncoherentInstances。问题是,当我包含该扩展时,我得到完全相同的错误消息:

Overlapping instances for SyntacticN
                            (Denotation sig)
                            (ASTF sup0 a0 -> ASTF sup0 (a0 -> b0) -> 
                            ASTF sup0 b0)
  arising from a use of `sugarSym'
Matching instances:
  instance [overlap ok] (Syntactic f, Domain f ~ sym,
                         fi ~ AST sym (Full (Internal f))) =>
                        SyntacticN f fi
    -- Defined in `Data.Syntactic.Sugar'
  instance [overlap ok] (Syntactic a, Domain a ~ sym,
                         ia ~ Internal a, SyntacticN f fi) =>
                        SyntacticN (a -> f) (AST sym (Full ia) -> fi)
    -- Defined in `Data.Syntactic.Sugar'
(The choice depends on the instantiation of `sig, sup0, a0, b0'
 To pick the first instance above, use -XIncoherentInstances
 when compiling the other instance declarations)
In the expression: sugarSym Let
In an equation for `share2': share2 = sugarSym Let

我怀疑这个问题实际上与库有关,但我不太了解IncoherentInstances编写我自己的例子。

0 个答案:

没有答案