How to import Control.Lens in Haskell?

Viewed 130

I am new to Haskell. I want to use Control.Lens package. I've read this and applied what it says but I get an error that says:

Resolving dependencies...
cabal-3.6.2.0.exe: Cannot build the executables in the package lens because it
does not contain any executables. Check the .cabal file for the package and
make sure that it properly declares the components that you expect.

when I try to run cabal install lens in the project folder.(I opened terminal in the project folder.)

Any help would be appreciated.

Solution: I've learned that I need to add 'lens' into build-depends part of .cabal file.Then I need to import Control.Lens inside Main.hs . I give my .cabal file as an example:

executable Prelude3
main-is:          Main.hs

-- Modules included in this executable, other than Main.
--other-modules: Basic

-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
build-depends:  containers,lens,microlens,microlens-platform,base ^>=4.14.3.0
hs-source-dirs:   app
default-language: Haskell2010

On the top of the Main.hs I write import Control.Lens. Finally after I run 'cabal build' and cabal run in the terminal necessary packages successfully downlaoaded.

0 Answers
Related