[Haskell-cafe] Why isn't hsc2hs functionality provided by ghc?

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Wed Jun 5 09:47:40 CEST 2013


On 5 June 2013 17:34, Roman Cheplyaka <roma at ro-che.info> wrote:
> * 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 #-}

Isn't this what -pgmF is
for?http://www.haskell.org/ghc/docs/7.6.1/html/users_guide/options-phases.html#replacing-phases

{-# OPTIONS_GHC -F -pgmF hsc2hs #-}

>
> This is a better option, IMO.
>
> Roman



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com



More information about the Haskell-Cafe mailing list