Control.Monad.State found in multiple packages haskell

后端 未结 2 778
长发绾君心
长发绾君心 2021-02-01 05:43

While evaluating the line \"import Control.Monad.State\" in a Haskell module, GHC gives me the following error:

Could not find module `Control.Monad         


        
2条回答
  •  梦如初夏
    2021-02-01 06:35

    You have several options. Either:

    • ghc-pkg hide monads-fd. This will cause GHC and GHCi to ignore the presence of the monads-fd by default until you later ghc-pkg expose monads-fd, but software installed by Cabal will still be able to build against it.
    • Use the {-# LANGUAGE PackageImports #-} pragma, and change your import statement to import "mtl" Control.Monad.State.
    • Use Cabal to build your project, and specify mtl in the Build-depends line.

    The first is best for casual hacking, and the last is best for production builds.

    These all assume you want the mtl module and not the monads-fd module; otherwise swap them.

提交回复
热议问题