Can I rely on the Template Haskell extension (using -ddump-splices) to generate a valid code?

I wrote a small utility to extend all TH connectors in the Haskell module so that even if TH is not available, I can use the Haskell module. To achieve this, I will -ddump The -splices option is passed to GHC, while compiling the module and capturing the generated code, and then replacing the TH statement in the module with the captured code.

However, it seems that -ddump-splices is not always Generate compilable code. Specifically, it seems that braces are used for layout, but the semicolon is not added in the right place!

This is an example from my test file –

case dispatch_a3Tg pieces0_a3Tf of {
Just f_a3U6
-> f_a3U6
master0_a3T9
sub0_a3Ta
toMaster0_a3Tb
app4040_a3Tc
handler4050_a3Td
method0_a3Te
Nothing -> app4040_a3Tc }

Here it is generated Opening and closing brackets, but not the semicolon required between the two case alternatives. This will cause the following error at compile time-

GHCi, version 7.4.1 : http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking .. . done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main (Test.hs, interpreted )

Test.hs:51 :17: parse error on input `->'
Failed, modules loaded: none.
Prelude>

No, splice dumps are usually invalid code, and it takes a lot of time to convert these into something that is not only compiled but also human-understandable. When investigating various aspects of TYB, this is irritating The source of frustration.

I wrote a small utility to extend all TH connectors in the Haskell module so that even if TH is not available , I can also use the haskell module. To achieve this, I pass the -ddump-splices option to GHC, compile the module and capture the generated code, and then replace the TH statement in the module with the captured code.

However, it seems that -ddump-splices does not always generate compilable code. Specifically, it seems to use curly braces for layout, but does not add a semicolon in the right place!

This is an example from my test file –

case dispatch_a3Tg pieces0_a3Tf of {
Just f_a3U6
-> f_a3U6
master0_a3T9
sub0_a3Ta
toMaster0_a3Tb
app4040_a3Tc
handler4050_a3Td
method0_a3Te
Nothing -> app4040_a3Tc }

Here it is generated Opening and closing brackets, but not the semicolon required between the two case alternatives. This will cause the following error at compile time-

GHCi, version 7.4.1 : http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking .. . done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main (Test.hs, interpreted )

Test.hs:51 :17: parse error on input `->'
Failed, modules loaded: none.
Prelude>

No, splice transfer Storage is usually invalid code, and it takes a lot of time to convert these into something that is not only compiled but also human-understandable. This is the source of frustration when investigating various aspects of TYB.

< /p>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2360 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.