diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,8 @@
+1.3.1
+=====
+
+- Support GHC 9.8.2
+
 1.3.0
 =====
 
diff --git a/melf.cabal b/melf.cabal
--- a/melf.cabal
+++ b/melf.cabal
@@ -1,11 +1,7 @@
 cabal-version: 1.18
 
--- This file has been generated from package.yaml by hpack version 0.35.2.
---
--- see: https://github.com/sol/hpack
-
 name:           melf
-version:        1.3.0
+version:        1.3.1
 synopsis:       An Elf parser
 description:    Parser for ELF object format
 category:       Data
@@ -18,7 +14,7 @@
 license-file:   LICENSE
 build-type:     Simple
 tested-with:
-    GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.7, GHC == 9.4.4, GHC == 9.6.1
+    GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.8, GHC == 9.4.8, GHC == 9.6.4, GHC == 9.8.2
 extra-doc-files:
     ChangeLog.md
     README.md
@@ -73,12 +69,12 @@
   build-depends:
       base >=4.13 && <5.0
     , binary >=0.8.7 && <0.9
-    , bytestring >=0.10.10 && <0.12
+    , bytestring >=0.10.10 && <0.13
     , exceptions >=0.10.4 && <0.11
     , lens >=5.0.1 && <5.3
     , mtl >=2.2.2 && <2.4
     , prettyprinter >=1.7.0 && <1.8
-    , template-haskell >=2.15 && <2.21
+    , template-haskell >=2.15 && <2.22
   default-language: Haskell2010
 
 executable hobjdump
@@ -93,7 +89,7 @@
     , binary
     , bytestring
     , melf
-    , optparse-applicative >=0.16.1 && <0.18
+    , optparse-applicative >=0.16.1 && <0.19
     , prettyprinter
   default-language: Haskell2010
 
@@ -167,10 +163,10 @@
     , bytestring
     , directory >=1.3.6 && <1.4
     , exceptions
-    , filepath >=1.4.2.1 && <1.5
+    , filepath >=1.4.2.1 && <1.6
     , melf
     , prettyprinter
-    , tasty >=1.4.1 && <1.5
+    , tasty >=1.4.1 && <1.6
     , tasty-golden >=2.3.4 && <2.4
     , tasty-hunit >=0.10.0.3 && <0.11
   default-language: Haskell2010
diff --git a/src/Control/Exception/ChainedException.hs b/src/Control/Exception/ChainedException.hs
--- a/src/Control/Exception/ChainedException.hs
+++ b/src/Control/Exception/ChainedException.hs
@@ -37,8 +37,8 @@
 
 -- | Structure to organize the stack of exceptions with locations
 data ChainedExceptionNext = Null                         -- ^ exception was initiated by @`chainedError`@
-                          | Next SomeException           -- ^ some context was added to @`SomeException`@ by @`addContext`@
-                          | NextChained ChainedException -- ^ some context was added to a @`ChainedException`@ by @`addContext`@
+                          | Next SomeException           -- ^ some context was added to @t`SomeException`@ by @`addContext`@
+                          | NextChained ChainedException -- ^ some context was added to a @t`ChainedException`@ by @`addContext`@
 
 -- | Exception that keeps track of error locations
 data ChainedException = ChainedException
@@ -77,7 +77,7 @@
 
 -- | @\$chainedError@ results in a function of type
 -- \'@chainedError :: MonadThrow m => String -> m a@\'.
--- It throws `ChainedException` with its argument as error description.
+-- It throws t`ChainedException` with its argument as error description.
 chainedError :: Q Exp
 chainedError = withLoc [| chainedErrorX |]
 
@@ -95,7 +95,7 @@
 
 -- | @\$addContext@ results in a function of type
 -- \'@addContext :: MonadCatch m => String -> m a -> m a@\'.
--- It runs the second argument and adds `ChainedException` with its first argument
+-- It runs the second argument and adds t`ChainedException` with its first argument
 -- to the exceptions thrown from that monad.
 addContext :: Q Exp
 addContext = withLoc [| addContextX |]
@@ -109,7 +109,7 @@
 
 -- | @\$maybeAddContext@ results in a function of type
 -- \'@maybeAddContext :: MonadThrow m => String -> Maybe a -> m a@\'.
--- If its second argument is `Nothing`, it throws `ChainedException` with its first argument,
+-- If its second argument is `Nothing`, it throws t`ChainedException` with its first argument,
 -- else it returns the value of `Just`.
 maybeAddContext :: Q Exp
 maybeAddContext = withLoc [| maybeAddContextX |]
@@ -123,7 +123,7 @@
 
 -- | @\$eitherAddContext'@ results in a function of type
 -- \'@eitherAddContext' :: MonadThrow m => Either String a -> m a@\'.
--- If its argument is @`Left` e@, it throws `ChainedException` with @e@ as error description,
+-- If its argument is @`Left` e@, it throws t`ChainedException` with @e@ as error description,
 -- else it returns the value of `Right`.
 eitherAddContext' :: Q Exp
 eitherAddContext' = withLoc [| eitherAddContextX |]
diff --git a/src/Data/Elf/Constants.hs b/src/Data/Elf/Constants.hs
--- a/src/Data/Elf/Constants.hs
+++ b/src/Data/Elf/Constants.hs
@@ -12,6 +12,49 @@
 -- https://stackoverflow.com/questions/10672981/export-template-haskell-generated-definitions
 
 module Data.Elf.Constants (
+    -- $docs
     module Data.Elf.Constants.Data
     ) where
 import Data.Elf.Constants.Data
+
+{- $docs
+
+Constants defined here are declared using Template Haskell,
+so the full documentation is supported only starting from @template-haskell@ version 2.18.
+For the older versions see the sources or the documents describing ELF file format.
+
+Data types, patterns and instances are generated by @mkDeclarations@ TH macros.
+Below is an example of how it works.  The code
+
+@
+$(mkDeclarations BaseWord16 \"TypeName\" \"ValuePrefix\"
+    [ (\"_A\", 0, "Doc strig for ValuePrefix_A")
+    , (\"_B\", 1, "Doc strig for ValuePrefix_B")
+    ])
+@
+
+produces this:
+
+@
+    newtype TypeName = TypeName Word16 deriving (Eq, Ord, Enum, Num, Real, Integral, Bits, FiniteBits)
+
+    instance Show TypeName where
+        show (TypeName 0) = (\"ValuePrefix\" ++ "_A")
+        show (TypeName 1) = (\"ValuePrefix\" ++ "_B")
+        show (TypeName n_a5QI) = (\"TypeName\" ++ (\" \" ++ show n_a5QI))
+
+    pattern ValuePrefix_A :: TypeName
+    pattern ValuePrefix_A = TypeName 0
+
+    pattern ValuePrefix_B :: TypeName
+    pattern ValuePrefix_B = TypeName 1
+
+    instance Binary (Le TypeName) where
+        get = (Le \<$\> (TypeName \<$\> getWord16le))
+        put (Le (TypeName n_a5QK)) = putWord16le n_a5QK
+
+    instance Binary (Be TypeName) where
+        get = (Be \<$\> (TypeName \<$\> getWord16be))
+        put (Be (TypeName n_a5QL)) = putWord16be n_a5QL
+@
+-}
diff --git a/src/Data/Elf/Constants/Data.hs b/src/Data/Elf/Constants/Data.hs
--- a/src/Data/Elf/Constants/Data.hs
+++ b/src/Data/Elf/Constants/Data.hs
@@ -13,48 +13,6 @@
 import Data.Elf.Constants.TH
 import Data.Endian
 
-{- $docs
-
-Constants defined here are declared using Template Haskell,
-so the full documentation is supported only starting from GHC 2.4.x.
-For the older versions see the sources or the documents describing ELF file format.
-
-Data types, patterns and instances are generated by @mkDeclarations@ TH macros.
-Below is an example of how it works.  The code
-
-@
-$(mkDeclarations BaseWord16 \"TypeName\" \"ValuePrefix\"
-    [ (\"_A\", 0, "Doc strig for ValuePrefix_A")
-    , (\"_B\", 1, "Doc strig for ValuePrefix_B")
-    ])
-@
-
-produces this:
-
-@
-    newtype TypeName = TypeName Word16 deriving (Eq, Ord, Enum, Num, Real, Integral, Bits, FiniteBits)
-
-    instance Show TypeName where
-        show (TypeName 0) = (\"ValuePrefix\" ++ "_A")
-        show (TypeName 1) = (\"ValuePrefix\" ++ "_B")
-        show (TypeName n_a5QI) = (\"TypeName\" ++ (\" \" ++ show n_a5QI))
-
-    pattern ValuePrefix_A :: TypeName
-    pattern ValuePrefix_A = TypeName 0
-
-    pattern ValuePrefix_B :: TypeName
-    pattern ValuePrefix_B = TypeName 1
-
-    instance Binary (Le TypeName) where
-        get = (Le \<$\> (TypeName \<$\> getWord16le))
-        put (Le (TypeName n_a5QK)) = putWord16le n_a5QK
-
-    instance Binary (Be TypeName) where
-        get = (Be \<$\> (TypeName \<$\> getWord16be))
-        put (Be (TypeName n_a5QL)) = putWord16be n_a5QL
-@
--}
-
 -- | Operating system and ABI for which the object is prepared
 $(mkDeclarations BaseWord8 "ElfOSABI" "ELFOSABI"
     [ ("_SYSV",         0, "No extensions or unspecified")
diff --git a/src/Data/Internal/Elf.hs b/src/Data/Internal/Elf.hs
--- a/src/Data/Internal/Elf.hs
+++ b/src/Data/Internal/Elf.hs
@@ -79,7 +79,7 @@
     foldMap f (LZip l  (Just c) r) = foldMap f $ LZip l Nothing (c : r)
     foldMap f (LZip l  Nothing  r) = foldMap f $ L.reverse l ++ r
 
--- | `Elf` is a forrest of trees of type `ElfXX`.
+-- | t`Elf` is a forrest of trees of type `ElfXX`.
 -- Trees are composed of `ElfXX` nodes, `ElfSegment` can contain subtrees
 data ElfNodeType = Header | SectionTable | SegmentTable | Section | Segment | RawData | RawAlign
 
@@ -656,8 +656,8 @@
 zeroSection = SectionXX 0 0 0 0 0 0 0 0 0 0
 
 neighbours :: [a] -> (a -> a -> b) -> [b]
-neighbours [] _ = []
-neighbours x  f = fmap (uncurry f) $ L.zip x $ L.tail x
+neighbours          [] _ = []
+neighbours x@(_:xtail) f = fmap (uncurry f) $ L.zip x xtail
 
 -- make string table and indexes for it from a list of strings
 mkStringTable :: [String] -> (BSL.ByteString, [Int64])
