diff --git a/src/Text/Lips.hs b/src/Text/Lips.hs
--- a/src/Text/Lips.hs
+++ b/src/Text/Lips.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE UnicodeSyntax #-}
 {-# LANGUAGE DeriveDataTypeable #-}
 {-# LANGUAGE BangPatterns #-}
@@ -5,6 +6,7 @@
 {-# LANGUAGE RecordWildCards #-}
 {-# LANGUAGE Rank2Types #-}
 {-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeOperators #-}
 {-# LANGUAGE DefaultSignatures #-}
 
 -- | Monadic parsing combinator library with attention to locations.
@@ -22,8 +24,10 @@
   ) where
 
 import Data.Typeable (Typeable)
+#if !MIN_VERSION_base(4,8,0)
 import Data.Monoid (Monoid(..))
 import Data.Word (Word)
+#endif
 import Data.String (IsString(..))
 import Data.Text (Text)
 import qualified Data.Text as T
@@ -35,6 +39,9 @@
 import Text.Parser.Char (CharParsing(..))
 import Control.Applicative
 import Control.Monad (MonadPlus(..))
+#if MIN_VERSION_base(4,9,0) && !MIN_VERSION_base(4,13,0)
+import Control.Monad.Fail (MonadFail(..))
+#endif
 import Control.Monad.Trans.Class (MonadTrans(..))
 import Control.Monad.Trans.Identity (IdentityT(..))
 import Control.Monad.Trans.Reader (ReaderT(..))
@@ -203,6 +210,12 @@
                   ParserCont c _ → starveParser (c t)
                   ParserDone r   → r
 
+
+failParser:: String → Parser α 
+failParser msg = Parser $ \_ _ h _ ctx pl nl →
+                   h (Error nl ctx msg) ctx pl nl
+{-# INLINE failParser #-}
+
 instance Functor Parser where
   fmap f (Parser p) = Parser $ \c cc → p (c . f) (cc . f)
 
@@ -227,10 +240,17 @@
   Parser p >>= f = Parser $ \c cc h ch →
     p (\a → runParser (f a) c cc h ch) (\a → runParser (f a) cc cc ch ch) h ch
   {-# INLINE (>>=) #-}
-  fail msg = Parser $ \_ _ h _ ctx pl nl →
-               h (Error nl ctx msg) ctx pl nl
+#if !MIN_VERSION_base(4,13,0)
+  fail = failParser
   {-# INLINE fail #-}
+#endif
 
+#if MIN_VERSION_base(4,9,0)
+instance MonadFail Parser where
+  fail = failParser
+  {-# INLINE fail #-}
+#endif
+
 instance MonadPlus Parser where
   mzero = empty
   {-# INLINE mzero #-}
@@ -262,7 +282,7 @@
                              (\_ → runParser (skipMany p) cc cc ch ch)
                              h ch
   {-# INLINE skipSome #-}
-  unexpected = fail . ("Unexpected " ++)
+  unexpected = failParser . ("Unexpected " ++)
   {-# INLINE unexpected #-}
   notFollowedBy (Parser p) = Parser $ \c _ h _ ctx pl nl ls is si →
     p (\a _ _ _ _ _ si' → h (Error nl ctx ("Unexpected " ++ show a))
diff --git a/text-lips.cabal b/text-lips.cabal
--- a/text-lips.cabal
+++ b/text-lips.cabal
@@ -1,5 +1,5 @@
 Name: text-lips
-Version: 0.1.0.1
+Version: 0.1.0.2
 Category: Text, Parsing
 Stability: experimental
 Synopsis: Monadic parsing combinator library with attention to locations
@@ -18,9 +18,11 @@
 Extra-Source-Files:
   README.md
 
-Tested-With: GHC==7.6.3, GHC==7.8.4, GHC==7.10.3, GHC==8.0.2, GHC==8.2.1
+Tested-With: GHC==7.6.3, GHC==7.8.4, GHC==7.10.3, GHC==8.0.2, GHC==8.2.2,
+             GHC==8.4.4, GHC==8.6.5, GHC==8.8.4, GHC==8.10.7, GHC==9.0.2,
+             GHC==9.2.4, GHC==9.4.2
 
-Cabal-Version: >= 1.6.0
+Cabal-Version: >= 1.10.0
 Build-Type: Simple
 
 Source-Repository head
@@ -28,9 +30,10 @@
   Location: https://github.com/mvv/text-lips.git
 
 Library
+  Default-Language: Haskell2010
   Build-Depends: base >= 4 && < 5
                , text >= 0.10
-               , text-loc >= 0.1
+               , text-loc >= 0.1.1
                , containers >= 0.5
                , parsers >= 0.5
                , transformers >= 0.3
