In Template Haskell, the Q
monad is where all the magic happens. However, Q
has a pretty limited API. I would like to have a value of type valueNameStore :: Q (String -> Maybe Name)
which basically captures the functionality lookupValueName :: String -> Q (Maybe Name)
but with the store of variables available at the moment it is bound.
I think this is theoretically sound: I shouldn't need to sequence my lookups if I am performing them with respect to a shared constant state that is a snapshot of the state of Q
when I initially called bind on valueNameStore
.
If this isn't possible, is there any way of forcing it through in an unsafe way? I am willing to lower myself to whatever hacks involving unsafePerformIO
...