diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,2 +1,12 @@
-import Distribution.Simple
-main = defaultMain
+import qualified Distribution.Simple as Simple
+import qualified Distribution.Simple.LocalBuildInfo as LocalBuildInfo
+import qualified Distribution.Simple.Program as Program
+
+main :: IO ()
+main = Simple.defaultMainWithHooks hooks where
+	hooks = Simple.simpleUserHooks
+		{ Simple.haddockHook = myHaddockHook
+		}
+	myHaddockHook pkg lbi = Simple.haddockHook Simple.simpleUserHooks pkg (lbi
+		{ LocalBuildInfo.withPrograms = Program.userSpecifyArgs "haddock" ["--optghc=-D__HADDOCK__"] (LocalBuildInfo.withPrograms lbi)
+		})
diff --git a/lib/Filesystem/Path.hs b/lib/Filesystem/Path.hs
--- a/lib/Filesystem/Path.hs
+++ b/lib/Filesystem/Path.hs
@@ -216,8 +216,8 @@
 -- | Remove a prefix from a path.
 --
 -- @
--- 'stripPrefix' \"/foo/\" \"/foo/bar/baz.txt\" == Just \"bar/baz.txt\"
--- 'stripPrefix' \"/foo/\" \"/bar/baz.txt\" == Nothing
+-- 'stripPrefix' \"\/foo\/\" \"\/foo\/bar\/baz.txt\" == Just \"bar\/baz.txt\"
+-- 'stripPrefix' \"\/foo\/\" \"\/bar\/baz.txt\" == Nothing
 -- @
 --
 -- Since: 0.4.1
diff --git a/lib/Filesystem/Path/CurrentOS.hs b/lib/Filesystem/Path/CurrentOS.hs
--- a/lib/Filesystem/Path/CurrentOS.hs
+++ b/lib/Filesystem/Path/CurrentOS.hs
@@ -41,14 +41,18 @@
 import qualified Filesystem.Path as F
 import qualified Filesystem.Path.Rules as R
 
-#if defined(CABAL_OS_WINDOWS) || defined(CABAL_OS_DARWIN)
-#define PLATFORM_PATH_FORMAT T.Text
+#if defined(__HADDOCK__)
+#  define PLATFORM_PATH_FORMAT platformTextFormat
+#elif defined(CABAL_OS_WINDOWS) || defined(CABAL_OS_DARWIN)
+#  define PLATFORM_PATH_FORMAT T.Text
 #else
-#define PLATFORM_PATH_FORMAT B.ByteString
+#  define PLATFORM_PATH_FORMAT B.ByteString
 #endif
 
 currentOS :: R.Rules PLATFORM_PATH_FORMAT
-#if defined(CABAL_OS_WINDOWS)
+#if defined(__HADDOCK__)
+currentOS = undefined
+#elif defined(CABAL_OS_WINDOWS)
 currentOS = R.windows
 #elif defined(CABAL_OS_DARWIN)
 #if __GLASGOW_HASKELL__ >= 702
diff --git a/system-filepath.cabal b/system-filepath.cabal
--- a/system-filepath.cabal
+++ b/system-filepath.cabal
@@ -1,12 +1,12 @@
 name: system-filepath
-version: 0.4.8
+version: 0.4.9
 synopsis: High-level, byte-based file and directory path manipulations
 license: MIT
 license-file: license.txt
 author: John Millikin <jmillikin@gmail.com>
 maintainer: John Millikin <jmillikin@gmail.com>
 copyright: John Millikin 2010-2012
-build-type: Simple
+build-type: Custom
 cabal-version: >= 1.6
 category: System
 stability: experimental
@@ -29,7 +29,7 @@
 source-repository this
   type: git
   location: https://john-millikin.com/code/haskell-filesystem/
-  tag: system-filepath_0.4.8
+  tag: system-filepath_0.4.9
 
 library
   ghc-options: -Wall -O2
@@ -39,7 +39,7 @@
       base >= 4.0 && < 5.0
     , bytestring >= 0.9
     , deepseq >= 1.1 && < 1.4
-    , text >= 0.7.1 && < 0.12
+    , text >= 0.7.1
 
   if os(windows)
     cpp-options: -DCABAL_OS_WINDOWS
