Skip to content

Commit

Permalink
Autoformat more files with Fourmolu
Browse files Browse the repository at this point in the history
  • Loading branch information
9999years committed Jan 3, 2025
1 parent 00f2eab commit c3b5cf4
Show file tree
Hide file tree
Showing 126 changed files with 10,102 additions and 8,535 deletions.
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 c3b5cf4

Please sign in to comment.