diff --git a/happy-meta.cabal b/happy-meta.cabal
--- a/happy-meta.cabal
+++ b/happy-meta.cabal
@@ -1,5 +1,5 @@
 Name:                happy-meta
-Version:             0.2.0.7
+Version:             0.2.0.8
 Synopsis:            Quasi-quoter for Happy parsers
 -- Description:         
 License:             BSD3
@@ -21,7 +21,7 @@
     Text.Happy.Quote
 
   Build-depends:
-      template-haskell >=2.4&&<2.10
+      template-haskell >=2.4&&<2.11
     , haskell-src-meta >=0.5.1.2&&<1.0
     , base >= 4.2 && < 5
     , array, containers
diff --git a/src/ParamRules.hs b/src/ParamRules.hs
--- a/src/ParamRules.hs
+++ b/src/ParamRules.hs
@@ -60,6 +60,7 @@
         build xs' [] _  = err ("Need " ++ show (length xs') ++ " more arguments")
         build _ ts' _   = err (show (length ts') ++ " arguments too many.")
 
+        err :: String -> M2 a
         err m = throwError ("In " ++ inst_name (x,ts) ++ ": " ++ m)
 
 make_rule :: Funs -> Inst -> M2 Rule1
diff --git a/src/ParseMonad.lhs b/src/ParseMonad.lhs
--- a/src/ParseMonad.lhs
+++ b/src/ParseMonad.lhs
@@ -12,6 +12,8 @@
 
 > module ParseMonad where
 
+> import Control.Monad( ap )
+> import Control.Applicative( Applicative(..) )
 
 > data ParseResult a = OkP a | FailP String
 > newtype P a = P (String -> Int -> ParseResult a)
@@ -29,3 +31,11 @@
 >		OkP a -> runP (k a) s l
 >		FailP err -> FailP err
 >	fail s = P $ \ _ _ -> FailP s
+
+
+> instance Functor P where
+>   fmap f a = a >>= (return . f)
+
+> instance Applicative P where
+>   (<*>) = ap
+>   pure = return
diff --git a/src/ProduceCode.lhs b/src/ProduceCode.lhs
--- a/src/ProduceCode.lhs
+++ b/src/ProduceCode.lhs
@@ -7,7 +7,7 @@
 
 
 
-
+> {-#LANGUAGE FlexibleContexts#-}
 
 
 > module ProduceCode (produceParser) where
