summaryrefslogtreecommitdiff
path: root/testsuite/tests/gadt/Session.hs
blob: 2a9b3da6efcc5174c79b3b10c90fc68a56ea3520 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{-# LANGUAGE GADTs, KindSignatures #-}

-- See Trac #1323; crashed GHC 6.6

module Main where

import Data.Kind (Type)

data Zero = Zero
            deriving (Show)

-- Change this newtype to a data and all's well
-- and it's not like the class restriction actually restricts
-- the type rather than the constructor
newtype Succ p = Succ p deriving (Show)

class TyNum a where
instance TyNum Zero where
instance (TyNum p) => TyNum (Succ p) where

data List :: Type -> Type -> Type where
             Nil :: List a Zero
             Cons :: (TyNum p) => a -> List a p -> List a (Succ p)

instance (Show a) => Show (List a l) where
    show Nil = "Nil"
    show (Cons a t) = "Cons " ++ (show a) ++ " (" ++ (show t) ++ ")"

zipL :: List a l -> List b l -> List (a, b) l
zipL Nil Nil = Nil -- this line is fine
zipL (Cons l ls) (Cons r rs) = Cons (l,r) (zipL ls rs) -- this line blows up

l1 = Cons 5 (Cons 3 Nil)
l2 = Cons True (Cons False Nil)

main = print $ zipL l1 l2

{-
$ ghc --make Test.hs
[1 of 1] Compiling Main             ( Test.hs, Test.o )
ghc-6.6: panic! (the 'impossible' happened)
  (GHC version 6.6 for x86_64-unknown-linux):
        Pattern match failure in do expression at simplCore/Simplify.lhs:1540:8-21

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
-}