在安装新版本的伊森之后(ghc-pkg list | grep aeson显示伊森-1.4.7.1),我现在有一个以下错误:
RoseTree.hs:17:69: error:
• Overlapping instances for aeson-1.2.1.0:Data.Aeson.Types.ToJSON.RecordToPairs
JSON.Value
(dlist-1.0:Data.DList.Internal.DList
aeson-1.2.1.0:Data.Aeson.Types.Internal.Pair)
JSON.Zero
(M1
S
('MetaSel
('Just "value")
'NoSourceUnpackedness
'NoSourceStrictness
'DecidedLazy)
(Rec0 a))
arising from the 'deriving' clause of a data type declaration
Matching instances:
two instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
(The choice depends on the instantiation of ‘a’
To pick the first instance above, use IncoherentInstances
when compiling the other instance declarations)
• When deriving the instance for (JSON.ToJSON (RoseTree a))
|
17 | deriving (Show, Generic, Functor, JSON.FromJSON, JSON.ToJSON)
| ^^^^^^^^^^^
Failed, one module loaded.我的源码如下:
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE IncoherentInstances #-}
module RoseTree where
import qualified Data.Aeson as JSON
import Data.Maybe
import Data.Monoid
import Data.Tree
import GHC.Generics (Generic)
data RoseTree a = RoseTree { value :: a, children :: [RoseTree a]}
deriving (Show, Generic, Functor, JSON.FromJSON, JSON.ToJSON)如何摆脱这个错误?提前谢谢。
发布于 2021-05-21 01:29:57
事实证明,cabal被早期版本的aeson 1.2.1.0卡住了,通过普通方法修复它没有任何帮助。问题可以通过切换到Nix来解决。
https://stackoverflow.com/questions/67610554
复制相似问题