summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_run/tcrun039.hs
blob: 916d5330e414d7c3cd4dff06691fd296d2280a2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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]")