summaryrefslogtreecommitdiff
path: root/testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun06.hs
blob: 92f870833d032a4ce3b47324149fce6209c26556 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-- Test that ambiguous selectors can be disambiguated by providing
-- type signatures in various places

{-# LANGUAGE DuplicateRecordFields #-}

data S = MkS { x :: Int }
data T = MkT { x :: Bool }
data U a = MkU { x :: a }

x_for_s :: S -> Int
x_for_s = x

x_for_t = x :: T -> Bool

x_for_u u = x (u :: U Int)

k :: (T -> Bool) -> Bool
k f = f (MkT True)

main = do print (x_for_s (MkS 42))
          print (k x)