-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Cabal instances from cabal-install TreeDiffInstances into it. Remove defaultToExprViaShow to get better diffs and dumps Also rename Cabal-QuickCheck (proper case), and add GenericArbitrary module there.
- Loading branch information
Showing
59 changed files
with
2,933 additions
and
1,797 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Cabal/Cabal-QuickCheck/src/Test/QuickCheck/GenericArbitrary.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{-# LANGUAGE CPP #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
module Test.QuickCheck.GenericArbitrary ( | ||
genericArbitrary, | ||
GArbitrary, | ||
) where | ||
|
||
import GHC.Generics | ||
import Test.QuickCheck | ||
|
||
#if !MIN_VERSION_base(4,8,0) | ||
import Control.Applicative (pure, (<$>), (<*>)) | ||
#endif | ||
|
||
-- Generic arbitary for non-recursive types | ||
genericArbitrary :: (Generic a, GArbitrary (Rep a)) => Gen a | ||
genericArbitrary = fmap to garbitrary | ||
|
||
class GArbitrary f where | ||
garbitrary :: Gen (f ()) | ||
|
||
class GArbitrarySum f where | ||
garbitrarySum :: [Gen (f ())] | ||
|
||
class GArbitraryProd f where | ||
garbitraryProd :: Gen (f ()) | ||
|
||
instance (GArbitrarySum f, i ~ D) => GArbitrary (M1 i c f) where | ||
garbitrary = fmap M1 (oneof garbitrarySum) | ||
|
||
instance (GArbitraryProd f, i ~ C) => GArbitrarySum (M1 i c f) where | ||
garbitrarySum = [fmap M1 garbitraryProd] | ||
|
||
instance (GArbitrarySum f, GArbitrarySum g) => GArbitrarySum (f :+: g) where | ||
garbitrarySum = map (fmap L1) garbitrarySum ++ map (fmap R1) garbitrarySum | ||
|
||
instance (GArbitraryProd f, i ~ S) => GArbitraryProd (M1 i c f) where | ||
garbitraryProd = fmap M1 garbitraryProd | ||
|
||
instance GArbitraryProd U1 where | ||
garbitraryProd = pure U1 | ||
|
||
instance (GArbitraryProd f, GArbitraryProd g) => GArbitraryProd (f :*: g) where | ||
garbitraryProd = (:*:) <$> garbitraryProd <*> garbitraryProd | ||
|
||
instance (Arbitrary a) => GArbitraryProd (K1 i a) where | ||
garbitraryProd = fmap K1 arbitrary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
cabal-version: 2.2 | ||
name: Cabal-tree-diff | ||
version: 3.3.0.0 | ||
synopsis: QuickCheck instances for types in Cabal | ||
category: Testing | ||
description: Provides tree-diff ToExpr instances for some types in Cabal | ||
|
||
library | ||
default-language: Haskell2010 | ||
hs-source-dirs: src | ||
ghc-options: -Wall | ||
build-depends: | ||
, base | ||
, Cabal ^>=3.3.0.0 | ||
, tree-diff ^>=0.1 | ||
|
||
exposed-modules: Data.TreeDiff.Instances.Cabal | ||
other-modules: | ||
Data.TreeDiff.Instances.CabalLanguage | ||
Data.TreeDiff.Instances.CabalSPDX | ||
Data.TreeDiff.Instances.CabalVersion |
136 changes: 136 additions & 0 deletions
136
Cabal/Cabal-tree-diff/src/Data/TreeDiff/Instances/Cabal.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
{-# LANGUAGE CPP #-} | ||
#if __GLASGOW_HASKELL__ >= 800 | ||
{-# OPTIONS_GHC -freduction-depth=0 #-} | ||
#else | ||
{-# OPTIONS_GHC -fcontext-stack=151 #-} | ||
#endif | ||
{-# OPTIONS_GHC -fno-warn-orphans #-} | ||
module Data.TreeDiff.Instances.Cabal () where | ||
|
||
import Data.TreeDiff | ||
|
||
import Data.TreeDiff.Instances.CabalLanguage () | ||
import Data.TreeDiff.Instances.CabalSPDX () | ||
import Data.TreeDiff.Instances.CabalVersion () | ||
|
||
------------------------------------------------------------------------------- | ||
|
||
import Distribution.Backpack (OpenModule, OpenUnitId) | ||
import Distribution.CabalSpecVersion (CabalSpecVersion) | ||
import Distribution.Compiler (CompilerFlavor, CompilerId, PerCompilerFlavor) | ||
import Distribution.InstalledPackageInfo (AbiDependency, ExposedModule, InstalledPackageInfo) | ||
import Distribution.ModuleName (ModuleName) | ||
import Distribution.Package (Dependency, PackageIdentifier, PackageName) | ||
import Distribution.PackageDescription | ||
import Distribution.Simple.Compiler (DebugInfoLevel, OptimisationLevel, ProfDetailLevel) | ||
import Distribution.Simple.Flag (Flag) | ||
import Distribution.Simple.InstallDirs | ||
import Distribution.Simple.InstallDirs.Internal | ||
import Distribution.Simple.Setup (HaddockTarget, TestShowDetails) | ||
import Distribution.System | ||
import Distribution.Types.AbiHash (AbiHash) | ||
import Distribution.Types.ComponentId (ComponentId) | ||
import Distribution.Types.CondTree | ||
import Distribution.Types.ExecutableScope | ||
import Distribution.Types.ExeDependency | ||
import Distribution.Types.ForeignLib | ||
import Distribution.Types.ForeignLibOption | ||
import Distribution.Types.ForeignLibType | ||
import Distribution.Types.IncludeRenaming (IncludeRenaming) | ||
import Distribution.Types.LegacyExeDependency | ||
import Distribution.Types.LibraryVisibility (LibraryVisibility) | ||
import Distribution.Types.Mixin | ||
import Distribution.Types.PackageVersionConstraint | ||
import Distribution.Types.PkgconfigDependency (PkgconfigDependency) | ||
import Distribution.Types.PkgconfigName (PkgconfigName) | ||
import Distribution.Types.PkgconfigVersion (PkgconfigVersion) | ||
import Distribution.Types.PkgconfigVersionRange (PkgconfigVersionRange) | ||
import Distribution.Types.UnitId (DefUnitId, UnitId) | ||
import Distribution.Types.UnqualComponentName | ||
import Distribution.Utils.NubList (NubList) | ||
import Distribution.Utils.ShortText (ShortText, fromShortText) | ||
import Distribution.Verbosity | ||
import Distribution.Verbosity.Internal | ||
|
||
------------------------------------------------------------------------------- | ||
-- instances | ||
------------------------------------------------------------------------------- | ||
|
||
instance (Eq a, Show a) => ToExpr (Condition a) where toExpr = defaultExprViaShow | ||
instance (Show a, ToExpr b, ToExpr c, Show b, Show c, Eq a, Eq c, Eq b) => ToExpr (CondTree a b c) | ||
instance (Show a, ToExpr b, ToExpr c, Show b, Show c, Eq a, Eq c, Eq b) => ToExpr (CondBranch a b c) | ||
instance (ToExpr a) => ToExpr (NubList a) | ||
instance (ToExpr a) => ToExpr (Flag a) | ||
|
||
instance ToExpr a => ToExpr (PerCompilerFlavor a) | ||
|
||
instance ToExpr AbiDependency | ||
instance ToExpr AbiHash | ||
instance ToExpr Arch | ||
instance ToExpr Benchmark | ||
instance ToExpr BenchmarkInterface | ||
instance ToExpr BenchmarkType | ||
instance ToExpr BuildInfo | ||
instance ToExpr BuildType | ||
instance ToExpr CabalSpecVersion | ||
instance ToExpr CompilerFlavor | ||
instance ToExpr CompilerId | ||
instance ToExpr ComponentId | ||
instance ToExpr DebugInfoLevel | ||
instance ToExpr DefUnitId | ||
instance ToExpr Dependency | ||
instance ToExpr ExeDependency | ||
instance ToExpr Executable | ||
instance ToExpr ExecutableScope | ||
instance ToExpr ExposedModule | ||
instance ToExpr FlagAssignment | ||
instance ToExpr FlagName | ||
instance ToExpr ForeignLib | ||
instance ToExpr ForeignLibOption | ||
instance ToExpr ForeignLibType | ||
instance ToExpr GenericPackageDescription | ||
instance ToExpr HaddockTarget | ||
instance ToExpr IncludeRenaming | ||
instance ToExpr InstalledPackageInfo | ||
instance ToExpr KnownRepoType | ||
instance ToExpr LegacyExeDependency | ||
instance ToExpr LibVersionInfo | ||
instance ToExpr Library | ||
instance ToExpr LibraryName | ||
instance ToExpr LibraryVisibility | ||
instance ToExpr Mixin | ||
instance ToExpr ModuleName | ||
instance ToExpr ModuleReexport | ||
instance ToExpr ModuleRenaming | ||
instance ToExpr OS | ||
instance ToExpr OpenModule | ||
instance ToExpr OpenUnitId | ||
instance ToExpr OptimisationLevel | ||
instance ToExpr PackageDescription | ||
instance ToExpr PackageFlag | ||
instance ToExpr PackageIdentifier | ||
instance ToExpr PackageName | ||
instance ToExpr PackageVersionConstraint | ||
instance ToExpr PathComponent | ||
instance ToExpr PathTemplate | ||
instance ToExpr PathTemplateVariable | ||
instance ToExpr PkgconfigDependency | ||
instance ToExpr PkgconfigName | ||
instance ToExpr PkgconfigVersion | ||
instance ToExpr PkgconfigVersionRange | ||
instance ToExpr ProfDetailLevel | ||
instance ToExpr RepoKind | ||
instance ToExpr RepoType | ||
instance ToExpr SetupBuildInfo | ||
instance ToExpr SourceRepo | ||
instance ToExpr TestShowDetails | ||
instance ToExpr TestSuite | ||
instance ToExpr TestSuiteInterface | ||
instance ToExpr TestType | ||
instance ToExpr UnitId | ||
instance ToExpr UnqualComponentName | ||
instance ToExpr Verbosity | ||
instance ToExpr VerbosityFlag | ||
instance ToExpr VerbosityLevel | ||
|
||
instance ToExpr ShortText where toExpr = toExpr . fromShortText |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.