diff --git a/Text/XHtml.hs b/Text/XHtml.hs
index 31ed6d098c513d3b236fb9c57ed68465d5d3109a..d2afe780c02a2c0783bc61bb5fae74b712b51598 100644
--- a/Text/XHtml.hs
+++ b/Text/XHtml.hs
@@ -1,3 +1,7 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Text.XHtml
diff --git a/Text/XHtml/BlockTable.hs b/Text/XHtml/BlockTable.hs
index 1780e52db77f7ae1cf825a9ce6a5e41cd9604ece..4defc72238adc5c0b6263902c468e9899a71b694 100644
--- a/Text/XHtml/BlockTable.hs
+++ b/Text/XHtml/BlockTable.hs
@@ -1,4 +1,6 @@
--- #hide
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
 
 -----------------------------------------------------------------------------
 -- |
diff --git a/Text/XHtml/Debug.hs b/Text/XHtml/Debug.hs
index baa807311321c854d5bd642829734e5591791bba..cfd77d279db987acf835e7507f03689ca07df966 100644
--- a/Text/XHtml/Debug.hs
+++ b/Text/XHtml/Debug.hs
@@ -1,3 +1,9 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
+{-# OPTIONS_HADDOCK hide #-}
+-- #hide
+
 -- | This module contains functions for displaying
 --   HTML as a pretty tree.
 module Text.XHtml.Debug ( HtmlTree(..), treeHtml, treeColors, debugHtml ) where
diff --git a/Text/XHtml/Extras.hs b/Text/XHtml/Extras.hs
index 379b63132d404434cd4f0757edf1c321ffc67a1d..835ca37cac977bb200ad7b7b0c835909f690c03e 100644
--- a/Text/XHtml/Extras.hs
+++ b/Text/XHtml/Extras.hs
@@ -1,4 +1,6 @@
--- #hide
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
 
 module Text.XHtml.Extras where
 
diff --git a/Text/XHtml/Frameset.hs b/Text/XHtml/Frameset.hs
index 22cef1de926ff635b80a8a0ee579510c2526b22c..befc499f3cda681af77793de8eda3f828f1aaf18 100644
--- a/Text/XHtml/Frameset.hs
+++ b/Text/XHtml/Frameset.hs
@@ -1,3 +1,7 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
+
 -- | Produces XHTML 1.0 Frameset.
 module Text.XHtml.Frameset (
      -- * Data types
@@ -50,4 +54,4 @@ renderHtml = renderHtmlInternal docType
 --   The implementation is inefficient, and you are normally
 --   better off using 'showHtml' or 'renderHtml'.
 prettyHtml :: HTML html => html -> String
-prettyHtml = prettyHtmlInternal docType
\ No newline at end of file
+prettyHtml = prettyHtmlInternal docType
diff --git a/Text/XHtml/Frameset/Attributes.hs b/Text/XHtml/Frameset/Attributes.hs
index f55f39429d7e90113239f6ece15e6d2c6d2cbe96..31f7a4843247919929e9783589040cf291390131 100644
--- a/Text/XHtml/Frameset/Attributes.hs
+++ b/Text/XHtml/Frameset/Attributes.hs
@@ -1,3 +1,7 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
+{-# OPTIONS_HADDOCK hide #-}
 -- #hide
 
 module Text.XHtml.Frameset.Attributes where
diff --git a/Text/XHtml/Frameset/Elements.hs b/Text/XHtml/Frameset/Elements.hs
index 53999cb4f22ae1195f86a3f355b56b295231e469..bd9aafbf1d92e4e9e79a709281fa07a45243267b 100644
--- a/Text/XHtml/Frameset/Elements.hs
+++ b/Text/XHtml/Frameset/Elements.hs
@@ -1,3 +1,7 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
+{-# OPTIONS_HADDOCK hide #-}
 -- #hide
 
 module Text.XHtml.Frameset.Elements where
diff --git a/Text/XHtml/Internals.hs b/Text/XHtml/Internals.hs
index 481c85cbfa2723e4edc7bfaa0051642a8123daee..c25ea538dff267aa419875f88872129e21067746 100644
--- a/Text/XHtml/Internals.hs
+++ b/Text/XHtml/Internals.hs
@@ -1,3 +1,7 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
+{-# OPTIONS_HADDOCK hide #-}
 -- #hide
 
 -----------------------------------------------------------------------------
diff --git a/Text/XHtml/Strict.hs b/Text/XHtml/Strict.hs
index 3616f7e13f8faab98eee5e5d9e93ea6cd23f4a4e..fdb2a3986dd932a76f446c4cad6c2266fd31bd26 100644
--- a/Text/XHtml/Strict.hs
+++ b/Text/XHtml/Strict.hs
@@ -1,3 +1,7 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
+
 -- | Produces XHTML 1.0 Strict.
 module Text.XHtml.Strict (
      -- * Data types
diff --git a/Text/XHtml/Strict/Attributes.hs b/Text/XHtml/Strict/Attributes.hs
index f761c2d76a5130e0dcd3e4834d3f574b6b90a435..4e3cbf1b08ef905709bd3c7e40d2203ffef15b33 100644
--- a/Text/XHtml/Strict/Attributes.hs
+++ b/Text/XHtml/Strict/Attributes.hs
@@ -1,3 +1,7 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
+{-# OPTIONS_HADDOCK hide #-}
 -- #hide
 
 module Text.XHtml.Strict.Attributes where
diff --git a/Text/XHtml/Strict/Elements.hs b/Text/XHtml/Strict/Elements.hs
index c2c1eb00193e61e8ad634155c5f409bd9ad0f43b..8220347360977de5c597583c676199718af2edca 100644
--- a/Text/XHtml/Strict/Elements.hs
+++ b/Text/XHtml/Strict/Elements.hs
@@ -1,3 +1,7 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
+{-# OPTIONS_HADDOCK hide #-}
 -- #hide
 
 module Text.XHtml.Strict.Elements where
diff --git a/Text/XHtml/Table.hs b/Text/XHtml/Table.hs
index c243673a36b92aa47e5a2405508509cafa06a05c..b94b4dbce9d77b58dc9f9c41adddb29cb8d0d846 100644
--- a/Text/XHtml/Table.hs
+++ b/Text/XHtml/Table.hs
@@ -1,3 +1,8 @@
+{-# LANGUAGE CPP #-}
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
+
 -- | Table combinators for XHTML.
 module Text.XHtml.Table (HtmlTable, HTMLTABLE(..),
                         (</>), above, (<->), beside, 
diff --git a/Text/XHtml/Transitional.hs b/Text/XHtml/Transitional.hs
index 56ac8b1b1875638ef822a7c011e3bcde3f2bf6fd..71a8bcee6d912a638ddf58ff321aa41fd1f6cf09 100644
--- a/Text/XHtml/Transitional.hs
+++ b/Text/XHtml/Transitional.hs
@@ -1,3 +1,7 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
+
 -- | Produces XHTML 1.0 Transitional.
 module Text.XHtml.Transitional (
      -- * Data types
diff --git a/Text/XHtml/Transitional/Attributes.hs b/Text/XHtml/Transitional/Attributes.hs
index efe5edc83108c4f27ae8aecf7b88dc6879d0bee2..635562c9113bd7618a79eb79c3ecec57c159fb6e 100644
--- a/Text/XHtml/Transitional/Attributes.hs
+++ b/Text/XHtml/Transitional/Attributes.hs
@@ -1,3 +1,7 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
+{-# OPTIONS_HADDOCK hide #-}
 -- #hide
 
 module Text.XHtml.Transitional.Attributes where
diff --git a/Text/XHtml/Transitional/Elements.hs b/Text/XHtml/Transitional/Elements.hs
index 9d27bfecfd9b3c81638a04b1f6efe993e2827e98..704674ba97c1937b7e9bc1afc6497a9e65572e36 100644
--- a/Text/XHtml/Transitional/Elements.hs
+++ b/Text/XHtml/Transitional/Elements.hs
@@ -1,3 +1,7 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
+{-# OPTIONS_HADDOCK hide #-}
 -- #hide
 
 module Text.XHtml.Transitional.Elements where
diff --git a/xhtml.cabal b/xhtml.cabal
index f21e7af14dd395197ef035b078816575ef4bf7df..e5b6fc4c46243b10239a5d23338369a392fa1a0f 100644
--- a/xhtml.cabal
+++ b/xhtml.cabal
@@ -31,3 +31,4 @@ Other-modules:
   Text.XHtml.Extras,
   Text.XHtml.Internals
 ghc-options: -O2 -W
+Extensions: CPP