-- ---------------------------------------------------------------------------
-- Instances for other mtl transformers
--
-- All of these instances need UndecidableInstances,
-- because they do not satisfy the coverage condition.
Run Code Online (Sandbox Code Playgroud)
什么是"覆盖条件"?我只能说它与MTPC和fundeps有关.
我有一段非常简单的代码如下:
{-# LANGUAGE
MultiParamTypeClasses,
FunctionalDependencies,
FlexibleInstances,
FlexibleContexts
#-}
class Graph g n e | g -> n e where
nodes :: g -> [n]
edge :: g -> (n,n) -> Maybe e
instance Graph g Int e where
nodes g = []
edge g (n1,n2) = Nothing
Run Code Online (Sandbox Code Playgroud)
我得到一个与Coverage条件相关的错误,其中一个函数依赖项失败了.我是否需要添加-XUndecidableInstances以允许此操作?或者我如何解决这个问题?谢谢