Opened 4 years ago

Last modified 3 years ago

#11377 new feature request

Template Haskell only imports

Reported by: ezyang Owned by:
Priority: low Milestone:
Component: Template Haskell Version: 7.11
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


This is the Template Haskell equivalent of #11244.

It should be possible to use the plugin package database to make a Template Haskell only import; I suggest the syntax import {-# TH_ONLY #-} Foo. Such imports are only allowed to be used in splices, and cannot be quoted (they are not allowed to reside in the final code generated by the splice.)

The reason a user may want to use such an import is that it means that they can declare that a library is necessary when compiling splices, but not necessary when actually linking against it.

There are extra benefits. If a user is compiling the package with the splices with profiling, it ordinarily requires all imports to have been compiled with profiling. This would NOT be necessary for a TH_ONLY import, since we're only ever going to run the imported code in the (non-profiled) compiler, and not in the (profiled) executable.)

Change History (1)

comment:1 Changed 3 years ago by shlevy

With the ultimate goal of supporting TH in cross-compilation, I've got a WIP branch to separate out compile time and runtime code more rigorously at (current WIP commit is on separating out the HPT). This work is temporarily on hold while I get a quick fix working using external-interpreter running on the target, but I hope to get back to it soon as it's clearly the better long-term solution and works for plugins too.

Note: See TracTickets for help on using tickets.