As there is no haskell-plattform for the newest Ubuntu 13.04, I only downloaded the GHCi and had no problems until now.
But now I want to work with monads. Importing them with
import Control.Monad.State
for example does not work. The error message:
Could not find module `Control.Monad.State'
Perhaps you meant
Control.Monad.ST (from base)
Control.Monad.ST.Safe (from base)
Control.Monad.Fix (from base)
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
How can I manually download them, or is there an entirely different problem?
You need to install the library somewhere GHC can find it.
If you haven't installed cabal-install then do that first. Do this one of two ways.
Via OS Packaging:
sudo apt-get install cabal-install
or manually:
wget http://hackage.haskell.org/package/cabal-install-1.18.0.2/cabal-install-1.18.0.2.tar.gz
tar xzf cabal-install-1.18.0.2.tar.gz
cd cabal-install-1.18.0.2
sh ./bootstrap.sh
export PATH=$PATH:$HOME/.cabal/bin
Once you have installed cabal-install then do:
cabal update
cabal install mtl
This is the "Monad Transformer Library" which includes many common monads, such as State, that you see used in examples.
Alternative to all of this is to install the ubuntu packaging of mtl. That said, I don't know any active Haskell developers who use OS packagings of Haskell packages instead of cabal. The ubuntu package is libghc-ghc-mtl-dev:
sudo apt-get install libghc-ghc-mtl-dev
If you're using Stack, you can get the monad transformer library by adding transformers to the dependencies of your package.yml:
executables:
state-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- state
- transformers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With