XIncoherentInstances不起作用

我一直在使用语法库(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知识不够,无法写出我自己的例子。

链接地址: http://www.djcxy.com/p/43255.html

上一篇: XIncoherentInstances doesn't work

下一篇: How can I extract this polymorphic recursion function?