Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for GADTs and scoped type variables
- Loading branch information
simonpj
committed
Nov 2, 2007
1 parent
a6909cb
commit f9f5741
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{-# OPTIONS_GHC -XGADTs -XScopedTypeVariables -XPatternSignatures #-} | ||
|
||
-- Tests for scoped type variables and GADTs | ||
|
||
module GADT where | ||
|
||
data C x y where | ||
C :: a -> C a a | ||
|
||
data D x y where | ||
D :: C b c -> D a c | ||
|
||
------- All these should be ok | ||
|
||
-- Rejected! | ||
g1 :: forall x y . C x y -> () | ||
-- C (..) :: C x y | ||
-- Inside match on C, x=y | ||
g1 (C (p :: y)) = () | ||
|
||
-- OK! | ||
g2 :: forall x y . C x y -> () | ||
-- C (..) :: C x y | ||
-- Inside match on C, x=y | ||
g2 (C (p :: x)) = () | ||
|
||
-- Rejected! | ||
g3 :: forall x y . D x y -> () | ||
-- D (..) :: D x y | ||
-- C (..) :: C sk y | ||
-- sk = y | ||
-- p :: sk | ||
g3 (D (C (p :: y))) = () |