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 ^>=
   , 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/ manually?

I have GHCi 8.10.7, cabal version 2.0 on Fedora.

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

1 Like

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.