Restricted Template Haskell

Greg Weber greg at gregweber.info
Sat Jan 31 16:33:49 UTC 2015


On Fri, Jan 30, 2015 at 7:05 PM, adam vogt <vogt.adam at gmail.com> wrote:

> Hi Greg,
>
> Perhaps a less-invasive way to implement the -XSafe part of your
> proposal would be to provide a module like:
>
> module Language.Haskell.TH.Safe (
>   module Language.Haskell.TH,
>   reifyWithoutNameG,
>  )  where
> import Language.Haskell.TH hiding (runIO, reify*)
>
> where reifyWithoutNameG is the same as reify, except definitions that
> are out of scope are either missing or modified such that they use
> NameQ instead of NameG for out-of-scope names.
>

Thanks, I added this concept to the wiki.


> That way there is no new syntax needed, and safe TH can be called by
> unsafe TH without any conversions.
>
> I think defining another monad like Q that can do less is too
> inconvenient because you have to disambiguate between Safe.listE and
> Unsafe.listE, or make those functions more polymorphic (which makes
> type errors worse). Another option would be if there were
>

Oh, you are getting into more concrete details now than I have even thought
about!
For the restricted monad route, we might look into a more capable method of
using capabilities that would end up looking like this:

reify :: Name -> Restrict (TH :+: Reify) Info
runIO :: IO a -> Restrict (TH :+: RunIO) a

There are still a lot of details to work out, thanks for getting things
started.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20150131/a6927fe9/attachment.html>


More information about the Glasgow-haskell-users mailing list