Search code examples
haskellcaballeksah

Include other files in scope for program


I'm trying to make my first steps into the haskell world and for this I chose to use the leksah IDE. However I'm not sure this is truly leksah specific but guess it might be more of a cabal / build problem.

Now I'm trying to solve 99 Haskell problems and for this I've opened a new workspace and created a new package. This brings me basicaly to something like the following directory structure:

dist/
  +--- (here be dragons... a lot of hopefully unrelated files)
scr/
  +--- Main.hs
  +--- 01_lists.hs   (<- now that's what I want)
99problems.cabal
Setup.lhs

My Main.hs file looks like this:

module Main ( main ) where
main = putStrLn (show (myLast [1,2,3]) )

which blames me, that Not in scope: myLast. I can fix this by writing the definition above the definition for main = putStrLn ... but what I want is to split this into different files and to include the files to my scope.

How is this done?

Guess it has something to do with cabal which leksah is using and I have to include it somehow, like I would do with :load 01_lists.hs in the REPL. I've added the file in leksah under Package -> Extra Files but that alone didn't work out.

My environment is:

  • Fedora 20
  • Haskell-platform 2013.2.0.0 that is
    • leksah 0.12.1.3
    • cabal 1.16.0.2 (that is no cabal repl command which comes in Cabal 1.18 and would most likely help me)

I tend to believe it's an easy configuration problem with cabal. Would anyone be so kind to lend me a hand with this?


Solution

  • Make your 01_lists.hs be Euler01.hs and start with module Euler01. Then in Main.hs, add at the top import Euler01