Skip to content

Commit

Permalink
Format more
Browse files Browse the repository at this point in the history
  • Loading branch information
9999years committed Dec 21, 2024
1 parent 5ec4dd1 commit 5f18808
Show file tree
Hide file tree
Showing 128 changed files with 9,070 additions and 7,616 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,23 @@ jobs:
- uses: haskell-actions/run-fourmolu@v11
with:
version: "0.12.0.0"
# NOTE: Keep this in sync with `../../Makefile`
pattern: |
bootstrap/**/*.hs
buildinfo-reference-generator/**/*.hs
Cabal/**/*.hs
Cabal-syntax/**/*.hs
Cabal-benchmarks/**/*.hs
Cabal-described/**/*.hs
Cabal-dev-scripts/**/*.hs
Cabal-hooks/**/*.hs
cabal-install/**/*.hs
cabal-install-solver/**/*.hs
Cabal-QuickCheck/**/*.hs
Cabal-syntax/**/*.hs
Cabal-tests/**/*.hs
Cabal-testsuite/src/**/*.hs
Cabal-testsuite/main/**/*.hs
Cabal-testsuite/static/**/*.hs
Cabal-tree-diff/**/*.hs
cabal-validate/**/*.hs
solver-benchmarks/**/*.hs
35 changes: 18 additions & 17 deletions Cabal-QuickCheck/src/Test/QuickCheck/GenericArbitrary.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators #-}
module Test.QuickCheck.GenericArbitrary (
genericArbitrary,
GArbitrary,
) where

module Test.QuickCheck.GenericArbitrary
( genericArbitrary
, GArbitrary
) where

import GHC.Generics
import Test.QuickCheck
Expand All @@ -15,31 +16,31 @@ genericArbitrary :: (Generic a, GArbitrary (Rep a)) => Gen a
genericArbitrary = fmap to garbitrary

class GArbitrary f where
garbitrary :: Gen (f ())
garbitrary :: Gen (f ())

class GArbitrarySum f where
garbitrarySum :: [Gen (f ())]
garbitrarySum :: [Gen (f ())]

class GArbitraryProd f where
garbitraryProd :: Gen (f ())
garbitraryProd :: Gen (f ())

instance (GArbitrarySum f, i ~ D) => GArbitrary (M1 i c f) where
garbitrary = fmap M1 (oneof garbitrarySum)
garbitrary = fmap M1 (oneof garbitrarySum)

instance (GArbitraryProd f, i ~ C) => GArbitrarySum (M1 i c f) where
garbitrarySum = [fmap M1 garbitraryProd]
garbitrarySum = [fmap M1 garbitraryProd]

instance (GArbitrarySum f, GArbitrarySum g) => GArbitrarySum (f :+: g) where
garbitrarySum = map (fmap L1) garbitrarySum ++ map (fmap R1) garbitrarySum
garbitrarySum = map (fmap L1) garbitrarySum ++ map (fmap R1) garbitrarySum

instance (GArbitraryProd f, i ~ S) => GArbitraryProd (M1 i c f) where
garbitraryProd = fmap M1 garbitraryProd
garbitraryProd = fmap M1 garbitraryProd

instance GArbitraryProd U1 where
garbitraryProd = pure U1
garbitraryProd = pure U1

instance (GArbitraryProd f, GArbitraryProd g) => GArbitraryProd (f :*: g) where
garbitraryProd = (:*:) <$> garbitraryProd <*> garbitraryProd
garbitraryProd = (:*:) <$> garbitraryProd <*> garbitraryProd

instance (Arbitrary a) => GArbitraryProd (K1 i a) where
garbitraryProd = fmap K1 arbitrary
instance Arbitrary a => GArbitraryProd (K1 i a) where
garbitraryProd = fmap K1 arbitrary
Loading

0 comments on commit 5f18808

Please sign in to comment.