<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Sylvain,<div class=""><br class=""></div><div class="">I think you're after <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/14474" class="">https://gitlab.haskell.org/ghc/ghc/-/issues/14474</a>. There is some real work to do there, but it should be quite possible.</div><div class=""><br class=""></div><div class="">Richard<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Feb 1, 2021, at 4:51 AM, Sylvain Henry <<a href="mailto:sylvain@haskus.fr" class="">sylvain@haskus.fr</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" class="">
<div class=""><p class="">Hi,</p><p class="">I have the following kind of template haskell code:</p>
<pre class="">module Foo where
foo :: String -> Name -> Q [Dec]
foo str name = return []
module Bar where
bar :: String
bar = "whatever"
module FooBar where
import Foo
import Bar
foo bar 'bar</pre><p class="">It works great as in `foo` I can use both bar's Name and bar's
value computed at compile time.</p><p class="">But it's unsafe for my purpose because a user could call: `foo
"fakeBarValue" 'bar`</p><p class="">So the question is: is there a way to write `foo` so that it can
only be used safely?</p><p class=""><br class="">
</p><p class="">If not, I guess it could be possible to add a new kind of quote
to TH, something like:<br class="">
<br class="">
data Named a = Named Name a -- constructor not exported so that
Named values can't be forged by users.<br class="">
<br class="">
[namedValue||bar||] :: Named String -- new quote</p><p class="">What do you think?<br class="">
</p><p class="">Thanks,<br class="">
Sylvain<br class="">
</p>
</div>
_______________________________________________<br class="">Haskell-Cafe mailing list<br class="">To (un)subscribe, modify options or view archives go to:<br class=""><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">Only members subscribed via the mailman list are allowed to post.</div></blockquote></div><br class=""></div></body></html>