From 568c9b6f03e5d66a25685a776386e2ff50b61aa9 Mon Sep 17 00:00:00 2001 From: Mike Sperber Date: Thu, 21 May 2020 22:36:52 +0200 Subject: [PATCH] Update to current proto-lens packages. (#258) --- stack.yaml | 2 +- tensorflow-core-ops/tensorflow-core-ops.cabal | 6 +++--- tensorflow-logging/tensorflow-logging.cabal | 4 ++-- .../src/TensorFlow/Examples/MNIST/Parse.hs | 1 - tensorflow-mnist/tensorflow-mnist.cabal | 4 ++-- tensorflow-opgen/src/TensorFlow/OpGen.hs | 1 - tensorflow-opgen/src/TensorFlow/OpGen/ParsedOp.hs | 1 - tensorflow-opgen/tensorflow-opgen.cabal | 4 ++-- tensorflow-ops/src/TensorFlow/Gradient.hs | 6 +++--- tensorflow-ops/src/TensorFlow/Variable.hs | 1 - tensorflow-ops/tensorflow-ops.cabal | 4 ++-- tensorflow-ops/tests/EmbeddingOpsTest.hs | 1 - tensorflow-ops/tests/GradientTest.hs | 3 +-- tensorflow-proto/tensorflow-proto.cabal | 6 +++--- tensorflow-records/tests/Main.hs | 1 - tensorflow/src/TensorFlow/Build.hs | 2 -- tensorflow/src/TensorFlow/Internal/VarInt.hs | 1 - tensorflow/src/TensorFlow/Nodes.hs | 1 - tensorflow/src/TensorFlow/Session.hs | 2 -- tensorflow/src/TensorFlow/Types.hs | 11 +++++------ tensorflow/tensorflow.cabal | 4 ++-- 21 files changed, 26 insertions(+), 40 deletions(-) diff --git a/stack.yaml b/stack.yaml index 8f8d447..1eeb681 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-14.4 +resolver: lts-15.11 packages: - tensorflow diff --git a/tensorflow-core-ops/tensorflow-core-ops.cabal b/tensorflow-core-ops/tensorflow-core-ops.cabal index b5f6a74..497d7a4 100644 --- a/tensorflow-core-ops/tensorflow-core-ops.cabal +++ b/tensorflow-core-ops/tensorflow-core-ops.cabal @@ -16,10 +16,10 @@ library exposed-modules: TensorFlow.GenOps.Core autogen-modules: TensorFlow.GenOps.Core build-depends: bytestring - , proto-lens >= 0.4.0 && < 0.6.0 + , proto-lens == 0.6.* , tensorflow == 0.2.* , base >= 4.7 && < 5 - , lens-family + , lens-family == 2.* , text default-language: Haskell2010 @@ -27,7 +27,7 @@ custom-setup setup-depends: Cabal , bytestring , directory - , proto-lens >= 0.4.0 && < 0.6.0 + , proto-lens == 0.6.* , tensorflow-opgen == 0.2.* , tensorflow == 0.2.* , base >= 4.7 && < 5 diff --git a/tensorflow-logging/tensorflow-logging.cabal b/tensorflow-logging/tensorflow-logging.cabal index e8df674..b79cf98 100644 --- a/tensorflow-logging/tensorflow-logging.cabal +++ b/tensorflow-logging/tensorflow-logging.cabal @@ -23,8 +23,8 @@ library , exceptions , filepath , hostname - , lens-family - , proto-lens >= 0.4.0 && < 0.6.0 + , lens-family == 2.* + , proto-lens == 0.6.* , resourcet , stm , stm-chans diff --git a/tensorflow-mnist/src/TensorFlow/Examples/MNIST/Parse.hs b/tensorflow-mnist/src/TensorFlow/Examples/MNIST/Parse.hs index 35a835a..c4374c4 100644 --- a/tensorflow-mnist/src/TensorFlow/Examples/MNIST/Parse.hs +++ b/tensorflow-mnist/src/TensorFlow/Examples/MNIST/Parse.hs @@ -24,7 +24,6 @@ import Control.Monad (when, liftM) import Data.Binary.Get (Get, runGet, getWord32be, getLazyByteString) import Data.ByteString.Lazy (toStrict, readFile) import Data.List.Split (chunksOf) -import Data.Monoid ((<>)) import Data.ProtoLens (Message, decodeMessageOrDie) import Data.Text (Text) import Data.Word (Word8, Word32) diff --git a/tensorflow-mnist/tensorflow-mnist.cabal b/tensorflow-mnist/tensorflow-mnist.cabal index 3bd2f1d..f628140 100644 --- a/tensorflow-mnist/tensorflow-mnist.cabal +++ b/tensorflow-mnist/tensorflow-mnist.cabal @@ -20,12 +20,12 @@ library exposed-modules: TensorFlow.Examples.MNIST.Parse , TensorFlow.Examples.MNIST.TrainedGraph other-modules: Paths_tensorflow_mnist - build-depends: proto-lens >= 0.4.0 && < 0.6.0 + build-depends: proto-lens == 0.6.* , base >= 4.7 && < 5 , binary , bytestring , filepath - , lens-family + , lens-family >= 2.0 , containers , split , tensorflow-proto == 0.2.* diff --git a/tensorflow-opgen/src/TensorFlow/OpGen.hs b/tensorflow-opgen/src/TensorFlow/OpGen.hs index d9a7555..421b147 100644 --- a/tensorflow-opgen/src/TensorFlow/OpGen.hs +++ b/tensorflow-opgen/src/TensorFlow/OpGen.hs @@ -72,7 +72,6 @@ import Proto.Tensorflow.Core.Framework.OpDef_Fields import Proto.Tensorflow.Core.Framework.Types (DataType(..)) import System.FilePath (takeBaseName) import TensorFlow.OpGen.ParsedOp -import Data.Semigroup ((<>)) import Text.PrettyPrint.Mainland ( Doc , (<+>) diff --git a/tensorflow-opgen/src/TensorFlow/OpGen/ParsedOp.hs b/tensorflow-opgen/src/TensorFlow/OpGen/ParsedOp.hs index beaa1d0..2649d86 100644 --- a/tensorflow-opgen/src/TensorFlow/OpGen/ParsedOp.hs +++ b/tensorflow-opgen/src/TensorFlow/OpGen/ParsedOp.hs @@ -25,7 +25,6 @@ import Data.Char (toUpper, toLower) import Data.List (sortBy) import Data.List.NonEmpty (NonEmpty, nonEmpty) import Data.Maybe (mapMaybe) -import Data.Monoid ((<>)) import Data.Ord (comparing) import qualified Data.Set as Set import Data.Text (Text) diff --git a/tensorflow-opgen/tensorflow-opgen.cabal b/tensorflow-opgen/tensorflow-opgen.cabal index 0d0a263..e867121 100644 --- a/tensorflow-opgen/tensorflow-opgen.cabal +++ b/tensorflow-opgen/tensorflow-opgen.cabal @@ -16,13 +16,13 @@ library hs-source-dirs: src exposed-modules: TensorFlow.OpGen.ParsedOp , TensorFlow.OpGen - build-depends: proto-lens >= 0.4.0 && < 0.6.0 + build-depends: proto-lens == 0.6.* , tensorflow-proto == 0.2.* , base >= 4.7 && < 5 , bytestring , containers , filepath - , lens-family + , lens-family == 2.* , mainland-pretty , optparse-applicative , semigroups diff --git a/tensorflow-ops/src/TensorFlow/Gradient.hs b/tensorflow-ops/src/TensorFlow/Gradient.hs index 5e12e74..7f716e5 100644 --- a/tensorflow-ops/src/TensorFlow/Gradient.hs +++ b/tensorflow-ops/src/TensorFlow/Gradient.hs @@ -43,10 +43,10 @@ import Data.ProtoLens.TextFormat (showMessage) import Data.Set (Set) import Data.Text (Text) import Data.Tuple (swap) -import Lens.Family2 (Lens', view, (&), (^.), (.~), (%~)) +import Lens.Family2 (Lens', view, (&), (^.), (.~), (%~), under) import Lens.Family2.State.Strict (uses) import Lens.Family2.Stock (at, intAt) -import Lens.Family2.Unchecked (lens, iso) +import Lens.Family2.Unchecked (lens, adapter) import Prelude hiding (sum, tanh) import Text.Printf (printf) import qualified Data.Graph.Inductive.Basic as FGL @@ -244,7 +244,7 @@ _ `safeIndex` n | n < 0 = Nothing -- Copy of http://hackage.haskell.org/package/lens-3.9.0.2/docs/Control-Lens-Iso.html#v%3anon anon :: a -> (a -> Bool) -> Lens' (Maybe a) a -anon a p = iso (fromMaybe a) go where +anon a p = under (adapter (fromMaybe a) go) where go b | p b = Nothing | otherwise = Just b diff --git a/tensorflow-ops/src/TensorFlow/Variable.hs b/tensorflow-ops/src/TensorFlow/Variable.hs index 239bf0c..8bdbde9 100644 --- a/tensorflow-ops/src/TensorFlow/Variable.hs +++ b/tensorflow-ops/src/TensorFlow/Variable.hs @@ -11,7 +11,6 @@ {-# LANGUAGE RecursiveDo #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE NoMonadFailDesugaring #-} module TensorFlow.Variable ( Variable , variable diff --git a/tensorflow-ops/tensorflow-ops.cabal b/tensorflow-ops/tensorflow-ops.cabal index 7727989..e707ae6 100644 --- a/tensorflow-ops/tensorflow-ops.cabal +++ b/tensorflow-ops/tensorflow-ops.cabal @@ -21,13 +21,13 @@ library , TensorFlow.NN , TensorFlow.Queue , TensorFlow.Variable - build-depends: proto-lens >= 0.4.0 && < 0.6.0 + build-depends: proto-lens == 0.6.* , base >= 4.7 && < 5 , bytestring , fgl , mtl , data-default - , lens-family + , lens-family == 2.* , containers , tensorflow == 0.2.* , tensorflow-proto == 0.2.* diff --git a/tensorflow-ops/tests/EmbeddingOpsTest.hs b/tensorflow-ops/tests/EmbeddingOpsTest.hs index 135bde2..6fdaea2 100644 --- a/tensorflow-ops/tests/EmbeddingOpsTest.hs +++ b/tensorflow-ops/tests/EmbeddingOpsTest.hs @@ -15,7 +15,6 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE NoMonadFailDesugaring #-} -- | Tests for EmbeddingOps. module Main where diff --git a/tensorflow-ops/tests/GradientTest.hs b/tensorflow-ops/tests/GradientTest.hs index 7b28c40..20f3b01 100644 --- a/tensorflow-ops/tests/GradientTest.hs +++ b/tensorflow-ops/tests/GradientTest.hs @@ -16,7 +16,6 @@ {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE NoMonadFailDesugaring #-} import Data.Int (Int32, Int64) import Data.List (sort) @@ -33,7 +32,7 @@ import Control.Monad(forM_, replicateM, zipWithM) import Control.Monad.IO.Class (liftIO) import qualified TensorFlow.Core as TF -import qualified TensorFlow.GenOps.Core as TF (conv2DBackpropInput', max, maximum, resizeBilinear', tile, pad, batchToSpaceND, spaceToBatchND, squeeze, sqrt, slice, shape, diag, depthwiseConv2dNative', depthwiseConv2dNativeBackpropInput', batchMatMul, batchMatMul', sum, conjugateTranspose) +import qualified TensorFlow.GenOps.Core as TF (conv2DBackpropInput', max, maximum, resizeBilinear', tile, pad, batchToSpaceND, spaceToBatchND, squeeze, sqrt, slice, shape, diag, depthwiseConv2dNative', depthwiseConv2dNativeBackpropInput', batchMatMul, batchMatMul', conjugateTranspose) import qualified TensorFlow.Gradient as TF import qualified TensorFlow.Ops as TF hiding (zeroInitializedVariable, shape) import qualified TensorFlow.Output as TF diff --git a/tensorflow-proto/tensorflow-proto.cabal b/tensorflow-proto/tensorflow-proto.cabal index 7cafd13..5d453b8 100644 --- a/tensorflow-proto/tensorflow-proto.cabal +++ b/tensorflow-proto/tensorflow-proto.cabal @@ -176,9 +176,9 @@ library , Proto.Tensorflow.Core.Util.SavedTensorSlice_Fields , Proto.Tensorflow.Core.Util.TestLog , Proto.Tensorflow.Core.Util.TestLog_Fields - build-depends: proto-lens >= 0.4.0 && < 0.6.0 - , proto-lens-runtime >= 0.4.0 && < 0.6.0 - , proto-lens-protobuf-types >= 0.4.0 && < 0.6.0 + build-depends: proto-lens == 0.6.* + , proto-lens-runtime == 0.6.* + , proto-lens-protobuf-types == 0.6.* , base >= 4.7 && < 5 default-language: Haskell2010 include-dirs: . diff --git a/tensorflow-records/tests/Main.hs b/tensorflow-records/tests/Main.hs index b7473d8..d2207ae 100644 --- a/tensorflow-records/tests/Main.hs +++ b/tensorflow-records/tests/Main.hs @@ -17,7 +17,6 @@ module Main where import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL -import Data.Monoid ((<>)) import Data.Word (Word8) import Data.Serialize (runGet, runPut) import Test.Framework (Test, defaultMain) diff --git a/tensorflow/src/TensorFlow/Build.hs b/tensorflow/src/TensorFlow/Build.hs index 56e5d67..ed2e40d 100644 --- a/tensorflow/src/TensorFlow/Build.hs +++ b/tensorflow/src/TensorFlow/Build.hs @@ -65,12 +65,10 @@ import Data.ProtoLens.Message(defMessage) import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask) import Control.Monad.Fix (MonadFix(..)) import Control.Monad.IO.Class (MonadIO(..)) -import Control.Monad.Fail (MonadFail(..)) import Control.Monad.Trans.Class (MonadTrans(..)) import Control.Monad.Trans.State.Strict(StateT(..), mapStateT, evalStateT) import Data.Functor.Identity (Identity(..)) import qualified Data.Map.Strict as Map -import Data.Monoid ((<>)) import qualified Data.Set as Set import Data.Set (Set) import Data.String (IsString(..)) diff --git a/tensorflow/src/TensorFlow/Internal/VarInt.hs b/tensorflow/src/TensorFlow/Internal/VarInt.hs index a82bec9..d45e9f7 100644 --- a/tensorflow/src/TensorFlow/Internal/VarInt.hs +++ b/tensorflow/src/TensorFlow/Internal/VarInt.hs @@ -28,7 +28,6 @@ module TensorFlow.Internal.VarInt import Data.Attoparsec.ByteString as Parse import Data.Bits import Data.ByteString.Lazy.Builder as Builder -import Data.Monoid ((<>)) import Data.Word (Word64) -- | Decode an unsigned varint. diff --git a/tensorflow/src/TensorFlow/Nodes.hs b/tensorflow/src/TensorFlow/Nodes.hs index ba2f32d..277b824 100644 --- a/tensorflow/src/TensorFlow/Nodes.hs +++ b/tensorflow/src/TensorFlow/Nodes.hs @@ -26,7 +26,6 @@ module TensorFlow.Nodes where import Control.Applicative (liftA2, liftA3) import Data.Functor.Identity (Identity) import Data.Map.Strict (Map) -import Data.Monoid ((<>)) import Data.Set (Set) import Data.Text (Text) import qualified Data.Map.Strict as Map diff --git a/tensorflow/src/TensorFlow/Session.hs b/tensorflow/src/TensorFlow/Session.hs index 68acdac..f09998a 100644 --- a/tensorflow/src/TensorFlow/Session.hs +++ b/tensorflow/src/TensorFlow/Session.hs @@ -39,14 +39,12 @@ module TensorFlow.Session ( import Data.ProtoLens.Message(defMessage) import Control.Monad (forever, unless, void) -import Control.Monad.Fail (MonadFail(..)) import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask) import Control.Monad.IO.Class (MonadIO, liftIO) import Control.Monad.Trans.Class (MonadTrans, lift) import Control.Monad.Trans.Reader (ReaderT(..), ask, asks) import Data.ByteString (ByteString) import Data.Default (Default, def) -import Data.Monoid ((<>)) import Data.ProtoLens (showMessage) import Data.Set (Set) import Data.Text.Encoding (encodeUtf8) diff --git a/tensorflow/src/TensorFlow/Types.hs b/tensorflow/src/TensorFlow/Types.hs index be8e391..3ea73fb 100644 --- a/tensorflow/src/TensorFlow/Types.hs +++ b/tensorflow/src/TensorFlow/Types.hs @@ -69,15 +69,14 @@ import Data.Functor.Identity (Identity(..)) import Data.Complex (Complex) import Data.Int (Int8, Int16, Int32, Int64) import Data.Maybe (fromMaybe) -import Data.Monoid ((<>)) import Data.ProtoLens.TextFormat (showMessageShort) import Data.Proxy (Proxy(..)) import Data.String (IsString) import Data.Word (Word8, Word16, Word32, Word64) import Foreign.Storable (Storable) import GHC.Exts (Constraint, IsList(..)) -import Lens.Family2 (Lens', view, (&), (.~), (^..)) -import Lens.Family2.Unchecked (iso) +import Lens.Family2 (Lens', view, (&), (.~), (^..), under) +import Lens.Family2.Unchecked (adapter) import Text.Printf (printf) import qualified Data.Attoparsec.ByteString as Atto import Data.ByteString (ByteString) @@ -164,7 +163,7 @@ instance TensorType Int64 where tensorVal = int64Val integral :: Integral a => Lens' [Int32] [a] -integral = iso (fmap fromIntegral) (fmap fromIntegral) +integral = under (adapter (fmap fromIntegral) (fmap fromIntegral)) instance TensorType Word8 where tensorType _ = DT_UINT8 @@ -395,7 +394,7 @@ instance IsList Shape where toList (Shape ss) = toList ss protoShape :: Lens' TensorShapeProto Shape -protoShape = iso protoToShape shapeToProto +protoShape = under (adapter protoToShape shapeToProto) where protoToShape p = fromMaybe (error msg) (view protoMaybeShape p) where msg = "Can't convert TensorShapeProto with unknown rank to Shape: " @@ -403,7 +402,7 @@ protoShape = iso protoToShape shapeToProto shapeToProto s' = defMessage & protoMaybeShape .~ Just s' protoMaybeShape :: Lens' TensorShapeProto (Maybe Shape) -protoMaybeShape = iso protoToShape shapeToProto +protoMaybeShape = under (adapter protoToShape shapeToProto) where protoToShape :: TensorShapeProto -> Maybe Shape protoToShape p = diff --git a/tensorflow/tensorflow.cabal b/tensorflow/tensorflow.cabal index fe70b26..0c81268 100644 --- a/tensorflow/tensorflow.cabal +++ b/tensorflow/tensorflow.cabal @@ -36,7 +36,7 @@ library , TensorFlow.Types other-modules: TensorFlow.Internal.Raw build-tools: c2hs - build-depends: proto-lens >= 0.4.0 && < 0.6.0 + build-depends: proto-lens == 0.6.* , tensorflow-proto == 0.2.* , base >= 4.7 && < 5 , async @@ -46,7 +46,7 @@ library , data-default , exceptions , fgl - , lens-family + , lens-family == 2.* , mainland-pretty , mtl , semigroups