From 8d5ef502be1d7141105afd4c9f667e875204fe55 Mon Sep 17 00:00:00 2001 From: Claude Heiland-Allen Date: Fri, 14 Dec 2018 18:40:41 +0000 Subject: [PATCH] support GHC 7.10 - no `Data.Kind` module in this old GHC, so use CPP for conditional include - also use CPP to define `Type=*` for backward compatibility --- grenade.cabal | 1 + src/Grenade/Core/Layer.hs | 3 +++ src/Grenade/Core/Network.hs | 3 +++ src/Grenade/Layers/Concat.hs | 4 ++++ src/Grenade/Layers/Convolution.hs | 2 ++ src/Grenade/Layers/Crop.hs | 2 ++ src/Grenade/Layers/Deconvolution.hs | 2 ++ src/Grenade/Layers/Merge.hs | 3 +++ src/Grenade/Layers/Pad.hs | 2 ++ src/Grenade/Layers/Pooling.hs | 2 ++ src/Grenade/Recurrent/Core/Layer.hs | 3 +++ src/Grenade/Recurrent/Core/Network.hs | 3 +++ src/Grenade/Recurrent/Layers/BasicRecurrent.hs | 3 +++ src/Grenade/Recurrent/Layers/ConcatRecurrent.hs | 3 +++ src/Grenade/Recurrent/Layers/LSTM.hs | 3 +++ 15 files changed, 39 insertions(+) diff --git a/grenade.cabal b/grenade.cabal index ae84102..784c5ff 100644 --- a/grenade.cabal +++ b/grenade.cabal @@ -57,6 +57,7 @@ library if impl(ghc < 8.0) ghc-options: -fno-warn-incomplete-patterns + cpp-options: -DType=* if impl(ghc >= 8.6) default-extensions: NoStarIsType diff --git a/src/Grenade/Core/Layer.hs b/src/Grenade/Core/Layer.hs index 7a9f2f2..db62808 100644 --- a/src/Grenade/Core/Layer.hs +++ b/src/Grenade/Core/Layer.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeOperators #-} @@ -41,7 +42,9 @@ import Control.Monad.Random ( MonadRandom ) import Data.List ( foldl' ) +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import Grenade.Core.Shape import Grenade.Core.LearningParameters diff --git a/src/Grenade/Core/Network.hs b/src/Grenade/Core/Network.hs index ec1a2a2..f7b1f00 100644 --- a/src/Grenade/Core/Network.hs +++ b/src/Grenade/Core/Network.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE GADTs #-} @@ -36,7 +37,9 @@ import Data.Singletons import Data.Singletons.Prelude import Data.Serialize +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import Grenade.Core.Layer import Grenade.Core.LearningParameters diff --git a/src/Grenade/Layers/Concat.hs b/src/Grenade/Layers/Concat.hs index 1ea18ec..ca3eba6 100644 --- a/src/Grenade/Layers/Concat.hs +++ b/src/Grenade/Layers/Concat.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeOperators #-} @@ -26,7 +27,10 @@ import Data.Serialize import Data.Singletons import GHC.TypeLits + +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import Grenade.Core diff --git a/src/Grenade/Layers/Convolution.hs b/src/Grenade/Layers/Convolution.hs index 13ca165..11dc9c1 100644 --- a/src/Grenade/Layers/Convolution.hs +++ b/src/Grenade/Layers/Convolution.hs @@ -36,7 +36,9 @@ import GHC.TypeLits hiding (natVal) #else import GHC.TypeLits #endif +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import Numeric.LinearAlgebra hiding ( uniformSample, konst ) import qualified Numeric.LinearAlgebra as LA diff --git a/src/Grenade/Layers/Crop.hs b/src/Grenade/Layers/Crop.hs index a0cf181..0634bca 100644 --- a/src/Grenade/Layers/Crop.hs +++ b/src/Grenade/Layers/Crop.hs @@ -28,7 +28,9 @@ import GHC.TypeLits hiding (natVal) #else import GHC.TypeLits #endif +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import Grenade.Core import Grenade.Layers.Internal.Pad diff --git a/src/Grenade/Layers/Deconvolution.hs b/src/Grenade/Layers/Deconvolution.hs index 0f4597a..8e3926b 100644 --- a/src/Grenade/Layers/Deconvolution.hs +++ b/src/Grenade/Layers/Deconvolution.hs @@ -40,7 +40,9 @@ import GHC.TypeLits hiding (natVal) #else import GHC.TypeLits #endif +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import Numeric.LinearAlgebra hiding ( uniformSample, konst ) import qualified Numeric.LinearAlgebra as LA diff --git a/src/Grenade/Layers/Merge.hs b/src/Grenade/Layers/Merge.hs index 8a9c814..f5333f2 100644 --- a/src/Grenade/Layers/Merge.hs +++ b/src/Grenade/Layers/Merge.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeOperators #-} @@ -23,7 +24,9 @@ import Data.Serialize import Data.Singletons +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import Grenade.Core diff --git a/src/Grenade/Layers/Pad.hs b/src/Grenade/Layers/Pad.hs index 788153a..652a778 100644 --- a/src/Grenade/Layers/Pad.hs +++ b/src/Grenade/Layers/Pad.hs @@ -28,7 +28,9 @@ import GHC.TypeLits hiding (natVal) #else import GHC.TypeLits #endif +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import Grenade.Core import Grenade.Layers.Internal.Pad diff --git a/src/Grenade/Layers/Pooling.hs b/src/Grenade/Layers/Pooling.hs index ea8e001..ecfb9ee 100644 --- a/src/Grenade/Layers/Pooling.hs +++ b/src/Grenade/Layers/Pooling.hs @@ -29,7 +29,9 @@ import GHC.TypeLits hiding (natVal) #else import GHC.TypeLits #endif +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import Grenade.Core import Grenade.Layers.Internal.Pooling diff --git a/src/Grenade/Recurrent/Core/Layer.hs b/src/Grenade/Recurrent/Core/Layer.hs index 2611cbc..9124371 100644 --- a/src/Grenade/Recurrent/Core/Layer.hs +++ b/src/Grenade/Recurrent/Core/Layer.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MultiParamTypeClasses #-} @@ -8,7 +9,9 @@ module Grenade.Recurrent.Core.Layer ( , RecurrentUpdateLayer (..) ) where +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import Grenade.Core diff --git a/src/Grenade/Recurrent/Core/Network.hs b/src/Grenade/Recurrent/Core/Network.hs index 8ad0c1b..62df741 100644 --- a/src/Grenade/Recurrent/Core/Network.hs +++ b/src/Grenade/Recurrent/Core/Network.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeOperators #-} @@ -32,7 +33,9 @@ import Data.Singletons ( SingI ) import Data.Singletons.Prelude ( Head, Last ) import Data.Serialize +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import Grenade.Core import Grenade.Recurrent.Core.Layer diff --git a/src/Grenade/Recurrent/Layers/BasicRecurrent.hs b/src/Grenade/Recurrent/Layers/BasicRecurrent.hs index 3be165e..5dfa8e7 100644 --- a/src/Grenade/Recurrent/Layers/BasicRecurrent.hs +++ b/src/Grenade/Recurrent/Layers/BasicRecurrent.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE RecordWildCards #-} @@ -18,7 +19,9 @@ import Control.Monad.Random ( MonadRandom, getRandom ) import Data.Singletons.TypeLits +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import Numeric.LinearAlgebra.Static diff --git a/src/Grenade/Recurrent/Layers/ConcatRecurrent.hs b/src/Grenade/Recurrent/Layers/ConcatRecurrent.hs index 71e34d4..65aa197 100644 --- a/src/Grenade/Recurrent/Layers/ConcatRecurrent.hs +++ b/src/Grenade/Recurrent/Layers/ConcatRecurrent.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeOperators #-} @@ -27,7 +28,9 @@ import Data.Serialize import Data.Singletons import GHC.TypeLits +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import Grenade.Core import Grenade.Recurrent.Core diff --git a/src/Grenade/Recurrent/Layers/LSTM.hs b/src/Grenade/Recurrent/Layers/LSTM.hs index 5f9b4bc..f0ac79a 100644 --- a/src/Grenade/Recurrent/Layers/LSTM.hs +++ b/src/Grenade/Recurrent/Layers/LSTM.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} @@ -23,7 +24,9 @@ import Data.Proxy import Data.Serialize import Data.Singletons.TypeLits +#if MIN_VERSION_base(4,9,0) import Data.Kind (Type) +#endif import qualified Numeric.LinearAlgebra as LA import Numeric.LinearAlgebra.Static