haskell-tensorflow: unbreak

- get the current Git head of haskell-tensorflow
- adjust dependencies
This commit is contained in:
Mike Sperber
2020-04-17 20:50:48 +02:00
committed by Peter Simons
parent d59d157ad9
commit 53cfd1d132
5 changed files with 248 additions and 115 deletions
@@ -1,23 +0,0 @@
diff -Naur proto-lens-0.2.2.0/proto-lens.cabal proto-lens-0.2.2.0-patched/proto-lens.cabal
--- proto-lens-0.2.2.0/proto-lens.cabal 2018-08-13 18:05:41.704823370 +0200
+++ proto-lens-0.2.2.0-patched/proto-lens.cabal 2018-08-13 18:07:42.352372300 +0200
@@ -33,7 +33,7 @@
Data.ProtoLens.Encoding.Wire
Data.ProtoLens.TextFormat.Parser
build-depends: attoparsec == 0.13.*
- , base >= 4.8 && < 4.11
+ , base >= 4.8
, bytestring == 0.10.*
, containers == 0.5.*
, data-default-class >= 0.0 && < 0.2
diff -Naur proto-lens-0.2.2.0/src/Data/ProtoLens/TextFormat.hs proto-lens-0.2.2.0-patched/src/Data/ProtoLens/TextFormat.hs
--- proto-lens-0.2.2.0/src/Data/ProtoLens/TextFormat.hs 2017-04-28 02:16:46.000000000 +0200
+++ proto-lens-0.2.2.0-patched/src/Data/ProtoLens/TextFormat.hs 2018-08-13 18:08:06.371486594 +0200
@@ -17,6 +17,7 @@
readMessageOrDie,
) where
+import Prelude hiding ((<>))
import Lens.Family2 ((&),(^.),(.~), set, over)
import Control.Arrow (left)
import qualified Data.ByteString
@@ -0,0 +1,23 @@
diff --git a/src/Data/ProtoLens/Encoding/Parser/Internal.hs b/src/Data/ProtoLens/Encoding/Parser/Internal.hs
index 30eeaad..f2703e7 100644
--- a/src/Data/ProtoLens/Encoding/Parser/Internal.hs
+++ b/src/Data/ProtoLens/Encoding/Parser/Internal.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE CPP #-}
-- | Definition of the parsing monad, plus internal
-- unsafe functions.
module Data.ProtoLens.Encoding.Parser.Internal
@@ -36,8 +37,11 @@ instance Applicative Parser where
(<*>) = ap
instance Monad Parser where
- fail s = Parser $ \_ _ -> return $ ParseFailure s
return = pure
Parser f >>= g = Parser $ \end pos -> f end pos >>= \case
ParseSuccess pos' x -> unParser (g x) end pos'
ParseFailure s -> return $ ParseFailure s
+#if MIN_VERSION_base(4,13,0)
+instance MonadFail Parser where
+#endif
+ fail s = Parser $ \_ _ -> return $ ParseFailure s
@@ -1,51 +0,0 @@
diff -Naur proto-lens-protoc-0.2.2.3/proto-lens-protoc.cabal proto-lens-protoc-0.2.2.3-patched/proto-lens-protoc.cabal
--- proto-lens-protoc-0.2.2.3/proto-lens-protoc.cabal 2018-07-21 22:55:12.041698876 +0200
+++ proto-lens-protoc-0.2.2.3-patched/proto-lens-protoc.cabal 2018-08-13 19:44:44.993147985 +0200
@@ -37,8 +37,8 @@
default-language: Haskell2010
hs-source-dirs: src
build-depends:
- Cabal >= 1.22 && < 2.1
- , base >= 4.8 && < 4.11
+ Cabal >= 1.22
+ , base >= 4.8
, bytestring == 0.10.*
, containers == 0.5.*
, data-default-class >= 0.0 && < 0.2
@@ -53,6 +53,7 @@
, proto-lens == 0.2.2.*
, proto-lens-descriptors == 0.2.2.*
, text == 1.2.*
+ , semigroups
reexported-modules:
-- Modules that are needed by the generated Haskell files.
-- For forwards compatibility, reexport them as new module names so that
@@ -76,7 +77,7 @@
main-is: protoc-gen-haskell.hs
build-depends:
- base >= 4.8 && < 4.11
+ base >= 4.8
, bytestring == 0.10.*
, containers == 0.5.*
, data-default-class >= 0.0 && < 0.2
diff -Naur proto-lens-protoc-0.2.2.3/src/Data/ProtoLens/Compiler/Definitions.hs proto-lens-protoc-0.2.2.3-patched/src/Data/ProtoLens/Compiler/Definitions.hs
--- proto-lens-protoc-0.2.2.3/src/Data/ProtoLens/Compiler/Definitions.hs 2017-08-07 06:52:21.000000000 +0200
+++ proto-lens-protoc-0.2.2.3-patched/src/Data/ProtoLens/Compiler/Definitions.hs 2018-08-13 19:14:07.240505220 +0200
@@ -35,6 +35,7 @@
import qualified Data.Map as Map
import Data.Maybe (fromMaybe)
import Data.Monoid
+import qualified Data.Semigroup as Semigroup
import qualified Data.Set as Set
import Data.String (IsString(..))
import Data.Text (Text, cons, splitOn, toLower, uncons, unpack)
@@ -139,7 +140,7 @@
-- a 'Symbol' is used to construct both the type-level argument to
-- @HasLens@ and the name of the function @foo@.
newtype Symbol = Symbol String
- deriving (Eq, Ord, IsString, Monoid)
+ deriving (Eq, Ord, IsString, Semigroup.Semigroup, Monoid)
nameFromSymbol :: Symbol -> Name
nameFromSymbol (Symbol s) = fromString s
@@ -0,0 +1,154 @@
diff --git a/src/Data/ProtoLens/Setup.hs b/src/Data/ProtoLens/Setup.hs
index e68f32b..f381199 100644
--- a/src/Data/ProtoLens/Setup.hs
+++ b/src/Data/ProtoLens/Setup.hs
@@ -41,9 +41,6 @@ import Distribution.PackageDescription
, exeName
, exposedModules
, extraSrcFiles
-#if !MIN_VERSION_Cabal(2,0,0)
- , hsSourceDirs
-#endif
#if MIN_VERSION_Cabal(2,4,0)
, specVersion
#endif
@@ -53,7 +50,7 @@ import Distribution.PackageDescription
, testBuildInfo
, testName
)
-import qualified Distribution.Simple.BuildPaths as BuildPaths
+import Distribution.Simple.BuildPaths (autogenComponentModulesDir)
import Distribution.Simple.InstallDirs (datadir)
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(..)
@@ -61,9 +58,10 @@ import Distribution.Simple.LocalBuildInfo
, ComponentName(..)
, ComponentLocalBuildInfo
, componentPackageDeps
-#if MIN_VERSION_Cabal(2,0,0)
, allComponentsInBuildOrder
, componentNameMap
+#if MIN_VERSION_Cabal(3,0,0)
+ , LibraryName(..)
#endif
)
import qualified Distribution.Simple.PackageIndex as PackageIndex
@@ -205,16 +203,6 @@ generatingSpecificProtos root getProtos hooks = hooks
{ buildHook = \p l h f -> generate l >> buildHook hooks p l h f
, haddockHook = \p l h f -> generate l >> haddockHook hooks p l h f
, replHook = \p l h f args -> generate l >> replHook hooks p l h f args
-#if !MIN_VERSION_Cabal(2,0,0)
- -- Older versions of Cabal don't support the autogen-modules field.
- -- Work around it by manually generating the modules and putting them
- -- in a place where `cabal sdist` will pick them up.
- , sDistHook = \p maybe_l h f -> case maybe_l of
- Nothing -> error "Can't run protoc; run 'cabal configure' first."
- Just l -> do
- generate l
- sDistHook hooks (fudgePackageDesc l p) maybe_l h f
-#endif
, postCopy = \a flags pkg lbi -> do
let verb = fromFlag $ copyVerbosity flags
let destDir = datadir (absoluteInstallDirs pkg lbi
@@ -316,39 +304,6 @@ copyProtosToDataDir verb root destDir files = do
protoLensImportsPrefix :: FilePath
protoLensImportsPrefix = "proto-lens-imports"
-#if !MIN_VERSION_Cabal(2,0,0)
--- | Add the autogen directory to the hs-source-dirs of all the targets in the
--- .cabal file. Used to fool 'sdist' by pointing it to the generated source
--- files.
-fudgePackageDesc :: LocalBuildInfo -> PackageDescription -> PackageDescription
-fudgePackageDesc lbi p = p
- { library =
- (\lib -> lib { libBuildInfo = fudgeBuildInfo CLibName $ libBuildInfo lib })
- <$> library p
- , executables =
- (\exe -> exe { buildInfo = fudgeBuildInfo (CExeName $ exeName exe)
- $ buildInfo exe })
- <$> executables p
- , testSuites =
- (\test -> test { testBuildInfo = fudgeBuildInfo (CTestName $ testName test)
- $ testBuildInfo test })
- <$> testSuites p
- , benchmarks =
- (\bench -> bench { benchmarkBuildInfo =
- fudgeBuildInfo (CBenchName $ benchmarkName bench)
- $ benchmarkBuildInfo bench })
- <$> benchmarks p
- }
- where
- comps = allComponents lbi
- fudgeBuildInfo n bi
- | Just compLBI <- Map.lookup n comps
- = bi { hsSourceDirs = autogenComponentModulesDir lbi compLBI
- : hsSourceDirs bi }
- | otherwise = bi -- Could happen if a component isn't active; try
- -- anyway and see whether Cabal complains later on.
-#endif
-
-- | Returns whether the @root@ is a parent folder of @f@.
isSubdirectoryOf :: FilePath -> FilePath -> Bool
isSubdirectoryOf root f
@@ -423,15 +378,18 @@ collectActiveModules
collectActiveModules l = map (\(n, c) -> (c, f n)) $ Map.toList $ allComponents l
where
p = localPkgDescr l
- f CLibName = maybeToList (library p) >>=
+#if MIN_VERSION_Cabal(3,0,0)
+ f (CLibName LMainLibName)
+#else
+ f CLibName
+#endif
+ = maybeToList (library p) >>=
\lib -> exposedModules lib
++ otherModules (libBuildInfo lib)
f (CExeName n) = otherModules . buildInfo $ exes Map.! n
f (CTestName n) = otherModules . testBuildInfo $ tests Map.! n
f (CBenchName n) = otherModules . benchmarkBuildInfo $ benchs Map.! n
-#if MIN_VERSION_Cabal(2,0,0)
f _ = [] -- TODO: other lib kinds; for now just suppress the warning
-#endif
exes = Map.fromList [(exeName e, e) | e <- executables p]
tests = Map.fromList [(testName e, e) | e <- testSuites p]
benchs = Map.fromList [(benchmarkName e, e) | e <- benchmarks p]
@@ -441,22 +399,14 @@ collectActiveModules l = map (\(n, c) -> (c, f n)) $ Map.toList $ allComponents
-- | List all the packages that this one depends on.
collectDeps :: LocalBuildInfo -> [InstalledPackageInfo.InstalledPackageInfo]
-#if MIN_VERSION_Cabal(2,0,0)
collectDeps l = do
c <- allComponentsInBuildOrder l
(i,_) <- componentPackageDeps c
Just p <- [PackageIndex.lookupUnitId (installedPkgs l) i]
return p
-#else
-collectDeps l = do
- (_, c ,_) <- componentsConfigs l
- (_, i) <- componentPackageDeps c
- PackageIndex.lookupSourcePackageId (installedPkgs l) i
-#endif
-- | All the components that will be built by this Cabal command.
allComponents :: LocalBuildInfo -> Map.Map ComponentName ComponentLocalBuildInfo
-#if MIN_VERSION_Cabal(2,0,0)
allComponents l = fmap requireOne $ componentNameMap l
where
-- TODO: this doesn't support Backpack, which can have more than one
@@ -464,16 +414,3 @@ allComponents l = fmap requireOne $ componentNameMap l
requireOne [x] = x
requireOne xs = error $ "Data.ProtoLens.Setup.allComponents: expected one "
++ "component per name, got " ++ show xs
-
-#else
-allComponents l = Map.fromList [(c, b) | (c, b, _) <- componentsConfigs l]
-#endif
-
--- | Get the component-level "autogen" directory where we're putting the
--- generated .hs files. (For Cabal-1.0, use the shared 'BuildPaths.autogenModulesDir'.)
-autogenComponentModulesDir :: LocalBuildInfo -> ComponentLocalBuildInfo -> FilePath
-#if MIN_VERSION_Cabal(2,0,0)
-autogenComponentModulesDir = BuildPaths.autogenComponentModulesDir
-#else
-autogenComponentModulesDir lbi _ = BuildPaths.autogenModulesDir lbi
-#endif