Trying to install "Craft3e" from Hackage using stack

I'm currently reading "Haskell: the Craft of Functional Programming", by Simon Thompson and I'm trying to download and install the package books code. But when I run "stack build Craft3e" I get the following error message:
Run from outside a project, using implicit global project config Using resolver: lts-5.12 from implicit global project's config file: > /home/dumbl3d0re/.stack/global-project/stack.yaml While constructing the BuildPlan the following exceptions were encountered:
-- Failure when adding dependencies: HUnit: needed (==1.2.*), 1.3.1.1 found (latest applicable is 1.2.5.2) mtl: needed (>=1.1 && <2.2), 2.2.1 found (latest applicable is 2.1.3.1) needed for package Craft3e-0.1.0.10
How should I go about to install "Craft3e"? Thanks in advance! Regards, Albin

Assuming that you would keep any book-related code in a local project, here's how you'd create a local project with a dependency on Craft3e: # Create a new project using ghc-7.8 (due to Craft3e's dependency on mtl <2.2) $ stack --resolver ghc-7.8 new craft $ cd craft # Edit the library section of craft.cabal to contain a dependency on Craft3e: # # build-depends: base >= 4.7 && < 5 # , Craft3e # # Calculate a consistent set of packages to use in the project: $ stack solver --update-config Now you can write exercises etc. as library modules in the src directory and use them interactively with stack repl. If you haven't used stack before, you might also want to take a look at the stack guide: http://docs.haskellstack.org/en/stable/GUIDE/ Cheers, Simon

On 2016-04-16 02:36, Simon Jakobi wrote:
Assuming that you would keep any book-related code in a local project, here's how you'd create a local project with a dependency on Craft3e:
# Create a new project using ghc-7.8 (due to Craft3e's dependency on mtl <2.2) $ stack --resolver ghc-7.8 new craft $ cd craft # Edit the library section of craft.cabal to contain a dependency on Craft3e: # # build-depends: base >= 4.7 && < 5 # , Craft3e # # Calculate a consistent set of packages to use in the project: $ stack solver --update-config
Now you can write exercises etc. as library modules in the src directory and use them interactively with stack repl.
If you haven't used stack before, you might also want to take a look at the stack guide: http://docs.haskellstack.org/en/stable/GUIDE/
Cheers, Simon
I don't know if it's possible with the method you described, but I need to be able to import some files into GHCi. They contain function definitions that I have to be able to use in GHCi. Regards, Albin

I don't know if it's possible with the method you described, but I need to be able to import some files into GHCi. They contain function definitions that I have to be able to use in GHCi.
Sorry, I should have taken a look at the package description before writing a response. That should work: $ stack unpack Craft3e $ cd Craft3e-0.1.0.10 $ stack init $ stack build You can then use stack ghci (stack's wrapper around ghci) and λ> import Chapter1 -- for example Cheers, Simon

On 2016-04-16 16:15, Simon Jakobi wrote:
I don't know if it's possible with the method you described, but I need to be able to import some files into GHCi. They contain function definitions that I have to be able to use in GHCi.
Sorry, I should have taken a look at the package description before writing a response. That should work:
$ stack unpack Craft3e $ cd Craft3e-0.1.0.10 $ stack init $ stack build
You can then use stack ghci (stack's wrapper around ghci) and
λ> import Chapter1 -- for example
Cheers, Simon _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Thank, it works! For ev. readers with the same problem: Do note that you have to use `stack exec ghci [file]` for it to work. Regards, Albin
participants (2)
-
Albin Otterhäll
-
Simon Jakobi