summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_run/tcrun039.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/typecheck/should_run/tcrun039.hs')
-rw-r--r--testsuite/tests/typecheck/should_run/tcrun039.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_run/tcrun039.hs b/testsuite/tests/typecheck/should_run/tcrun039.hs
new file mode 100644
index 0000000000..916d5330e4
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/tcrun039.hs
@@ -0,0 +1,22 @@
+{-# LANGUAGE GADTs, ExplicitForAll #-}
+
+-- Test for GADTs and implication constraints
+
+module Main where
+
+data T a where
+ MkT :: Num a => a -> T a
+
+f :: Read a => T a -> String -> a
+f (MkT n) s = n + read s
+
+----------------
+data GADT a where
+ MkG :: Num a => a -> GADT [a]
+
+g :: forall b. Read b => GADT b -> String -> b
+g (MkG n) s = -- Here we know Read [b]
+ n : (read s)
+
+main = do print (f (MkT (3::Int)) "4")
+ print (g (MkG (3::Int)) "[4,5]")