This repository has been archived by the owner on Nov 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
skip equation
and skip case pattern
edits
- Loading branch information
Showing
11 changed files
with
302 additions
and
57 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
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
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,36 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# OPTIONS_GHC -Wno-overlapping-patterns #-} | ||
|
||
module SkipMatches where | ||
|
||
-- See also issue #130 | ||
skipEquation :: Bool -> Bool | ||
skipEquation True = False | ||
skipEquation False = True | ||
skipEquation _ = True -- This underscore case is redundant and needs to be eliminated | ||
|
||
skipEquationMultipleArgs :: Bool -> Bool -> Bool | ||
skipEquationMultipleArgs True _ = False | ||
skipEquationMultipleArgs False _ = True | ||
skipEquationMultipleArgs _ True = True -- This case is redundant and needs to be eliminated | ||
skipEquationMultipleArgs _ False = False -- This case is redundant and needs to be eliminated | ||
|
||
skipCasePattern :: Bool -> Bool | ||
skipCasePattern b = case b of | ||
True -> False | ||
False -> True | ||
_ -> True -- This underscore case is redundant and needs to be eliminated (locally) | ||
ignore -> True -- This variable case is redundant and needs to be eliminated (globally) | ||
|
||
skipLambdaCasePattern :: Bool -> Bool | ||
skipLambdaCasePattern = \case | ||
True -> False | ||
False -> True | ||
_ -> True -- This underscore case is redundant and needs to be eliminated (locally) | ||
ignore -> True -- This variable case is redundant and needs to be eliminated (globally) | ||
|
||
preserveCasePattern :: Bool -> Bool | ||
preserveCasePattern = \case | ||
True -> False | ||
_ -> True -- This underscore case is NOT redundant | ||
ignore -> True -- This variable case is redundant and needs to be eliminated (globally) |
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,11 @@ | ||
skip equation SkipMatches.skipEquation _ | ||
|
||
# We have to write the patterns using the *translated* names | ||
skip equation SkipMatches.skipEquationMultipleArgs _ true | ||
skip equation SkipMatches.skipEquationMultipleArgs _ false | ||
|
||
in SkipMatches.skipCasePattern skip case pattern _ | ||
in SkipMatches.skipLambdaCasePattern skip case pattern _ | ||
|
||
skip case pattern ignore | ||
in SkipMatches.redundant skip case pattern _ |
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
Oops, something went wrong.