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

Roman Cheplyaka roma at ro-che.info
Wed Jun 5 09:56:14 CEST 2013


* Ivan Lazar Miljenovic <ivan.miljenovic at gmail.com> [2013-06-05 17:47:40+1000]
> 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 #-}

Indeed! I should've read the whole section.

Problem solved, then?

Roman



More information about the Haskell-Cafe mailing list