Hi,
I have the following kind of template haskell code:
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
It works great as in `foo` I can use both bar's Name and bar's value computed at compile time.
But it's unsafe for my purpose because a user could call: `foo "fakeBarValue" 'bar`
So the question is: is there a way to write `foo` so that it can only be used safely?
If not, I guess it could be possible to add a new kind of quote
to TH, something like:
data Named a = Named Name a -- constructor not exported so that
Named values can't be forged by users.
[namedValue||bar||] :: Named String -- new quote
What do you think?
Thanks,
Sylvain