5c6cab8ea06499b0408cc02939dafada1bdd9739
[ghc.git] / testsuite / tests / typecheck / should_run / tcrun011.hs
1 {-# LANGUAGE ExistentialQuantification, FlexibleContexts,
2 MultiParamTypeClasses #-}
3
4 -- !!! Existential data tyes
5 -- Hugs didn't like this one
6
7 module Main (main) where
8
9
10 class MyClass a b where
11 foo :: a -> b -> Int
12
13 data Special = forall b. (MyClass Int b)=> MkSpecial b
14 data General a = forall b. (MyClass a b)=> MkGeneral b
15
16 instance MyClass Int Bool where
17 foo x False = -x
18 foo x True = x
19
20 xs :: [General Int]
21 xs = [MkGeneral True, MkGeneral False]
22
23 main = print [foo (3::Int) x | MkGeneral x <- xs]
24 -- Without the (::Int) part we get an
25 -- incomprehensible error message :-(