相关疑难解决方法(0)

什么是"覆盖条件"?

Statemtl中变压器的来源说明:

-- ---------------------------------------------------------------------------
-- 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有关.

haskell functional-dependencies

8
推荐指数
1
解决办法
536
查看次数

覆盖条件失败

我有一段非常简单的代码如下:

{-# 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以允许此操作?或者我如何解决这个问题?谢谢

haskell

2
推荐指数
1
解决办法
497
查看次数

标签 统计

haskell ×2

functional-dependencies ×1