summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_run/tcrun024.hs
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2011-07-20 11:09:03 -0700
committerDavid Terei <davidterei@gmail.com>2011-07-20 11:26:35 -0700
commit16514f272fb42af6e9c7674a9bd6c9dce369231f (patch)
treee4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/typecheck/should_run/tcrun024.hs
parentebd422aed41048476aa61dd4c520d43becd78682 (diff)
downloadhaskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/typecheck/should_run/tcrun024.hs')
-rw-r--r--testsuite/tests/typecheck/should_run/tcrun024.hs43
1 files changed, 43 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_run/tcrun024.hs b/testsuite/tests/typecheck/should_run/tcrun024.hs
new file mode 100644
index 0000000000..82c6f49e33
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/tcrun024.hs
@@ -0,0 +1,43 @@
+{-# LANGUAGE ImplicitParams, TypeSynonymInstances, FlexibleInstances #-}
+
+-- Class ops that bind no new type variables
+
+module Main where
+
+ import Data.List( sort )
+
+ just = [Just "fred",Just "bill"]
+
+ main = do { putStrLn (let ?p = "ok1" in fc1);
+ putStrLn (let ?p = "ok2" in fc2);
+ putStrLn (show (fd1 just)) ;
+ putStrLn (show (fd2 just)) }
+
+ -- This class has no tyvars in its class op context
+ -- One uses a newtype, the other a data type
+ class C1 a where
+ fc1 :: (?p :: String) => a;
+ class C2 a where
+ fc2 :: (?p :: String) => a;
+ opc :: a
+
+ instance C1 String where
+ fc1 = ?p;
+ instance C2 String where
+ fc2 = ?p;
+ opc = "x"
+
+ -- This class constrains no new type variables in
+ -- its class op context
+ class D1 a where
+ fd1 :: (Ord a) => [a] -> [a]
+ class D2 a where
+ fd2 :: (Ord a) => [a] -> [a]
+ opd :: a
+
+ instance D1 (Maybe a) where
+ fd1 xs = sort xs
+ instance D2 (Maybe a) where
+ fd2 xs = sort xs
+ opd = Nothing
+