From bdc4c679bf0185ab6c1895172f011193d9e9922c Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 21 Sep 2021 15:47:38 -1000 Subject: [PATCH] upgrade(ghc): changes necessary for ghc 8.10 and 9.0 compatibility (#44) * cabal: set default-language, silence warning * stack: bump to lts-18.10 (ghc 8.10.7) * stack: don't require nix by default * fix warnings, drop th-lift, require ghc 8.0+ * allow template-haskell 2.17.0.0, build with stackage nightly (ghc 9.0.1) * bump version to 0.7.0.7, draft changelog * don't bother version-controlling stack.yaml.lock --- .gitignore | 1 + CHANGELOG.md | 4 ++++ System/Console/Docopt/QQ/Instances.hs | 22 +++++++++------------- System/Console/Docopt/Types.hs | 9 +++++---- System/Console/Docopt/UsageParse.hs | 2 +- docopt.cabal | 13 ++++++++----- stack.yaml | 16 ++++++---------- stack.yaml.lock | 12 ------------ 8 files changed, 34 insertions(+), 45 deletions(-) delete mode 100644 stack.yaml.lock diff --git a/.gitignore b/.gitignore index a37b8ba..dbc8e53 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ cabal.sandbox.config # extra tmp .stack-work +stack.yaml.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index 3163e01..423618f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 0.7.0.7 (unreleased) + +- update bounds, fix warnings, require ghc 8.0+ + ### 0.7.0.6 - Fixes issue causing compilation error to happen with ghc-8.8.2 [#33][#34] diff --git a/System/Console/Docopt/QQ/Instances.hs b/System/Console/Docopt/QQ/Instances.hs index bad4b1d..c11706f 100644 --- a/System/Console/Docopt/QQ/Instances.hs +++ b/System/Console/Docopt/QQ/Instances.hs @@ -1,19 +1,15 @@ -{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE DeriveLift#-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE FlexibleInstances #-} + {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_HADDOCK hide, prune #-} + module System.Console.Docopt.QQ.Instances where import System.Console.Docopt.Types -import Language.Haskell.TH.Lift - -import qualified Data.Map as M - -instance (Lift k, Lift v) => Lift (M.Map k v) where - lift m = [| M.fromList assoc |] - where assoc = M.toList m +import Language.Haskell.TH.Syntax (Lift) +import Data.Map.Internal (Map(..)) -$(deriveLiftMany [ ''Option - , ''Pattern - , ''OptionInfo - , ''Docopt - ]) +deriving instance Lift (Map Option OptionInfo) +deriving instance Lift (Docopt) diff --git a/System/Console/Docopt/Types.hs b/System/Console/Docopt/Types.hs index eae8b93..cfc697e 100644 --- a/System/Console/Docopt/Types.hs +++ b/System/Console/Docopt/Types.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE DeriveLift#-} module System.Console.Docopt.Types where @@ -5,7 +6,7 @@ import Data.Char (isUpper) import Data.List (nub) import Data.Map (Map) import qualified Data.Map as M - +import Language.Haskell.TH.Syntax (Lift) -- * Usage expression Types @@ -17,7 +18,7 @@ data Pattern a = Sequence [Pattern a] | Optional (Pattern a) | Repeated (Pattern a) | Atom a - deriving (Show, Eq) + deriving (Show, Eq, Lift) atoms :: Eq a => Pattern a -> [a] atoms (Sequence ps) = concatMap atoms ps @@ -33,7 +34,7 @@ data Option = LongOption Name | Command Name | Argument Name | AnyOption - deriving (Show, Eq, Ord) + deriving (Show, Eq, Ord, Lift) type OptPattern = Pattern Option @@ -57,7 +58,7 @@ data OptionInfo = OptionInfo , defaultVal :: Maybe String , expectsVal :: Bool , isRepeated :: Bool - } deriving (Show, Eq) + } deriving (Show, Eq, Lift) fromSynList :: [Option] -> OptionInfo fromSynList opts = OptionInfo { synonyms = opts diff --git a/System/Console/Docopt/UsageParse.hs b/System/Console/Docopt/UsageParse.hs index 6e661c3..9d00d17 100644 --- a/System/Console/Docopt/UsageParse.hs +++ b/System/Console/Docopt/UsageParse.hs @@ -4,7 +4,7 @@ module System.Console.Docopt.UsageParse import qualified Data.Map as M import Data.Ord (comparing) import GHC.Exts (Down(..)) -import Data.List (nub, sortBy, maximumBy, dropWhile, dropWhileEnd) +import Data.List (nub, sortBy, maximumBy, dropWhileEnd) import System.Console.Docopt.ParseUtils import System.Console.Docopt.Types diff --git a/docopt.cabal b/docopt.cabal index 75dc214..aa7f8a9 100644 --- a/docopt.cabal +++ b/docopt.cabal @@ -1,5 +1,5 @@ name: docopt -version: 0.7.0.6 +version: 0.7.0.7 synopsis: A command-line interface parser that will make you smile description: Docopt parses command-line interface usage text that adheres to a familiar syntax, and from it builds a command-line argument parser that will ensure your program is invoked correctly with the available options specified in the usage text. This allows the developer to write a usage text and get an argument parser for free. @@ -57,8 +57,9 @@ library exposed-modules: System.Console.Docopt other-modules: System.Console.Docopt.QQ System.Console.Docopt.QQ.Instances - build-depends: template-haskell >= 2.15.0 && < 2.16, - th-lift >= 0.8.2 && < 0.9 + build-depends: template-haskell >= 2.15.0 && < 2.18 + + default-language: Haskell2010 test-suite tests type: exitcode-stdio-1.0 @@ -82,8 +83,8 @@ test-suite tests aeson, bytestring, text, - template-haskell >= 2.15.0 && < 2.16, - th-lift >= 0.8.2 && < 0.9 + template-haskell >= 2.15.0 && < 2.18 + other-modules: System.Console.Docopt System.Console.Docopt.ApplicativeParsec @@ -95,3 +96,5 @@ test-suite tests System.Console.Docopt.QQ System.Console.Docopt.QQ.Instances Paths_docopt + + default-language: Haskell2010 diff --git a/stack.yaml b/stack.yaml index 39ae7e3..750dfc5 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,18 +1,14 @@ # For advanced use and comprehensive documentation of the format, please see: # http://docs.haskellstack.org/en/stable/yaml_configuration/ -resolver: lts-16.20 +# ghc 8.10.7 +resolver: lts-18.10 +# ghc 9.0.1 +# resolver: nightly-2021-07-16 packages: - '.' - examples/ -# Uncomment to test https://github.com/docopt/docopt.hs/issues/29 -# extra-deps: -# - aeson-1.0.2.0 -# flags: -# aeson: -# fast: true - -nix: - enable: true +# nix: +# enable: true diff --git a/stack.yaml.lock b/stack.yaml.lock deleted file mode 100644 index 032c6e2..0000000 --- a/stack.yaml.lock +++ /dev/null @@ -1,12 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: [] -snapshots: -- completed: - size: 532177 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/20.yaml - sha256: 0e14ba5603f01e8496e8984fd84b545a012ca723f51a098c6c9d3694e404dc6d - original: lts-16.20