Reputation: 9805
I use intero with some file with no project, and my global (or local stack.yaml) is:
~/.stack/global
$ cat stack.yaml
flags: {}
packages: []
extra-deps: []
resolver: lts-8.21
If I stack exec -- ghci
and :l Intero.hs
where Intero.hs
contains:
$ cat Intero.hs
module Intero where
import Control.Lens.Lens
I get:
$ stack exec -- ghci
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /Users/nrolland/.emacs.d/.ghci
Prelude
λ> :l Intero.hs
[1 of 1] Compiling Intero ( Intero.hs, interpreted )
Intero.hs:3:1: error:
Failed to load interface for ‘Control.Lens.Lens’
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
I relaunched with -v:
$ stack exec -- ghci -v
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Glasgow Haskell Compiler, Version 8.0.2, stage 2 booted by GHC version 7.10.3
Using binary package database: /Users/nrolland/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d/package.cache
Using binary package database: /Users/nrolland/.stack/snapshots/x86_64-osx/lts-8.23/8.0.2/pkgdb/package.cache
Using binary package database: /Users/nrolland/Sync/clones/haskGist80/.stack-work/install/x86_64-osx/lts-8.23/8.0.2/pkgdb/package.cache
loading package database /Users/nrolland/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
loading package database /Users/nrolland/.stack/snapshots/x86_64-osx/lts-8.23/8.0.2/pkgdb
loading package database /Users/nrolland/Sync/clones/haskGist80/.stack-work/install/x86_64-osx/lts-8.23/8.0.2/pkgdb
wired-in package ghc-prim mapped to ghc-prim-0.5.0.0
and when loading the Intero.hs
, I get
Intero.hs:3:1: error:
Failed to load interface for ‘Control.Lens.Lens’
Locations searched:
Control/Lens/Lens.hs
Control/Lens/Lens.lhs
Control/Lens/Lens.hsig
Control/Lens/Lens.lhsig
Upsweep partially successful.
*** Deleting temp files:
Deleting:
Failed, modules loaded: none.
loading package database /Users/nrolland/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
loading package database /Users/nrolland/.stack/snapshots/x86_64-osx/lts-8.23/8.0.2/pkgdb
loading package database /Users/nrolland/Sync/clones/haskGist80/.stack-work/install/x86_64-osx/lts-8.23/8.0.2/pkgdb
wired-in package ghc-prim mapped to ghc-prim-0.5.0.0
wired-in package integer-gmp mapped to integer-gmp-1.0.0.1
wired-in package base mapped to base-4.9.1.0
wired-in package rts mapped to rts-1.0
wired-in package template-haskell mapped to template-haskell-2.11.1.0
wired-in package ghc mapped to ghc-8.0.2
wired-in package dph-seq not found.
wired-in package dph-par not found.
But lens is part of lts-8.23, although when I look it up in ghc-pkg
I don't see it
$ stack exec -- ghc-pkg list
/Users/nrolland/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
Cabal-1.24.2.0
array-0.5.1.1
base-4.9.1.0
binary-0.8.3.0
bytestring-0.10.8.1
containers-0.5.7.1
deepseq-1.4.2.0
directory-1.3.0.0
filepath-1.4.1.1
ghc-8.0.2
ghc-boot-8.0.2
ghc-boot-th-8.0.2
ghc-prim-0.5.0.0
ghci-8.0.2
haskeline-0.7.3.0
hoopl-3.10.2.1
hpc-0.6.0.3
integer-gmp-1.0.0.1
pretty-1.1.3.3
process-1.4.3.0
rts-1.0
template-haskell-2.11.1.0
terminfo-0.4.0.2
time-1.6.0.1
transformers-0.5.2.0
unix-2.7.2.1
xhtml-3000.2.1
/Users/nrolland/.stack/snapshots/x86_64-osx/lts-8.23/8.0.2/pkgdb
(no packages)
/Users/nrolland/Sync/clones/haskGist80/.stack-work/install/x86_64-osx/lts-8.23/8.0.2/pkgdb
(no packages)
How can I easily load up modules without creating a full blown project ? It might be easy but I am very confused about how this whole thing works..
Upvotes: 2
Views: 276
Reputation: 15605
Packages have to be installed (downloaded and compiled) before they can be used:
stack install lens
If you are working with a Cabalized project (which can be a good idea even for small things), stack will install dependencies listed in your cabal file so you don't have to install them manually.
In response to your comment: I suppose it would technically be possible to download and install all of (some version of) stackage, but this doesn't seem desirable. It would take an awfully long time and has little benefit over installing packages at need. Besides, I don't know of an automated way to do it. I know some interesting work has been done on "offline hackage" storage but it isn't ready for use.
Upvotes: 1