Acid-State example compiled error. No No instance for (Control.Monad.Reader.Class.MonadReader FailureDb (Query FailureDb))

左心房为你撑大大i 提交于 2019-12-11 06:19:28

问题


I was trying acid example but compile error.

The error message says no instance No instance for MonadState, No instance for MonadReader.

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

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

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

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

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?


回答1:


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

Stack

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.

Cabal-install only

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.



来源:https://stackoverflow.com/questions/52108291/acid-state-example-compiled-error-no-no-instance-for-control-monad-reader-clas

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!