module Comp where import Data.Semigroup import Test.QuickCheck newtype Comp a = Comp { unComp :: (a -> a) } instance Semigroup a => Semigroup (Comp a) where (Comp f1) <> (Comp f2) = Comp f where f x = (f1 x) <> (f2 x) instance Monoid a => Monoid (Comp a) where mempty = Comp $ \_ -> mempty mappend (Comp f1) (Comp f2) = Comp f where f x = mappend (f1 x) (f2 x) instance (Arbitrary a, CoArbitrary a) => Arbitrary (Comp a) where arbitrary = fmap Comp arbitrary instance Show (Comp a) where show _ = "a -> a"