cabal-dev ghci does work with hsc2hs, but only because it doesn't interpret your source.  Rather, cabal-dev ghci loads ghci using the sandbox install of your package, which is less useful for a variety of reasons.

Aside from that detail, I wouldn't gain any benefit from having this feature built in to ghci instead of accessing ghci via cabal (or cabal-dev).  cabal seems like a better location, and it's aware of several preprocessors already.



On Wed, Jun 5, 2013 at 12:00 PM, Jason Dagit <dagitj@gmail.com> wrote:
On Tue, Jun 4, 2013 at 8:45 PM, John Lato <jwlato@gmail.com> wrote:
> On Wed, Jun 5, 2013 at 10:15 AM, Ivan Lazar Miljenovic
> <ivan.miljenovic@gmail.com> wrote:
>>
>> On 5 June 2013 12:02, silly8888 <silly8888@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?
>>
>> Isn't this done automatically when you have files with the .hsc extension?
>
>
> cabal handles this transparently, but not ghc.  It's frustrating when you
> want to develop a project with ghci.
>
> I don't think it's a good idea to merge hsc2hs syntax into Haskell files.
> In particular, it's often useful to inspect the intermediate .hs file
> produced by hsc2hs during development or debugging.  Also it would
> complicate ghc's parser, etc...
>
> 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.)

Jason