Import monad state - haskell

I'm trying to import the monad State.
I did the following command:
:m Control.Monad.State
But the module cannot be found. I'm using GHCi, version 7.0.4:.
Can you give me some hint to fix the problem?
Thank you.

You're missing the mtl package.
You can either install it from Hackage yourself; or install the Haskell Platform, which comes with the necessary libraries.

Related

Haskell Language Server in VS code shows 'could not find module' Error

I have the following imports in my file
import Control.Applicative (Applicative(liftA2))
import Control.Monad ( guard )
import qualified Data.Vector as V
and I get the error that reads could not find module 'Data.Vector'
The module is installed. I have vector in dependencies and the program builds fine. I just can't get rid of the error in VS Code.
What extra installations do I have to do to fix this?
I have tried:
cabal install vector --lib
Have you tried?
cabal install vector --lib

Is there a ghci colon-command to hide a package?

At present I'm using ihaskell to learn about some libraries. IHaskell is still hazardous, and I can not do:
-- This doesn't work: ":ext PackageImports", the kernel hangs
-- This doesn't work: "{-# LANGUAGE PackageImports #-}", the kernel hangs
import Codec.Crypto.RSA.Pure
import qualified "crypto-api" Crypto.Random as CR
import Control.Monad.CryptoRandom
Without "PackageImports", I get an error message:
Ambiguous interface for ‘Crypto.Random’: it was found in multiple packages: crypto-api-0.13.2 cryptonite-0.7
My question is, is there a colon command inside ghci that would allow me to hide the cryptonite package?
Yes.
:set -hide-package cryptonite

Yesod tutorial compile error: Not in scope: ‘runResourceT’

experts
I'm following the Yesod tutorial on fpcomplete (part 3) https://www.fpcomplete.com/school/advanced-haskell/building-a-file-hosting-service-in-yesod/part%203, but got stuck.
When I compile the project, got this error: Handler/Home.hs:29:26: Not in scope: ‘runResourceT’
I'm using GHC 7.8 and the Stackage build: http://www.stackage.org/stackage/cd04dd6aad3aa5f097598adc050e4f02e571adbc
Did something changed about runResourceT in 7.8? I'm a newbie to Haskell, and not familar with the libraries.
Thanks a lot in advance!
Regards,
Terry
I think that an older version of Data.Conduit might have exported ResourceT directly, but nowadays you need to import it explicitly with
import Control.Monad.Trans.Resource

How can I use module Control.Monad.Free in Haskell?

I try code in Haskell. I want to use module Control.Monad.Free. I written import Control.Monad.Free in my test.hs. But I have error:
How can I fix this error?
Control.Monad.Free is defined in the free package. You can install it with Cabal:
cabal install free

Haskell Import MissingH

I'm trying to import the Data.String.Utils module in my Haskell code, this is part of the MissingH package. I've installed cabal and used it to acquire MissingH, which is properly installed. However, wehn I try adding
import Data.String.Utils
to my code, WinHugs returns
ERROR file:.\ex.hs - Can't find imported module "Data.String.Utils"
Any feedback?
You already have MissingH installed with Cabal.
Using Cabal packages with WinHugs is hit and miss.
Use ghci and import Data.String.Utils should work.

Resources