<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body>
<p>Hi Richard,</p>
<p>Thanks for the pointer. It's not exactly what I am after though
because I don't need the RHS (AST) of `bar` in my example but the
result of running it at compile time. I think it should be simpler
than reifying a Name into a TH AST.</p>
<p>I will open a new ticket.<br>
Thanks,<br>
Sylvain<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 01/02/2021 18:06, Richard Eisenberg
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:010f01775e8f20f5-a685a432-6400-4e77-bd69-43669b9e97e9-000000@us-east-2.amazonses.com">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
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="" moz-do-not-send="true">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=""
moz-do-not-send="true">sylvain@haskus.fr</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div 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="" moz-do-not-send="true">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>
</blockquote>
</body>
</html>