[commit: haddock] 2.15, 2.15.0.1, 2.15.0.2, T6018-injective-type-families, adamse-D1033, clean, fix-travis, ghc-head, master, metainfo, v2.15, wip/10268, wip/10313, wip/D538, wip/D538-1, wip/D538-2, wip/D538-3, wip/D538-4, wip/D538-5, wip/D538-6, wip/D548-master, wip/D548-master-2, wip/T10483, wip/T8584, wip/T9840, wip/api-ann-hstylit, wip/api-ann-hstylit-1, wip/api-ann-hstylit-2, wip/api-ann-hstylit-3, wip/api-ann-hstylit-4, wip/api-ann-hstylit-5, wip/api-annot-tweaks-7.10, wip/api-annots-ghc-7.10-3, wip/ast-annotations-separate, wip/ast-prepare-annotations, wip/ast-prepare-annotations-final, wip/ast-prepare-annotations-final2, wip/ast-prepare-annotations-final3, wip/ast-prepare-annotations-final4, wip/ast-prepare-annotations-final5, wip/ast-prepare-annotations-final6, wip/attoparsec-update, wip/landmine-param-family, wip/orf-new, wip/orf-reboot, wip/pattern-synonyms, wip/rae, wip/remove-cabal-dep, wip/trac-9744: Compatibility with older versions of base and bytestring (b973784)

git at git.haskell.org git at git.haskell.org
Wed Jul 8 08:28:27 UTC 2015


Repository : ssh://git@git.haskell.org/haddock

On branches: 2.15,2.15.0.1,2.15.0.2,T6018-injective-type-families,adamse-D1033,clean,fix-travis,ghc-head,master,metainfo,v2.15,wip/10268,wip/10313,wip/D538,wip/D538-1,wip/D538-2,wip/D538-3,wip/D538-4,wip/D538-5,wip/D538-6,wip/D548-master,wip/D548-master-2,wip/T10483,wip/T8584,wip/T9840,wip/api-ann-hstylit,wip/api-ann-hstylit-1,wip/api-ann-hstylit-2,wip/api-ann-hstylit-3,wip/api-ann-hstylit-4,wip/api-ann-hstylit-5,wip/api-annot-tweaks-7.10,wip/api-annots-ghc-7.10-3,wip/ast-annotations-separate,wip/ast-prepare-annotations,wip/ast-prepare-annotations-final,wip/ast-prepare-annotations-final2,wip/ast-prepare-annotations-final3,wip/ast-prepare-annotations-final4,wip/ast-prepare-annotations-final5,wip/ast-prepare-annotations-final6,wip/attoparsec-update,wip/landmine-param-family,wip/orf-new,wip/orf-reboot,wip/pattern-synonyms,wip/rae,wip/remove-cabal-dep,wip/trac-9744
Link       : http://git.haskell.org/haddock.git/commitdiff/b973784c65c4d20c893b5377a7ced557d0a420cf

>---------------------------------------------------------------

commit b973784c65c4d20c893b5377a7ced557d0a420cf
Author: Simon Hengel <sol at typeful.net>
Date:   Wed Jun 18 11:01:18 2014 +0800

    Compatibility with older versions of base and bytestring


>---------------------------------------------------------------

b973784c65c4d20c893b5377a7ced557d0a420cf
 haddock-library/haddock-library.cabal                 |  1 +
 haddock-library/src/Documentation/Haddock/Parser.hs   |  2 +-
 .../src/Documentation/Haddock/Parser/Util.hs          | 19 ++++++++++++++++++-
 .../test/Documentation/Haddock/Parser/UtilSpec.hs     |  2 +-
 4 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index 3fb5591..2dced3c 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -63,6 +63,7 @@ test-suite spec
 
   build-depends:
       base
+    , base-compat
     , hspec
     , bytestring
     , deepseq
diff --git a/haddock-library/src/Documentation/Haddock/Parser.hs b/haddock-library/src/Documentation/Haddock/Parser.hs
index 3d146d3..f059746 100644
--- a/haddock-library/src/Documentation/Haddock/Parser.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser.hs
@@ -437,7 +437,7 @@ autoUrl = mkLink <$> url
   where
     url = mappend <$> ("http://" <|> "https://" <|> "ftp://") <*> takeWhile1 (not . isSpace)
     mkLink :: BS.ByteString -> DocH mod a
-    mkLink s = case BS.unsnoc s of
+    mkLink s = case unsnoc s of
       Just (xs, x) | x `elem` ",.!?" -> DocHyperlink (Hyperlink (decodeUtf8 xs) Nothing) <> DocString [x]
       _ -> DocHyperlink (Hyperlink (decodeUtf8 s) Nothing)
 
diff --git a/haddock-library/src/Documentation/Haddock/Parser/Util.hs b/haddock-library/src/Documentation/Haddock/Parser/Util.hs
index 25dba2d..ef2af14 100644
--- a/haddock-library/src/Documentation/Haddock/Parser/Util.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser/Util.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 -- |
 -- Module      :  Documentation.Haddock.Parser.Util
 -- Copyright   :  (c) Mateusz Kowalczyk 2013-2014,
@@ -9,7 +10,14 @@
 -- Portability :  portable
 --
 -- Various utility functions used by the parser.
-module Documentation.Haddock.Parser.Util where
+module Documentation.Haddock.Parser.Util (
+  unsnoc
+, strip
+, takeUntil
+, makeLabeled
+, takeHorizontalSpace
+, skipHorizontalSpace
+) where
 
 import           Control.Applicative
 import           Control.Monad (mfilter)
@@ -18,6 +26,15 @@ import           Data.ByteString.Char8 (ByteString)
 import qualified Data.ByteString.Char8 as BS
 import           Prelude hiding (takeWhile)
 
+#if MIN_VERSION_bytestring(0,10,2)
+import           Data.ByteString.Char8 (unsnoc)
+#else
+unsnoc :: ByteString -> Maybe (ByteString, Char)
+unsnoc bs
+  | BS.null bs = Nothing
+  | otherwise = Just (BS.init bs, BS.last bs)
+#endif
+
 -- | Remove all leading and trailing whitespace
 strip :: String -> String
 strip = (\f -> f . f) $ dropWhile isSpace . reverse
diff --git a/haddock-library/test/Documentation/Haddock/Parser/UtilSpec.hs b/haddock-library/test/Documentation/Haddock/Parser/UtilSpec.hs
index 265a4d4..a6ac49e 100644
--- a/haddock-library/test/Documentation/Haddock/Parser/UtilSpec.hs
+++ b/haddock-library/test/Documentation/Haddock/Parser/UtilSpec.hs
@@ -2,8 +2,8 @@
 module Documentation.Haddock.Parser.UtilSpec (main, spec) where
 
 import Data.Attoparsec.ByteString.Char8
-import Data.Either
 import Documentation.Haddock.Parser.Util
+import Data.Either.Compat (isLeft)
 import Test.Hspec
 
 main :: IO ()



More information about the ghc-commits mailing list