[Haskell-cafe] Re: Template Haskell: exchanging information between 'splicers'

jean-christophe mincke jeanchristophe.mincke at gmail.com
Mon Nov 29 10:04:33 CET 2010


Oleg,

I am using GHC 6.12.3

Here a reproduction:

in the file Template.hs

proc () = runIO $ do runQ [|1+1|]
proc' () = [|1+1|]


In the file Main.hs


i1 = $(proc ())      -- fails at compile time with "Segmentation
fault/access violation in generated code". Maybe is it the expected
behavior, I do not know.
i2 = $(proc' ())     -- sucessfull

i3 = proc() -- sucessful but proc is executed at "runtime"

main = ...

Hope it is clear enough otherwise let me know.

Regards

J-C


On Mon, Nov 29, 2010 at 4:45 AM, <oleg at okmij.org> wrote:

>
> Hello!
>
> > But, please, correct me if I am wrong, in your example, the splicer are
> > executed at run time and not at compile time.
>
> With TH, it becomes a bit difficult to tell what is exactly `compile
> time'. One can say however that when the code is ready to be spliced
> in at the top level, the IO actions in its splices must have been
> completed.
>
> > I have modified your example to make it run at compile time and I get a
> > (compile time) segmentation fault.
>
> As I mentioned, the code was specifically designed to cause something
> like segmentation fault. Sneaking out free variables is definitely the
> bad thing. The principle of exchanging data between splices (using
> runQ/runIO) is valid and could be used for good things, too.
>
> I am wondering though what GHC version and command-line parameters are
> you using? On my system. with GHC 6.10.3, I tried running the original
> and modified code in GHCi and GHC (with and without -O2) and did not
> get segmentation fault. Could you provide more details about your
> system so to reproduce the segfault? I think Simon Peyton-Jones would
> really like to know all that.
>
>        Cheers,
>        Oleg
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20101129/06edea55/attachment.html


More information about the Haskell-Cafe mailing list