From 0e48a02bdd4fa3c605b79233ef2018859012c7f4 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sun, 15 Mar 2020 08:14:59 +0100 Subject: [PATCH] Always use custom prelude Previously, the custom prelude was used only with older GHC versions, as a workaround for problems with ghci. The ghci problems are resolved by replacing package `base` with `base-noprelude`, allowing for consistent use of the custom prelude across all GHC versions. --- pandoc.cabal | 72 ++++++++++------------- src/Text/Pandoc/App/CommandLineOptions.hs | 4 +- 2 files changed, 33 insertions(+), 43 deletions(-) diff --git a/pandoc.cabal b/pandoc.cabal index 66a309515..5dd7dafc5 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -377,7 +377,8 @@ flag trypandoc Default: False library - build-depends: base >= 4.9 && < 5, + build-depends: base-noprelude >= 4.9 && < 5, + base-compat >= 0.9, syb >= 0.1 && < 0.8, containers >= 0.4.2.1 && < 0.7, unordered-containers >= 0.2 && < 0.3, @@ -440,10 +441,6 @@ library build-depends: basement >= 0.0.10, foundation >= 0.0.23 -- basement 0.0.9 won't build on 32-bit windows. - if impl(ghc < 8.4) - hs-source-dirs: prelude - other-modules: Prelude - build-depends: base-compat >= 0.9 if os(windows) cpp-options: -D_WINDOWS else @@ -471,7 +468,8 @@ library default-language: Haskell2010 other-extensions: NoImplicitPrelude - hs-source-dirs: src + hs-source-dirs: src, + prelude exposed-modules: Text.Pandoc, Text.Pandoc.App, @@ -565,7 +563,8 @@ library Text.Pandoc.ImageSize, Text.Pandoc.BCP47, Text.Pandoc.Class - other-modules: Text.Pandoc.App.CommandLineOptions, + other-modules: Prelude, + Text.Pandoc.App.CommandLineOptions, Text.Pandoc.App.FormatHeuristics, Text.Pandoc.App.Opt, Text.Pandoc.App.OutputSettings, @@ -640,19 +639,19 @@ library buildable: True executable pandoc - build-depends: pandoc, base >= 4.8 && < 5 - if impl(ghc < 8.4) - hs-source-dirs: prelude - other-modules: Prelude - build-depends: base-compat >= 0.9 + build-depends: pandoc, + base-noprelude >= 4.8 && < 5, + base-compat >= 0.9 if flag(static) ld-options: -static default-language: Haskell2010 other-extensions: NoImplicitPrelude hs-source-dirs: . + prelude main-is: pandoc.hs buildable: True - other-modules: Paths_pandoc + other-modules: Paths_pandoc, + Prelude ghc-options: -rtsopts -with-rtsopts=-K16m -threaded -Wall -fno-warn-unused-do-bind -Wincomplete-record-updates @@ -667,19 +666,16 @@ executable pandoc executable trypandoc main-is: trypandoc.hs - hs-source-dirs: trypandoc + hs-source-dirs: trypandoc, prelude default-language: Haskell2010 other-extensions: NoImplicitPrelude + other-modules: Prelude if flag(trypandoc) - build-depends: base, aeson, pandoc, + build-depends: base-noprelude, base-compat >= 0.9, aeson, pandoc, text, wai-extra, wai >= 0.3, http-types buildable: True else buildable: False - if impl(ghc < 8.4) - hs-source-dirs: prelude - other-modules: Prelude - build-depends: base-compat >= 0.9 ghc-options: -rtsopts -with-rtsopts=-K16m -threaded -Wall -fno-warn-unused-do-bind -Wincomplete-record-updates @@ -695,18 +691,16 @@ executable trypandoc benchmark weigh-pandoc type: exitcode-stdio-1.0 main-is: weigh-pandoc.hs - hs-source-dirs: benchmark + hs-source-dirs: benchmark, + prelude build-depends: pandoc, - base >= 4.8 && < 5, + base-noprelude >= 4.8 && < 5, + base-compat >= 0.9, text, weigh >= 0.0 && < 0.1, mtl >= 2.2 && < 2.3 - if impl(ghc < 8.4) - hs-source-dirs: prelude - other-modules: Prelude - build-depends: base-compat >= 0.9 default-language: Haskell2010 - other-extensions: NoImplicitPrelude + other-modules: Prelude ghc-options: -rtsopts -with-rtsopts=-K16m -threaded -Wall -fno-warn-unused-do-bind -Wincomplete-record-updates @@ -723,8 +717,10 @@ benchmark weigh-pandoc test-suite test-pandoc type: exitcode-stdio-1.0 main-is: test-pandoc.hs - hs-source-dirs: test - build-depends: base >= 4.8 && < 5, + hs-source-dirs: test, + prelude + build-depends: base-noprelude >= 4.8 && < 5, + base-compat >= 0.9, pandoc, pandoc-types >= 1.20 && < 1.21, mtl >= 2.2 && < 2.3, @@ -750,11 +746,8 @@ test-suite test-pandoc xml >= 1.3.12 && < 1.4, doctemplates >= 0.8 && < 0.9, Glob >= 0.7 && < 0.11 - if impl(ghc < 8.4) - hs-source-dirs: prelude - other-modules: Prelude - build-depends: base-compat >= 0.9 - other-modules: Tests.Old + other-modules: Prelude + Tests.Old Tests.Command Tests.Helpers Tests.Lua @@ -809,7 +802,6 @@ test-suite test-pandoc if os(windows) cpp-options: -D_WINDOWS default-language: Haskell2010 - other-extensions: NoImplicitPrelude ghc-options: -rtsopts -with-rtsopts=-K16m -threaded -Wall -fno-warn-unused-do-bind -Wincomplete-record-updates @@ -826,19 +818,17 @@ test-suite test-pandoc benchmark benchmark-pandoc type: exitcode-stdio-1.0 main-is: benchmark-pandoc.hs - hs-source-dirs: benchmark + hs-source-dirs: benchmark, + prelude build-depends: pandoc, time, bytestring, containers, - base >= 4.8 && < 5, + base-noprelude >= 4.8 && < 5, + base-compat >= 0.9, text >= 1.1.1.0 && < 1.3, mtl >= 2.2 && < 2.3, criterion >= 1.0 && < 1.6 - if impl(ghc < 8.4) - hs-source-dirs: prelude - other-modules: Prelude - build-depends: base-compat >= 0.9 default-language: Haskell2010 - other-extensions: NoImplicitPrelude + other-modules: Prelude ghc-options: -rtsopts -with-rtsopts=-K16m -threaded -Wall -fno-warn-unused-do-bind -Wincomplete-record-updates diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs index 36a6c763c..164ef17d5 100644 --- a/src/Text/Pandoc/App/CommandLineOptions.hs +++ b/src/Text/Pandoc/App/CommandLineOptions.hs @@ -30,7 +30,7 @@ import Data.Bifunctor (second) import Data.Char (toLower) import Data.List (intercalate, sort) #ifdef _WINDOWS -#if MIN_VERSION_base(4,12,0) +#if MIN_VERSION_base_noprelude(4,12,0) import Data.List (isPrefixOf) #endif #endif @@ -1028,7 +1028,7 @@ setVariable key val (Context ctx) = Context $ M.alter go key ctx -- beginning with \\ to \\?\UNC\. -- See #5127. normalizePath :: FilePath -> FilePath #ifdef _WINDOWS -#if MIN_VERSION_base(4,12,0) +#if MIN_VERSION_base_noprelude(4,12,0) normalizePath fp = if "\\\\" `isPrefixOf` fp && not ("\\\\?\\" `isPrefixOf` fp) then "\\\\?\\UNC\\" ++ drop 2 fp