summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore/should_compile/T4203.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/simplCore/should_compile/T4203.hs')
-rw-r--r--testsuite/tests/simplCore/should_compile/T4203.hs37
1 files changed, 37 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_compile/T4203.hs b/testsuite/tests/simplCore/should_compile/T4203.hs
new file mode 100644
index 0000000000..9423de7a36
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T4203.hs
@@ -0,0 +1,37 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
+-- Triggered a lint error due to the specialiser
+
+module T4203 where
+
+
+newtype NonNegative a = NonNegative a
+ deriving (Eq, Num, Show)
+
+instance Num a => Arbitrary (NonNegative a) where
+ arbitrary = return (rubble (rubble 0))
+ coarbitrary = error "urk"
+
+rubble :: 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 Monad Gen where
+ return a = Gen a
+ Gen m >>= k = Gen (let Gen m' = k m in m')
+
+class Arbitrary a where
+ arbitrary :: Gen a
+ coarbitrary :: a
+
+data StackSet = StackSet