[Haskell-beginners] cabal sandbox add-source + cabal repl (for tracking Idris git version)

Andreas Reuleaux reuleaux at web.de
Mon Jul 14 04:25:27 UTC 2014


Being somehow new to cabal sandboxes, I would expect that sources that I
add with

  cabal sandbox add-source /some/path

are available to me in my local (sandbox aware) cabal repl, this is
however not the case, or at least I haven't figured out how to make this
this work.

I am trying to use Idris as a library - roughly as described in
http://brianmckenna.org/blog/idris_library, (and in particular the
"cabal sandbox add-source..." step, described there) but my question is
really more Haskell and cabal sandbox than Idris related, therefore I am
asking here.

I have successfully installed Idris from git in a sandbox (For
completeness's sake here are the individual steps, including some test
steps with highlight-versions, that are not strictly necessary). I
install only the idris deps via cabal (i.e. from hackage), idris itself
via make from its git sources:
--------------------

(within my dir ~/idr, i.e. creating ~/idr/dev here)
git clone git://github.com/idris-lang/Idris-dev dev
cd dev
cabal sandbox init
cabal update
cabal install highlight-versions

(activate my sandbox with some bash magic, i.e. include
/home/reuleaux/idr/dev/.cabal-sandbox/bin
in my PATH, so that the command highlight-versions is found:)

cabal install --dry-run --only-dependencies idris | highlight-versions

(now the wet run:)
cabal install --only-dependencies idris

make
(which installs idris from its git sources)
I have two more wrappers in my sandbox for that purpose:
(really some bash magic...)

* ghc:
  exec "/usr/bin/ghc" -no-user-package-db -package-db=/home/reuleaux/idr/dev/.cabal-sandbox/x86_64-linux-ghc-7.6.3-packages.conf.d "$@"

* ghc-pkg:
  exec "/usr/bin/ghc-pkg" --no-user-package-db --package-db=/home/reuleaux/idr/dev/.cabal-sandbox/x86_64-linux-ghc-7.6.3-packages.conf.d "$@"

  I know that "cabal sandbox hc-pkg" is the regular wrapper for
  ghc-pkg, but idris make expects a ghc-pkg command (not cabal sandbox hc-pkg)


Now within ~/dev I can e.g. call

* "idris" or 

* cabal repl
  and then

  > :m +Idris.Parser

  i.e. load some idris modules on the repl
--------------------

So far, so good.

Now I would like to track that dev version of idris in a separate
directory / sandbox, I am therefore using "cabal sandbox add-source...":

mkdir ~/foo
cd foo
cabal sandbox init
cabal sandbox add-source ~/idr/dev
cabal update

(I don't mind reinstalling the deps, not sure if this is really
necessary:)

cabal install --only-dependencies idris


I would think that within foo, I should be able to
just do e.g.

cabal repl
> :m +Idris.Parser


(as cabal repl is sandbox aware, as I learned) but nope !?

    Prelude > :m +Idris.Parser

    <no location info>:
        Could not find module `Idris.Parser'
        It is not a module in the current program, or in any known package.
    Prelude >

Well I can see the sources with

    [sb] reuleaux at mirabelle ~/foo $ cabal sandbox list-sources
    Source dependencies registered in the current sandbox
    ('/home/reuleaux/foo/.cabal-sandbox'):

    /home/reuleaux/idr/dev

    To unregister source dependencies, use the 'sandbox delete-source' command.
    [sb] reuleaux at mirabelle ~/foo $

But that's about it. 

Similarly: How would I use these added sources with ghc? Do I have to
use both:

* /home/reuleaux/idr/dev/.cabal-sandbox/x86_64-linux-ghc-7.6.3-packages.conf.d

* and 
  /home/reuleaux/idr/foo/.cabal-sandbox/x86_64-linux-ghc-7.6.3-packages.conf.d

in my -package-db ?


I am happy to give more details of my installation, if
necessary (I am on debian jessie, my cabal is v 1.20)


Thanks in advance.

-Andreas


More information about the Beginners mailing list