本文介绍了酸状态示例编译错误.否(Control.Monad.Reader.Class.MonadReader FailureDb(Query FailureDb))没有实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试示例,但编译错误.

I was trying acid example but compile error.

错误消息 no instance No instance No instance for MonadState,没有MonadReader的实例.

这篇文章说是由于两个不同已安装mtl版本.

This article says it is due to two different mtl versions installed.

我正在nixos中使用nix-shell:

And I am using nix-shell in nixos:

ghc-pkg list | grep acid
    acid-state-0.14.3

ghc-pkg list | grep mtl
    mtl-2.2.1
    mtl-2.2.2

但是,如果我在进入nix-shell时不使用酸性状态包装,则会得到:

However, if I don't use acid-state package when I enter nix-shell, I got:

ghc-pkg list | grep mtl
    mtl-2.2.2

这可能意味着酸性状态使用的Mtl版本与Control.Monad.Reader不同.

That probably means acid-state is using different mtl version than Control.Monad.Reader.

但是github中的acid-state的stack.yaml是lts-11.15,其具有mtl-2.2.2.

But acid-state's stack.yaml in github is lts-11.15, which has mtl-2.2.2.

那我应该怎么做才能使它工作呢?

So what should I do to make it work?

推荐答案

在处理GHC的软件包dbs时,堆栈和Cabal-install也有类似的问题,但是可以避免这些问题:

Stack and Cabal-install have similar problems when dealing with GHC's package dbs, but these problems can be avoided:

当我使用Stack时,我不会在nix-shell中运行它,因此nix-shell不能将软件包添加到已包装的GHC命令中,然后Stack会将其视为系统软件包(在Windows中为'global'阴谋术语).我不确定这是否是唯一有效的方法.

When I use Stack, I don't run it in a nix-shell, so that the nix-shell can't add packages to the wrapped GHC command that Stack will then consider to be system packages ('global' in Cabal terminology). I am not sure whether this is the only valid approach though.

在nix-shell中调用Cabal时,应添加以下标志以防止GHC查看错误的包db: cabal configure --package-db = clear --package-db = global .GHC包装器将使Nix管理的依赖项出现在全局"包db中.

When calling Cabal in a nix-shell, you should add these flags to prevent GHC from looking at the wrong package db: cabal configure --package-db=clear --package-db=global. The GHC wrapper will make the Nix-managed dependencies appear in the 'global' package db.

这篇关于酸状态示例编译错误.否(Control.Monad.Reader.Class.MonadReader FailureDb(Query FailureDb))没有实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 21:08