[Haskell-cafe] Why isn't hsc2hs functionality provided by ghc?
Roman Cheplyaka
roma at ro-che.info
Wed Jun 5 09:34:45 CEST 2013
* Jason Dagit <dagitj at gmail.com> [2013-06-04 21:00:25-0700]
> > My preferred solution would be to have ghc/ghci automatically run hsc2hs
> > (support c2hs also?) when necessary. But so long as it's handled
> > automatically, I wouldn't be particularly bothered by the implementation.
>
> How about having a `ghci` command for cabal? Or does the automatic
> requirement really need to be part of ghc to work the way you want?
>
> (BTW, cabal-dev does have a `ghci` command, but I haven't tested to
> see if it does the hsc -> hs conversion.)
I don't think cabal can provide that. Let's say you're inside a 'cabal
ghci' session. If you modify the hsc file and reload it in ghci, you'd
expect to load the updated version — yet cabal hasn't even been called
since 'cabal ghci', and have had no chance to re-generate the hs file.
To answer the subject question — hsc2hs is not a single preprocessor
available. There are also c2hs and greencard, and maybe something else.
It is (or, at least, was) not clear which one should be generally
preferred. Perhaps by now hsc2hs is a clear winner — I don't know.
Another option is to add a generic preprocessor option to GHC, something
like -pgmX cmd. Then, for hsc2hs one would write something like
{-# OPTIONS_GHC -pgmX hsc2hs #-}
This is a better option, IMO.
Roman
More information about the Haskell-Cafe
mailing list