blob: f7224da1e9bbd122ec416ff47d1e009add2c374e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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"
|