From c6fc26d897b147d5ac48d0d799230c5a4ddb791d Mon Sep 17 00:00:00 2001 From: alexwl Date: Fri, 12 Oct 2018 19:45:12 +0300 Subject: Fix all GHC 8.4.3 compatibility issues. Needs a bit more testing. --- src/HaskellCodeExplorer/Types.hs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/HaskellCodeExplorer/Types.hs') diff --git a/src/HaskellCodeExplorer/Types.hs b/src/HaskellCodeExplorer/Types.hs index 9e3667d..f94b3af 100644 --- a/src/HaskellCodeExplorer/Types.hs +++ b/src/HaskellCodeExplorer/Types.hs @@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE DeriveDataTypeable #-} @@ -47,6 +48,11 @@ import Documentation.Haddock.Types , Header(..) , Hyperlink(..) , Picture(..) +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) + , Table(..) + , TableCell(..) + , TableRow(..) +#endif ) import GHC.Generics (Generic) import Prelude hiding (id) @@ -781,7 +787,7 @@ docToHtml modToHtml idToHtml = toStrict . renderHtml . toH in htmlPrompt >> htmlExpression >> mapM_ (Html.span . Html.toHtml) (unlines results)) examples - toH (DocString str) = Html.span . Html.toHtml $ T.pack str + toH (DocString str) = Html.span . Html.toHtml $ T.pack str toH (DocHeader (Header level doc)) = toHeader level $ toH doc where toHeader 1 = Html.h1 @@ -790,6 +796,18 @@ docToHtml modToHtml idToHtml = toStrict . renderHtml . toH toHeader 4 = Html.h4 toHeader 5 = Html.h5 toHeader _ = Html.h6 +#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) + toH (DocTable (Table hs bs)) = + let tableRowToH tdOrTh (TableRow cells) = + Html.tr $ mapM_ (tableCellToH tdOrTh) cells + tableCellToH tdOrTh (TableCell colspan rowspan doc) = + (tdOrTh $ toH doc) Html.!? + (colspan /= 1, (Attr.colspan (Html.stringValue $ show colspan))) Html.!? + (rowspan /= 1, (Attr.rowspan (Html.stringValue $ show rowspan))) + in Html.table $ + Html.thead (mapM_ (tableRowToH Html.th) hs) >> + Html.tbody (mapM_ (tableRowToH Html.td) bs) +#endif instance A.ToJSON HaskellModuleName where toJSON (HaskellModuleName name) = A.String name -- cgit v1.2.3