首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重叠的aeson实例

重叠的aeson实例
EN

Stack Overflow用户
提问于 2021-05-20 04:37:52
回答 1查看 61关注 0票数 2

在安装新版本的伊森之后(ghc-pkg list | grep aeson显示伊森-1.4.7.1),我现在有一个以下错误:

代码语言:javascript
复制
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.

我的源码如下:

代码语言:javascript
复制
{-# 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)

如何摆脱这个错误?提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2021-05-21 01:29:57

事实证明,cabal被早期版本的aeson 1.2.1.0卡住了,通过普通方法修复它没有任何帮助。问题可以通过切换到Nix来解决。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67610554

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档