Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tweak the test suite
  • Loading branch information
RyanGlScott committed Jan 25, 2016
1 parent b506607 commit c91575c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 62 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.markdown
@@ -1,6 +1,7 @@
next
5.2.1
----
* Added `Bifoldable` and `Bitraversable` instances for `Constant` from `transformers`
* `Data.Bifunctor.TH` now compiles warning-free on GHC 8.0

5.2
-----
Expand Down
23 changes: 9 additions & 14 deletions bifunctors.cabal
@@ -1,6 +1,6 @@
name: bifunctors
category: Data, Functors
version: 5.2
version: 5.2.1
license: BSD3
cabal-version: >= 1.8
license-file: LICENSE
Expand Down Expand Up @@ -88,17 +88,12 @@ test-suite bifunctors-spec
hs-source-dirs: tests
main-is: Spec.hs
other-modules: BifunctorSpec

if impl(ghc >= 8)
buildable: False
else
ghc-options: -Wall

build-depends:
base >= 4 && < 5,
bifunctors,
hspec >= 1.8,
QuickCheck >= 2 && < 3,
transformers,
transformers-compat
ghc-options: -Wall
build-depends:
base >= 4 && < 5,
bifunctors,
hspec >= 1.8,
QuickCheck >= 2 && < 3,
transformers,
transformers-compat

29 changes: 3 additions & 26 deletions src/Data/Bifunctor/TH.hs
Expand Up @@ -45,12 +45,12 @@ module Data.Bifunctor.TH (
import Control.Monad (guard, unless, when)

import Data.Bifunctor.TH.Internal
#if MIN_VERSION_template_haskell(2,8,0) && !(MIN_VERSION_template_haskell(2,10,0))
import Data.Foldable (foldr')
#endif
import Data.List
import qualified Data.Map as Map (fromList, keys, lookup)
import Data.Maybe
#if __GLASGOW_HASKELL__ < 710 && MIN_VERSION_template_haskell(2,8,0)
import qualified Data.Set as Set
#endif

import Language.Haskell.TH.Lib
import Language.Haskell.TH.Ppr
Expand Down Expand Up @@ -130,24 +130,6 @@ Note that there are some limitations:
1. @v1@ and @v2@ must be distinct type variables.
2. Neither @v1@ not @v2@ must be mentioned in any of @e1@, ..., @e2@.
* In GHC 7.8, a bug exists that can cause problems when a data family declaration and
one of its data instances use different type variables, e.g.,
@
data family Foo a b c
data instance Foo Int y z = Foo Int y z
$(deriveBifunctor 'Foo)
@
To avoid this issue, it is recommened that you use the same type variables in the
same positions in which they appeared in the data family declaration:
@
data family Foo a b c
data instance Foo Int b c = Foo Int b c
$(deriveBifunctor 'Foo)
@
-}

{- $make
Expand Down Expand Up @@ -604,11 +586,6 @@ buildTypeInstance biClass parentName dataCxt tvbs (Just instTysAndKinds) = do
go (ConT n) | n == starKindName = StarT
go t = t

-- It's quite awkward to import * from GHC.Prim, so we'll just
-- hack our way around it.
starKindName :: Name
starKindName = mkNameG_tc "ghc-prim" "GHC.Prim" "*"

-- If we run this code with GHC 7.8, we might have to generate extra type
-- variables to compensate for any type variables that Template Haskell
-- eta-reduced away.
Expand Down
42 changes: 21 additions & 21 deletions tests/BifunctorSpec.hs
Expand Up @@ -64,12 +64,12 @@ data StrangeFunctions a b c
| T9 (IntFun b c) -- type synonyms

data StrangeGADT a b where
T10 :: Ord b => b -> StrangeGADT a b
T11 :: Int -> StrangeGADT a Int
T12 :: c ~ Int => c -> StrangeGADT a Int
T13 :: b ~ Int => Int -> StrangeGADT a b
T14 :: b ~ Int => b -> StrangeGADT a b
T15 :: (b ~ c, c ~ Int) => Int -> c -> StrangeGADT a b
T10 :: Ord d => d -> StrangeGADT c d
T11 :: Int -> StrangeGADT e Int
T12 :: c ~ Int => c -> StrangeGADT f Int
T13 :: i ~ Int => Int -> StrangeGADT h i
T14 :: k ~ Int => k -> StrangeGADT j k
T15 :: (n ~ c, c ~ Int) => Int -> c -> StrangeGADT m n

data NotPrimitivelyRecursive a b
= S1 (NotPrimitivelyRecursive (a,a) (b, a))
Expand All @@ -94,51 +94,51 @@ data Existential a b

-- Data families

data family StrangeFam a b c
data family StrangeFam x y z
data instance StrangeFam a b c
= T1Fam a b c
| T2Fam [a] [b] [c] -- lists
| T3Fam [[a]] [[b]] [[c]] -- nested lists
| T4Fam (c,(b,b),(c,c)) -- tuples
| T5Fam ([c],Strange a b c) -- tycons

data family StrangeFunctionsFam a b c
data family StrangeFunctionsFam x y z
data instance StrangeFunctionsFam a b c
= T6Fam (a -> c) -- function types
| T7Fam (a -> (c,a)) -- functions and tuples
| T8Fam ((b -> a) -> c) -- continuation
| T9Fam (IntFun b c) -- type synonyms

data family StrangeGADTFam a b
data family StrangeGADTFam x y
data instance StrangeGADTFam a b where
T10Fam :: Ord b => b -> StrangeGADTFam a b
T11Fam :: Int -> StrangeGADTFam a Int
T12Fam :: c ~ Int => c -> StrangeGADTFam a Int
T13Fam :: b ~ Int => Int -> StrangeGADTFam a b
T14Fam :: b ~ Int => b -> StrangeGADTFam a b
T15Fam :: (b ~ c, c ~ Int) => Int -> c -> StrangeGADTFam a b

data family NotPrimitivelyRecursiveFam a b
T10Fam :: Ord d => d -> StrangeGADTFam c d
T11Fam :: Int -> StrangeGADTFam e Int
T12Fam :: c ~ Int => c -> StrangeGADTFam f Int
T13Fam :: i ~ Int => Int -> StrangeGADTFam h i
T14Fam :: k ~ Int => k -> StrangeGADTFam j k
T15Fam :: (n ~ c, c ~ Int) => Int -> c -> StrangeGADTFam m n

data family NotPrimitivelyRecursiveFam x y
data instance NotPrimitivelyRecursiveFam a b
= S1Fam (NotPrimitivelyRecursive (a,a) (b, a))
| S2Fam a
| S3Fam b

data family OneTwoComposeFam (f :: * -> *) (g :: * -> * -> *) a b
data family OneTwoComposeFam (j :: * -> *) (k :: * -> * -> *) x y
newtype instance OneTwoComposeFam f g a b = OneTwoComposeFam (f (g a b))
deriving (Arbitrary, Eq, Show)

data family ComplexConstraintFam (f :: * -> * -> * -> *) (g :: * -> *) a b
data family ComplexConstraintFam (j :: * -> * -> * -> *) (k :: * -> *) x y
newtype instance ComplexConstraintFam f g a b = ComplexConstraintFam (f Int Int (g a,a,b))

data family UniversalFam a b
data family UniversalFam x y
data instance UniversalFam a b
= UniversalFam (forall b. (b,[a]))
| Universal2Fam (forall f. Bifunctor f => f a b)
| Universal3Fam (forall a. Maybe a) -- reuse a
| NotReallyUniversalFam (forall b. a)

data family ExistentialFam a b
data family ExistentialFam x y
data instance ExistentialFam a b
= forall a. ExistentialListFam [a]
| forall f. Bitraversable f => ExistentialFunctorFam (f a b)
Expand Down

0 comments on commit c91575c

Please sign in to comment.