Commit d0f97666 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Update standalone deriving test, and add a failure test

parent f029d2df
{-# OPTIONS -fglasgow-exts #-}
{-# LANGUAGE StandaloneDeriving, GeneralizedNewtypeDeriving #-}
module ShouldCompile where
data T a = T1 a | T2
newtype N = MkN Int
derive instance Eq (T a)
derive instance Num N
derive instance Eq N
derive instance Show N
deriving instance Eq a => Eq (T a)
deriving instance Num N
deriving instance Eq N
deriving instance Show N
......@@ -9,3 +9,4 @@ test('drvfail007', normal, compile_fail, [''])
test('drvfail008', reqlib('mtl'), compile_fail, [''])
test('drvfail009', normal, compile_fail, [''])
test('drvfail010', normal, compile_fail, [''])
test('drvfail011', normal, compile_fail, [''])
{-# LANGUAGE StandaloneDeriving #-}
module ShouldFail where
data T a = T1 a | T2
-- This fails as we need an (Eq a) context
deriving instance Eq (T a)
drvfail011.hs:5:5:
Could not deduce (Eq a) from the context (Eq (T a))
arising from a use of `==' at drvfail011.hs:5:5
Possible fix:
add (Eq a) to the context of the type signature for `=='
In the expression: ((a1 == b1))
In the definition of `==': == (T1 a1) (T1 b1) = ((a1 == b1))
In the definition for method `=='
......@@ -18,7 +18,7 @@ instance Eq (T Char) where
data family R a
data instance R [a] = R
derive instance Eq (R [a])
deriving instance Eq (R [a])
class C a where
data S a
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment