blob: 62e19575296f6eb2f2712c161ca939574e8f6eaf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-- Triggered a lint error due to the specialiser
module T4203 where
import Control.Applicative (Applicative(..))
import Control.Monad (liftM, ap)
newtype NonNegative a = NonNegative a
deriving (Eq, Num, Show)
instance (Eq a, Num a) => Arbitrary (NonNegative a) where
arbitrary = return (rubble (rubble 0))
coarbitrary = error "urk"
rubble :: (Eq a, Num a) => a -> a
rubble 0 = 1
rubble n = n * rubble (n-1)
newtype EmptyStackSet = EmptyStackSet (NonNegative Int)
instance Arbitrary EmptyStackSet where
arbitrary = do
x <- arbitrary :: Gen (NonNegative Int)
return $ EmptyStackSet x
coarbitrary = error "urk"
newtype Gen a = Gen a
instance Functor Gen where
fmap = liftM
instance Applicative Gen where
pure = Gen
(<*>) = ap
instance Monad Gen where
Gen m >>= k = Gen (let Gen m' = k m in m')
class Arbitrary a where
arbitrary :: Gen a
coarbitrary :: a
data StackSet = StackSet
|