Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions strict/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.4.0.2 -- UNRELEASED

- Add a `boot` flag for a minimal dependency footprint. This is intended for
testing purposes e.g. to break dependency cycles in GHC bootstrapping libs.

# 0.4.0.1

- Allow `bytestring-0.11`
Expand Down
4 changes: 4 additions & 0 deletions strict/src/Data/Strict/Classes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ import qualified Control.Monad.Trans.Writer.Lazy as L
import qualified Control.Monad.Trans.Writer.Strict as S
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as LBS
#ifdef MIN_VERSION_text
import qualified Data.Text as T
import qualified Data.Text.Lazy as LT
#endif

-- | Ad hoc conversion between "strict" and "lazy" versions of a structure.
--
Expand Down Expand Up @@ -78,9 +80,11 @@ instance Strict LBS.ByteString BS.ByteString where
toLazy = LBS.fromChunks . L.return {- singleton -}
#endif

#ifdef MIN_VERSION_text
instance Strict LT.Text T.Text where
toStrict = LT.toStrict
toLazy = LT.fromStrict
#endif

instance Strict (L.ST s a) (S.ST s a) where
toStrict = L.lazyToStrictST
Expand Down
8 changes: 8 additions & 0 deletions strict/src/Data/Strict/Either.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ import qualified Prelude as L
import Control.DeepSeq (NFData (..))
import Data.Bifoldable (Bifoldable (..))
import Data.Bifunctor (Bifunctor (..))
#ifdef MIN_VERSION_binary
import Data.Binary (Binary (..))
#endif
import Data.Bitraversable (Bitraversable (..))
#ifdef MIN_VERSION_hashable
import Data.Hashable (Hashable(..))
import Data.Hashable.Lifted (Hashable1 (..), Hashable2 (..))
#endif
import GHC.Generics (Generic)
import Data.Data (Data (..), Typeable)

Expand Down Expand Up @@ -174,10 +178,12 @@ instance NFData2 Either where
liftRnf2 rnfA rnfB = liftRnf2 rnfA rnfB . toLazy
#endif

#ifdef MIN_VERSION_binary
-- binary
instance (Binary a, Binary b) => Binary (Either a b) where
put = put . toLazy
get = toStrict <$> get
#endif

-- bifunctors
instance Bifunctor Either where
Expand All @@ -199,6 +205,7 @@ instance Bitraversable Either where
bitraverse f _ (Left a) = fmap Left (f a)
bitraverse _ g (Right b) = fmap Right (g b)

#ifdef MIN_VERSION_hashable
-- hashable
instance (Hashable a, Hashable b) => Hashable (Either a b) where
hashWithSalt salt = hashWithSalt salt . toLazy
Expand All @@ -208,6 +215,7 @@ instance (Hashable a) => Hashable1 (Either a) where

instance Hashable2 Either where
liftHashWithSalt2 hashA hashB salt = liftHashWithSalt2 hashA hashB salt . toLazy
#endif

-- assoc
#ifdef MIN_VERSION_assoc
Expand Down
8 changes: 8 additions & 0 deletions strict/src/Data/Strict/Maybe.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ import Data.Traversable (Traversable (..))
import qualified Prelude as L

import Control.DeepSeq (NFData (..))
#ifdef MIN_VERSION_binary
import Data.Binary (Binary (..))
#endif
#ifdef MIN_VERSION_hashable
import Data.Hashable (Hashable(..))
import Data.Hashable.Lifted (Hashable1 (..))
#endif
import GHC.Generics (Generic)
import Data.Data (Data (..), Typeable)

Expand Down Expand Up @@ -190,17 +194,21 @@ instance NFData1 Maybe where
liftRnf rnfA = liftRnf rnfA . toLazy
#endif

#ifdef MIN_VERSION_binary
-- binary
instance Binary a => Binary (Maybe a) where
put = put . toLazy
get = toStrict <$> get
#endif

#ifdef MIN_VERSION_hashable
-- hashable
instance Hashable a => Hashable (Maybe a) where
hashWithSalt salt = hashWithSalt salt . toLazy

instance Hashable1 Maybe where
liftHashWithSalt hashA salt = liftHashWithSalt hashA salt . toLazy
#endif

-- Data.Functor.Classes
#ifdef LIFTED_FUNCTOR_CLASSES
Expand Down
8 changes: 8 additions & 0 deletions strict/src/Data/Strict/These.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ import Control.Applicative (Applicative (..), (<$>))
import Control.DeepSeq (NFData (..))
import Data.Bifoldable (Bifoldable (..))
import Data.Bifunctor (Bifunctor (..))
#ifdef MIN_VERSION_binary
import Data.Binary (Binary (..))
#endif
import Data.Bitraversable (Bitraversable (..))
import Data.Data (Data, Typeable)
import Data.Either (partitionEithers)
import Data.Foldable (Foldable (..))
#ifdef MIN_VERSION_hashable
import Data.Hashable (Hashable (..))
import Data.Hashable.Lifted (Hashable1 (..), Hashable2 (..))
#endif
import Data.List.NonEmpty (NonEmpty (..))
import Data.Monoid (Monoid (..))
import Data.Semigroup (Semigroup (..))
Expand Down Expand Up @@ -401,14 +405,17 @@ instance NFData2 These where
-- binary
-------------------------------------------------------------------------------

#ifdef MIN_VERSION_binary
instance (Binary a, Binary b) => Binary (These a b) where
put = put . toLazy
get = toStrict <$> get
#endif

-------------------------------------------------------------------------------
-- hashable
-------------------------------------------------------------------------------

#ifdef MIN_VERSION_hashable
instance (Hashable a, Hashable b) => Hashable (These a b) where
hashWithSalt salt (This a) =
salt `hashWithSalt` (0 :: Int) `hashWithSalt` a
Expand All @@ -432,3 +439,4 @@ instance Hashable2 These where
(salt `hashWithSalt` (1 :: Int)) `hashB` b
liftHashWithSalt2 hashA hashB salt (These a b) =
(salt `hashWithSalt` (2 :: Int)) `hashA` a `hashB` b
#endif
8 changes: 8 additions & 0 deletions strict/src/Data/Strict/Tuple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@ import qualified Prelude as L
import Control.DeepSeq (NFData (..))
import Data.Bifoldable (Bifoldable (..))
import Data.Bifunctor (Bifunctor (..))
#ifdef MIN_VERSION_binary
import Data.Binary (Binary (..))
#endif
import Data.Bitraversable (Bitraversable (..))
#ifdef MIN_VERSION_hashable
import Data.Hashable (Hashable(..))
import Data.Hashable.Lifted (Hashable1 (..), Hashable2 (..))
#endif
import Data.Ix (Ix (..))
import GHC.Generics (Generic)
import Data.Data (Data (..), Typeable)
Expand Down Expand Up @@ -182,10 +186,12 @@ instance NFData2 Pair where
liftRnf2 rnfA rnfB = liftRnf2 rnfA rnfB . toLazy
#endif

#ifdef MIN_VERSION_binary
-- binary
instance (Binary a, Binary b) => Binary (Pair a b) where
put = put . toLazy
get = toStrict <$> get
#endif

-- bifunctors
instance Bifunctor Pair where
Expand All @@ -202,6 +208,7 @@ instance Bifoldable Pair where
instance Bitraversable Pair where
bitraverse f g (a :!: b) = (:!:) <$> f a <*> g b

#ifdef MIN_VERSION_hashable
-- hashable
instance (Hashable a, Hashable b) => Hashable (Pair a b) where
hashWithSalt salt = hashWithSalt salt . toLazy
Expand All @@ -211,6 +218,7 @@ instance (Hashable a) => Hashable1 (Pair a) where

instance Hashable2 Pair where
liftHashWithSalt2 hashA hashB salt = liftHashWithSalt2 hashA hashB salt . toLazy
#endif

-- assoc
#ifdef MIN_VERSION_assoc
Expand Down
18 changes: 13 additions & 5 deletions strict/strict.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: strict
Version: 0.4.0.1
Version: 0.4.0.2
Synopsis: Strict data types and String IO.
Category: Data, System
Description:
Expand Down Expand Up @@ -72,18 +72,20 @@ flag assoc
manual: True
default: True

flag boot
description: Build with minimal dependencies
manual: True
default: False

library
default-language: Haskell2010
hs-source-dirs: src
ghc-options: -Wall

build-depends:
base >= 4.5.0.0 && < 5
, binary >= 0.5.1.0 && < 0.9
, bytestring >= 0.9.2.1 && < 0.12
, deepseq >= 1.3.0.0 && < 1.5
, hashable >= 1.2.7.0 && < 1.4
, text >= 1.2.3.0 && < 1.3
, these >= 1.1.1.1 && < 1.2
, transformers >= 0.3.0.0 && < 0.6
, ghc-prim
Expand All @@ -101,9 +103,15 @@ library
build-depends:
bifunctors >= 5.5.2 && < 5.6

if flag(assoc)
if flag(assoc) && !flag(boot)
build-depends: assoc >= 1.0.1 && < 1.1

if !flag(boot)
build-depends:
binary >= 0.5.1.0 && < 0.9
, hashable >= 1.2.7.0 && < 1.4
, text >= 1.2.3.0 && < 1.3

exposed-modules:
Data.Strict
Data.Strict.Classes
Expand Down