diff --git a/Control/Applicative/QQ/ADo.hs b/Control/Applicative/QQ/ADo.hs
--- a/Control/Applicative/QQ/ADo.hs
+++ b/Control/Applicative/QQ/ADo.hs
@@ -167,9 +167,10 @@
 
 -- Uses lookupValueName when available via TH magic, otherwise tries a
 -- best-guess approach (see the caveats section)
--- | Finds a 'TyConI dec' corresponding to the given name, and returns 'dec'
+-- | Given a 'Name' of a value constructor, find the 'TyConI dec' of its
+-- type, and return 'dec'
 findTyCon :: Name -> Q Dec
-findTyCon n = case $maybeLookupValueName of
+findTyCon n = case $(maybeVar "lookupValueName") of
   Just fn -> do
     DataConI _ _ tn _ <- maybe noScope reify =<< fn (show n)
     TyConI dec <- reify tn
diff --git a/Magic.hs b/Magic.hs
new file mode 100644
--- /dev/null
+++ b/Magic.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE TemplateHaskell #-}
+-- This stuff has to be in a separate module because of the stage restriction.
+module Magic where
+
+import Language.Haskell.TH
+
+-- | 'return's 'Just (VarE n)' if 'n' names a variable in scope, or
+-- 'Nothing' if 'n' is not in scope or is not a variable.
+findVar :: Name -> Q (Maybe Exp)
+findVar name = recover (return Nothing) $ do
+  VarI n _ _ _ <- reify name
+  return (Just (VarE n))
+
+-- | Returns a Q Exp which expands to Just lookupValueName if lookupValueName
+-- exists, or Nothing if it doesn't.
+maybeVar :: String -> Q Exp
+maybeVar s = findVar (mkName s) >>= \e -> case e of
+  Nothing -> [| Nothing |]
+  Just expr -> [| Just $(return expr) |]
diff --git a/applicative-quoters.cabal b/applicative-quoters.cabal
--- a/applicative-quoters.cabal
+++ b/applicative-quoters.cabal
@@ -1,7 +1,7 @@
 Cabal-Version: >= 1.6
 
 Name:     applicative-quoters
-Version:  0.1.0.4
+Version:  0.1.0.5
 Category: Language
 Synopsis: Quasiquoters for idiom brackets and an applicative do-notation
 
@@ -23,6 +23,8 @@
   Exposed-modules:
       Control.Applicative.QQ.ADo
       Control.Applicative.QQ.Idiom
+  Other-modules:
+      Magic
 
   Build-depends:
       base >= 4 && < 4.6,
