diff --git a/.gitignore b/.gitignore index 65b76a939..691b3d29c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -*.sw[po] +*.sw[pon] .stack-work dist .cabal-sandbox diff --git a/CHANGES.md b/CHANGES.md index 807f83eae..30e8d3d97 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,7 +7,10 @@ * Export `genericLength` and other generic list return functions. * Rename `msg` to `fatalErrorMessage`. * Export `ExceptT`, `ReaderT`, and `StateT` constructors. -* Export `NonEmpty` type and constructor for GHC 8.0. +* Mask `displayException` from default exports. +* Mask `stToIO` from default exports. +* Export `NonEmpty` type and constructor for Base 4.9 only. +* Export `Data.Semigroup` type and functions for Base 4.9 only. 0.1.9 ==== diff --git a/protolude.cabal b/protolude.cabal index c9cc2836f..d67ed6b96 100644 --- a/protolude.cabal +++ b/protolude.cabal @@ -69,11 +69,12 @@ library deepseq >= 1.3 && <1.5, containers >= 0.5 && <0.6, hashable >= 1.2 && <1.3, - mtl >= 2.1 && <2.3, - transformers >= 0.4 && <0.6, + transformers >= 0.2 && <0.6, text >= 1.2 && <1.3, stm >= 2.4 && <2.5, - bytestring >= 0.10 && <0.11 + bytestring >= 0.10 && <0.11, + mtl >= 2.1 && <2.3, + mtl-compat >= 0.2 && <0.3 if impl(ghc >= 7.8.0) build-depends: diff --git a/src/Exceptions.hs b/src/Exceptions.hs index ec629e2f0..f8c0adbf7 100644 --- a/src/Exceptions.hs +++ b/src/Exceptions.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} @@ -21,8 +22,13 @@ hush :: Alternative m => Either e a -> m a hush (Left _) = empty hush (Right x) = pure x +#if ( __GLASGOW_HASKELL__ >= 800 ) +note :: (MonadError e m) => e -> Maybe a -> m a +note err = maybe (throwError err) pure +#else note :: (MonadError e m, Applicative m) => e -> Maybe a -> m a note err = maybe (throwError err) pure +#endif tryIO :: MonadIO m => IO a -> ExceptT IOException m a tryIO = ExceptT . liftIO . Exception.try diff --git a/src/Protolude.hs b/src/Protolude.hs index 45394d1d2..af1efebf9 100644 --- a/src/Protolude.hs +++ b/src/Protolude.hs @@ -28,6 +28,7 @@ module Protolude ( #endif ) where +-- Protolude module exports. import List as X import Show as X import Bool as X @@ -39,6 +40,7 @@ import Applicative as X import Conv as X import Panic as X import Exceptions as X +import Semiring as X import Base as Base hiding ( putStr -- Overriden by Show.putStr @@ -100,11 +102,9 @@ import Data.Foldable as X hiding ( , product , sum ) -import Semiring as X import Data.Functor.Identity as X -#if ( __GLASGOW_HASKELL__ >= 800 ) -import Data.Monoid as X +#if MIN_VERSION_base(4,9,0) import Data.List.NonEmpty as X ( NonEmpty(..) , nonEmpty @@ -121,14 +121,14 @@ import Data.Semigroup as X ( , stimesIdempotentMonoid , mtimesDefault ) -#else -import Data.Monoid as X #endif -#if (__GLASGOW_HASKELL__ >= 710) -import Data.Bifunctor as X (Bifunctor(..)) -#else +import Data.Monoid as X + +#if !MIN_VERSION_base(4,8,0) import Bifunctor as X (Bifunctor(..)) +#else +import Data.Bifunctor as X (Bifunctor(..)) #endif -- Deepseq @@ -140,7 +140,14 @@ import Control.DeepSeq as X ( ) -- Data structures -import Data.Tuple as X +import Data.Tuple as X ( + fst + , snd + , curry + , uncurry + , swap + ) + import Data.List as X ( splitAt , break @@ -191,7 +198,7 @@ import Data.Sequence as X (Seq) import Data.IntMap as X (IntMap) import Data.IntSet as X (IntSet) -#if ( __GLASGOW_HASKELL__ >= 710 ) +#if !MIN_VERSION_base(4,7,0) import Data.Proxy as X ( Proxy(..) ) @@ -287,15 +294,32 @@ import Data.Word as X ( , Word32 , Word64 , Word8 -#if (__GLASGOW_HASKELL__ >= 710) , byteSwap16 , byteSwap32 , byteSwap64 -#endif ) -import Data.Either as X -import Data.Complex as X +import Data.Either as X ( + Either(..) + , either + , lefts + , rights + , isLeft + , isRight + , partitionEithers + ) + +import Data.Complex as X ( + Complex(..) + , realPart + , imagPart + , mkPolar + , cis + , polar + , magnitude + , phase + , conjugate + ) import Data.Char as X (chr) import Data.Bool as X hiding (bool) import Data.Maybe as X hiding (fromJust) @@ -307,7 +331,7 @@ import Data.Function as X ( , flip , fix , on -#if ( __GLASGOW_HASKELL__ >= 800 ) +#if MIN_VERSION_base(4,8,0) , (&) #endif ) @@ -375,8 +399,16 @@ import Data.Text.Encoding.Error as X ( ) -- IO -import System.Exit as X import System.Environment as X (getArgs) +import System.Exit as X ( + ExitCode(..) + , exitWith + , exitFailure + , exitSuccess +#if MIN_VERSION_base(4,8,0) + , die +#endif + ) import System.IO as X ( Handle , FilePath @@ -389,7 +421,11 @@ import System.IO as X ( ) -- ST -import Control.Monad.ST as X +import Control.Monad.ST as X ( + ST + , runST + , fixST + ) -- Concurrency and Parallelism import Control.Exception as X hiding ( @@ -397,7 +433,6 @@ import Control.Exception as X hiding ( , throwIO , throwTo , assert - , displayException , Handler(..) ) diff --git a/stack-7.10.yaml b/stack-7.10.yaml new file mode 100644 index 000000000..3369f2990 --- /dev/null +++ b/stack-7.10.yaml @@ -0,0 +1,6 @@ +resolver: lts-6.24 +packages: +- '.' +extra-deps: +flags: {} +extra-package-dbs: [] diff --git a/stack-7.8.yaml b/stack-7.8.yaml new file mode 100644 index 000000000..b3ab0af8d --- /dev/null +++ b/stack-7.8.yaml @@ -0,0 +1,6 @@ +resolver: lts-2.22 +packages: +- '.' +extra-deps: +flags: {} +extra-package-dbs: [] diff --git a/stack-8.0.yaml b/stack-8.0.yaml new file mode 100644 index 000000000..86c184384 --- /dev/null +++ b/stack-8.0.yaml @@ -0,0 +1,6 @@ +resolver: lts-7.8 +packages: +- '.' +extra-deps: +flags: {} +extra-package-dbs: [] diff --git a/stack.yaml b/stack.yaml index bb517b9f0..3be2e7d0e 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-6.2 +resolver: lts-7.14 packages: - '.' extra-deps: diff --git a/test_stack_lts.sh b/test_stack_lts.sh new file mode 100755 index 000000000..bef4931b3 --- /dev/null +++ b/test_stack_lts.sh @@ -0,0 +1,3 @@ +STACK_YAML=stack-7.8.yaml stack build +STACK_YAML=stack-7.10.yaml stack build +STACK_YAML=stack-8.0.yaml stack build