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

John Lato jwlato at gmail.com
Thu Jun 6 06:44:36 CEST 2013

I agree that preprocessing code shouldn't be hsc2hs specific.  I prefer
c2hs myself.  But hsc2hs is distributed with ghc, which makes it as
official as a good many other parts of "modern Haskell".

I also agree that making cabal-ghci work nicely would be ideal, but I don't
think it can be done without either adding hooks into ghci or wrapping
stdin.  As Roman points out, if you use :r in ghci, cabal-ghci wouldn't
pick up changes in the source file.  Using ghc's support for custom
preprocessors seems like a very straightforward solution: it already
exists, can be used today, and isn't tied to hsc2hs.

Not that this should stop anyone from working on cabal-ghci of course.

On Thu, Jun 6, 2013 at 11:43 AM, Jeremy Shaw <jeremy at n-heptane.com> wrote:

> While hsc2hs is a popular FFI preprocessor, it is not the only one.
> There is also greencard and a few others.
> While hsc2hs can usually get the job done -- it's not clear that it is
> really the best choice. I think the Haskell FFI got to the point that
> it was 'just good enough' and then people lost interest in doing
> anything more. Let's face it -- working on the FFI is just not that
> exciting :)
> So, basically, we are stuck with stuff that is 'good enough' but no so
> great that we want to make it official.
> We can bind to C fairly easily, but for C++, Python, Ruby, Javascript,
> Java, etc, we have never really made much headway.
> I think the efforts to make cabal-ghci work nicely could really be the
> best solution for now. That is more extensible, and makes it easy to
> solve the problem you actually care about (being able to easily
> load/compile .hs files) with out giving priority to any particular FFI
> system.
> - jeremy
> On Tue, Jun 4, 2013 at 9:02 PM, silly8888 <silly8888 at gmail.com> wrote:
> > I was wondering today, why hasn't hsc2hs been merged with ghc so that
> > it would be possible to add a
> >
> > {-# LANGUAGE ForeignFunctionInterface #-}
> >
> > at the top of a source file and then load it with ghci or compile it,
> > without the intermediate step of calling hsc2hs? This would be exactly
> > like the CPP extension. I don't have to call cpp manually. All I have
> > to do is to add {-# LANGUAGE CPP #-} and then ghc will take care of
> > the rest. This would also mean that there would be no need to have a
> > separate file extension. Surely I must not be the first person to have
> > that thought, so there must be a good reason why this hasn't happen
> > yet, but what is it?
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130606/257d6cc7/attachment.htm>

More information about the Haskell-Cafe mailing list