summaryrefslogtreecommitdiff
path: root/testsuite/tests/indexed-types/should_fail/SimpleFail5b.hs
blob: d05b3bcb363e18bc3ec55e0f8c1d17ab87cc6404 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{-# LANGUAGE TypeFamilies #-}

module ShouldFail where

class C3 a where
  data    S3  a :: *
  data    S3n a :: *
  foo3  :: a -> S3 a
  foo3n :: a -> S3n a
  bar3  :: S3 a -> a
  bar3n :: S3n a -> a

instance C3 Int where
  data    S3  Int  = D3Int
  newtype S3n Int  = D3Intn ()
  foo3  _          = D3Int
  foo3n _          = D3Intn ()
  bar3  D3Int      = 1
  bar3n (D3Intn _) = 1

instance C3 Char where
  data S3 Char = D3Char
  foo3 _       = D3Char
  bar3 D3Char  = 'c'

bar3' :: S3 Char -> Char
bar3' D3Char = 'a'

-- must fail: Can't match Int against Char
bar3wrong' D3Int  = 1
bar3wrong' D3Char = 'a'