Skip to content

add a flag "boot" for minimal dependencies, to be used by certain boot libs #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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 these/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.1.1.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.

# 1.1.1.1

- Workaround GCC-4 C-preprocessor bug
Expand Down
8 changes: 8 additions & 0 deletions these/src/Data/These.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,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 @@ -424,6 +428,7 @@ instance NFData2 These where
-- binary
-------------------------------------------------------------------------------

#ifdef MIN_VERSION_binary
-- | @since 0.7.1
instance (Binary a, Binary b) => Binary (These a b) where
put (This a) = put (0 :: Int) >> put a
Expand All @@ -437,11 +442,13 @@ instance (Binary a, Binary b) => Binary (These a b) where
1 -> That <$> get
2 -> These <$> get <*> get
_ -> fail "Invalid These index"
#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 @@ -467,3 +474,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
16 changes: 11 additions & 5 deletions these/these.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: >=1.10
name: these
version: 1.1.1.1
version: 1.1.1.2
x-revision: 1
synopsis: An either-or-both data type.
homepage: https://github.com/haskellari/these
Expand Down Expand Up @@ -55,6 +55,11 @@ flag assoc
manual: True
default: True

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

library
default-language: Haskell2010
ghc-options: -Wall
Expand All @@ -71,11 +76,12 @@ library
-- ghc boot libs
build-depends:
base >=4.5.1.0 && <4.16
, binary >=0.5.1.0 && <0.10
, deepseq >=1.3.0.0 && <1.5

-- other dependencies
build-depends: hashable >=1.2.7.0 && <1.4
if !flag(boot)
build-depends:
binary >=0.5.1.0 && <0.10
, hashable >=1.2.7.0 && <1.4

if impl(ghc <7.5)
build-depends: ghc-prim
Expand All @@ -93,7 +99,7 @@ library
if impl(ghc >=7.10)
build-depends: transformers >=0.4.2.0

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

x-docspec-extra-packages: lens