
On Fri, Aug 6, 2010 at 6:11 AM, Hamish Mackenzie
On 5 Aug 2010, at 21:12, David Virebayre wrote:
Can you try out this...
~/haskell/test$ cat ~/bin/cabal_quick_init #!/bin/sh
SOURCE_FILE=$1 CABAL_NAME=`basename -s .lhs $SOURCE_FILE` CABAL_NAME=`basename -s .hs $CABAL_NAME` echo Creating Cabal Package $CABAL_NAME echo For file $SOURCE_FILE mkdir $CABAL_NAME.package || exit cd $CABAL_NAME.package || exit cabal init -n -p $CABAL_NAME --is-executable --source-dir=.. || exit sed -e "s/-- *[mM]ain-[iI]s *\:/Main-is:$SOURCE_FILE/" -i "" $CABAL_NAME.cabal || exit
This script doesn't word as-is for me. basename doesn't have a -s option, but that's easily corrected. Then, I couldn't get the sed command to work, so I edited manually the cabal file to modify and uncomment the Main-is line.
This will make a Euler/Euler.cabal file. You can then simply add that .cabal file to your workspace (right click in the Workspace pane).
Actually it makes a Euler.package/Euler.cabal file. Minor detail :)
I'll try to fix "leksah Euler.hs" so it does the following * if the file belongs to an package in the workspace open the file and activate the package * if not ask the user if they want to simply open it or cabalize it
That would be great.
We do plan to fix this in the same way we resolve missing imports. I had a look to see if I could do it when a user cabalizes the source, but "ghc --make -v" does not include the packages automatically loaded in its output. Instead we will need to wait for the error then resolve it when the user presses Ctrl+R.
Continuing on my Euler.hs example, I then created the cabal package with your script. Added the package, then tried to build. ../Euler.hs:1:0: Failed to load interface for `Prelude': It is a member of the hidden package `base'. Perhaps you need to add `base' to the build-depends in your .cabal file. It is a member of the hidden package `base-3.0.3.2'. Perhaps you need to add `base' to the build-depends in your .cabal file. Use -v to see a list of the files searched for. I didn't find a way to automatically fill the dependencies, Ctrl-R doesn't seem to do something. I added base >= 4 using the package editor, then it build. By the way, did I mention you guys are doing an awesome job with leksah ? David.