[Haskell-cafe] Re: Using Cabal during development

2010-02-11 Thread Maurí­cio CA

> Eventually, I think using cabal during development may be
> convenient. The only drawback is that you have to specify each
> dependency and -- above all -- every module each time you add
> one.

When writing bindings-posix, bindings-glib etc., which have lots
of modules, I used a shell script to take all modules under ./src
to .cabal. What it did was: 1) for each subdirectory, create a .hs
file that reimport all modules under that subdirectory; 2) list
all .hs (and, in my case, also .hsc) under ./src and insert then
into .cabal.

I've found that scripts of this kind have been very usefull. They
require you to follow some rules (like, say, all modules with name
mapping to directories are always a reimport of submodules).

> Then, to compile you executable with ghc (because Cabal is
> definitely not convient when you have a lib and an executable in
> the same package): ghc --make --package-conf pkg.conf.d main.hs
>
> Again, should you have better/simpler ways to achieve this, I
> would be glad to know them.

I usually find useful, at first, to build only the executable and
leave the library. When modules get stable enough, I separate
both. Other scripts have been also usefull: one to check
uncommited changes in all packages I'm working in, other to sync
all my local packages with their repos. You could have a single
'b' script you could run like:

b l # build and install your library in local database
b t # build and run your test package executable
b m # update module list in .cabal file for all your packages
etc.

Best,

Maurício

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Using Cabal during development

2010-02-10 Thread Simon Michael
Another great thread. I'm another who uses both make and cabal. I try to automate a lot of things and find a makefile 
easier for quick scripting. Perhaps at some point I'll get by with just cabal. Here's an example:


http://joyful.com/repos/hledger/Makefile

An unusual feature, I think, is the use of the little-known sp tool for auto-recompiling (see "ci" rule). Typically I 
leave make ci running in an emacs shell window, where I can watch the errors as I edit and save source. I don't have 
clickable errors currently, I get by with linum-mode. When I need to explore I'll run ghci in another shell window. 
After reading this thread, I'm going to try using C-c C-l more.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Using Cabal during development

2010-02-09 Thread Jose A. Ortega Ruiz
Johan Tibell  writes:

> It's really unfortunate that this approach doesn't work for .hsc
> files. When writing low level libraries I often have a couple of these
> which forces me out of my nice Emacs workflow into an Emacs + terminal
> + Cabal workflow.

I use the elisp code below to run cabal without leaving emacs, with its
output going into a compilation buffer (so that one can jump to the
errors). C-c c will find the cabal file nearest to the current buffer
and invoke cabal.

HTH,
jao

--8<---cut here---start->8---

(defun jao-locate-dominating-files (regexp &optional file)
 "Look up the directory hierarchy from FILE for a file matching REGEXP.
 Stop at the first parent where a matching file is found and return the
 list
 of files that that match in this directory."
 (catch 'found
   (let ((dir (file-name-as-directory (or file (buffer-file-name
 files)
 (while (and dir
 (not (string-match locate-dominating-stop-dir-regexp
dir)))
   (if (setq files (condition-case nil
   (directory-files dir 'full regexp 'nosort)
 (error nil)))
   (throw 'found files)
 (if (equal dir
(setq dir (file-name-directory
   (directory-file-name dir
 (setq dir nil
 nil)))

(defun jao-haskell-locate-cabal-file ()
 "Find the cabal file associated with current buffer."
 (car (jao-locate-dominating-files ".+\\.cabal")))

(eval-after-load 'haskell-mode
 '(add-hook 'haskell-mode-hook
(lambda ()
  (set (make-local-variable 'compile-command) "cabal
 build"

(defun jao-haskell-cabal-build ()
 "Run, in a compilation buffer, a cabal command, after finding
the cabal file associated with this buffer."
 (interactive)
 (let ((cabal-file (jao-haskell-locate-cabal-file)))
   (unless cabal-file
 (error "Couldn't find associated cabal file"))
   (let ((default-directory (file-name-directory cabal-file)))
 (call-interactively 'compile

(eval-after-load 'haskell-mode
  '(define-key haskell-mode-map [?\C-c ?c] 'jao-haskell-cabal-build))

--8<---cut here---end--->8---

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe