Could not find module ‘Control.Monad.State’ even though mtl is installed

时光总嘲笑我的痴心妄想 提交于 2020-05-13 06:19:12

问题


When I tried loading a module containing import Control.Monad.State I got

Could not find module ‘Control.Monad.State’
Perhaps you meant
  Control.Monad.ST (from base-4.8.2.0)
  Control.Monad.ST.Safe (from base-4.8.2.0)
  Control.Monad.Fix (from base-4.8.2.0)
Use -v to see a list of the files searched for.
Failed, modules loaded: none.

I installed the Haskell Platform, which has cabal and mtl installed.

When I run cabal update and then cabal install mtl:

Resolving dependencies...
All the requested packages are already installed:
mtl-2.2.1
Use --reinstall if you want to reinstall anyway.

I tried the reinstall flag but it just keeps giving me warnings that I will break other packages so I didn't continue.

My ghc --version is version 7.10.3. cabal --version is 1.22.5.0

This is what I got when I ran ghc-pkg list mtl:

WARNING: cache is out of date: Library/Frameworks/GHC.framework/Versions/7.10.3-x86_64/usr/lib/ghc-7.10.3/package.conf.d/package.cache
ghc will see an old view of this package db. Use 'ghc-pkg recache' to fix.
/Library/Frameworks/GHC.framework/Versions/7.10.3-x86_64/usr/lib/ghc-7.10.3/package.conf.d
   mtl-2.2.1

And when I ran ghc-pkg check :

WARNING: cache is out of date: /Library/Frameworks/GHC.framework/Versions/7.10.3-x86_64/usr/lib/ghc-7.10.3/package.conf.d/package.cache
ghc will see an old view of this package db. Use 'ghc-pkg recache' to fix.

And when I ran ghc-pkg recache

ghc-pkg: /Library/Frameworks/GHC.framework/Versions/7.10.3-x86_64/usr/lib/ghc-7.10.3/package.conf.d/package.cache: you don't have permission to modify this file

来源:https://stackoverflow.com/questions/34654081/could-not-find-module-control-monad-state-even-though-mtl-is-installed

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