Importing Micro.Lens.Platform

I learn Haskell from the Practical Haskell book, but I’m stuck with chapter 6’s dependencies. I’m trying to load Chapter06.hs into the ghci.

It writes me:

Could not find module ‘Lens.Micro.Platform'

because of the 9th row.

I’ve created a separate directory, initialized cabal there, copied Chapter06.hs there, and added these packages to the cabal file

build-depends:       base ^>=4.14.3.0
   , mtl
   , containers
   , microlens-mtl
   , microlens
   , microlens-ghc
   , microlens-platform

It may be more then I need. I guess I don’t need all the microlens*, just the microlens-platform, but is it a problem? Should I remove those packages from ~/.cabal/packages/hackage.haskell.org manually?

I have GHCi 8.10.7, cabal version 2.0 on Fedora.

1 Like

You only need microlens-platform. if you want to install it system-wide, type cabal install --lib mictolens-platform.

2 Likes

To load packages from the current cabal project into your ghci, make sure you are starting ghci with cabal repl to make it project-aware, and not running ghci directly, which isn’t. In the same way that you use cabal build rather than invoking ghc.

1 Like