-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
which test a few variants of rules involving constructors, including nullary constructors, constructors with wrappers, and unsaturated of constructors. At the moment, all the rules work as expected, despite GHC’s compile time warnings when called with -Wall.
- Loading branch information
Showing
5 changed files
with
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
data T1 = MkT1Bad | MkT1Good deriving Show | ||
data T2 = MkT2Bad Int | MkT2Good Int deriving Show | ||
data T3 = MkT3Bad {-# UNPACK #-} !Int | MkT3Good {-# UNPACK #-} !Int deriving Show | ||
data T4 = MkT4Bad Int | MkT4Good Int deriving Show | ||
data T5 = MkT5Bad {-# UNPACK #-} !Int | MkT5Good {-# UNPACK #-} !Int deriving Show | ||
|
||
{-# RULES | ||
|
||
"T1" MkT1Bad = MkT1Good | ||
"T2" forall x. MkT2Bad x = MkT2Good x | ||
"T3" forall x. MkT3Bad x = MkT3Good x | ||
"T4" MkT4Bad = MkT4Good | ||
"T5" MkT5Bad = MkT5Good | ||
#-} | ||
|
||
app = id | ||
{-# NOINLINE app #-} | ||
|
||
main = do | ||
print MkT1Bad | ||
print (MkT2Bad 42) | ||
print (MkT3Bad 42) | ||
print (MkT4Bad 42) | ||
print (app MkT4Bad 42) | ||
print (MkT5Bad 42) | ||
print (app MkT5Bad 42) |
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,7 @@ | ||
MkT1Good | ||
MkT2Good 42 | ||
MkT3Good 42 | ||
MkT4Good 42 | ||
MkT4Good 42 | ||
MkT5Good 42 | ||
MkT5Good 42 |
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,24 @@ | ||
data T1 = MkT1Bad | MkT1Good deriving Show | ||
data T2 = MkT2Bad Int | MkT2Good Int deriving Show | ||
data T3 = MkT3Bad {-# UNPACK #-} !Int | MkT3Good {-# UNPACK #-} !Int deriving Show | ||
data T4 = MkT4Bad Int | MkT4Good Int deriving Show | ||
data T5 = MkT5Bad {-# UNPACK #-} !Int | MkT5Good {-# UNPACK #-} !Int deriving Show | ||
|
||
{-# RULES | ||
|
||
"T1" app MkT1Bad = MkT1Good | ||
"T2" forall x. app (MkT2Bad x) = MkT2Good x | ||
"T3" forall x. app (MkT3Bad x) = MkT3Good x | ||
"T4" app MkT4Bad = MkT4Good | ||
"T5" app MkT5Bad = MkT5Good | ||
#-} | ||
|
||
app = id | ||
{-# NOINLINE app #-} | ||
|
||
main = do | ||
print (app MkT1Bad) | ||
print (app (MkT2Bad 42)) | ||
print (app (MkT3Bad 42)) | ||
print (app MkT4Bad 42) | ||
print (app MkT5Bad 42) |
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,5 @@ | ||
MkT1Good | ||
MkT2Good 42 | ||
MkT3Good 42 | ||
MkT4Good 42 | ||
MkT5Good 42 |
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