-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor Uninhabited implementation for Elem types #3412
Open
ihor-rud
wants to merge
6
commits into
idris-lang:main
Choose a base branch
from
ihor-rud:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+153
−9
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
872fde9
refactor Uninhabited implementation for Elem types
ihor-rud 1c82b4b
add different xs
ihor-rud d33446b
review fixes
ihor-rud ca39508
review fixes
ihor-rud 2aacf3c
Merge branch 'main' into main
ihor-rud 5a8009a
Merge branch 'main' into main
CodingCellist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,21 @@ | ||
import Data.List | ||
import Data.List.Elem | ||
|
||
decHomogeneousElem : (el1 : Elem x xs) -> (el2 : Elem x xs) -> Dec (el1 = el2) | ||
decHomogeneousElem Here Here = Yes Refl | ||
decHomogeneousElem (There _) Here = No uninhabited | ||
decHomogeneousElem Here (There _) = No uninhabited | ||
decHomogeneousElem (There el1') (There el2') = case decHomogeneousElem el1' el2' of | ||
Yes Refl => Yes Refl | ||
No contra => No $ \Refl => contra Refl | ||
|
||
decHeterogeneousElem : (el1 : Elem x xs) -> (el2 : Elem y xs) -> Dec (el1 = el2) | ||
decHeterogeneousElem Here Here = Yes Refl | ||
decHeterogeneousElem (There _) Here = No uninhabited | ||
decHeterogeneousElem Here (There _) = No uninhabited | ||
decHeterogeneousElem (There el1') (There el2') = case decHeterogeneousElem el1' el2' of | ||
Yes Refl => Yes Refl | ||
No contra => No $ \Refl => contra Refl | ||
|
||
main : IO () | ||
main = printLn "OK" |
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 @@ | ||
"OK" |
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,3 @@ | ||
. ../../testutils.sh | ||
|
||
run Elem.idr |
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,39 @@ | ||
import Data.List | ||
import Data.List.Elem | ||
import Data.List1 | ||
import Data.List1.Elem | ||
|
||
decHomogeneousElemList : (el1 : Data.List.Elem.Elem x xs) -> (el2 : Data.List.Elem.Elem x xs) -> Dec (el1 = el2) | ||
decHomogeneousElemList Here Here = Yes Refl | ||
decHomogeneousElemList (There _) Here = No uninhabited | ||
decHomogeneousElemList Here (There _) = No uninhabited | ||
decHomogeneousElemList (There el1') (There el2') = case decHomogeneousElemList el1' el2' of | ||
Yes Refl => Yes Refl | ||
No contra => No $ \Refl => contra Refl | ||
|
||
decHeterogeneousElemList : (el1 : Data.List.Elem.Elem x xs) -> (el2 : Data.List.Elem.Elem y xs) -> Dec (el1 = el2) | ||
decHeterogeneousElemList Here Here = Yes Refl | ||
decHeterogeneousElemList (There _) Here = No uninhabited | ||
decHeterogeneousElemList Here (There _) = No uninhabited | ||
decHeterogeneousElemList (There el1') (There el2') = case decHeterogeneousElemList el1' el2' of | ||
Yes Refl => Yes Refl | ||
No contra => No $ \Refl => contra Refl | ||
|
||
decHomogeneousElem : (el1 : Data.List1.Elem.Elem x xs) -> (el2 : Data.List1.Elem.Elem x xs) -> Dec (el1 = el2) | ||
decHomogeneousElem Here Here = Yes Refl | ||
decHomogeneousElem (There _) Here = No uninhabited | ||
decHomogeneousElem Here (There _) = No uninhabited | ||
decHomogeneousElem (There el1') (There el2') = case decHomogeneousElemList el1' el2' of | ||
Yes Refl => Yes Refl | ||
No contra => No $ \Refl => contra Refl | ||
|
||
decHeterogeneousElem : (el1 : Data.List1.Elem.Elem x xs) -> (el2 : Data.List1.Elem.Elem y xs) -> Dec (el1 = el2) | ||
decHeterogeneousElem Here Here = Yes Refl | ||
decHeterogeneousElem (There _) Here = No uninhabited | ||
decHeterogeneousElem Here (There _) = No uninhabited | ||
decHeterogeneousElem (There el1') (There el2') = case decHeterogeneousElemList el1' el2' of | ||
Yes Refl => Yes Refl | ||
No contra => No $ \Refl => contra Refl | ||
|
||
main : IO () | ||
main = printLn "OK" |
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 @@ | ||
"OK" |
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,3 @@ | ||
. ../../testutils.sh | ||
|
||
run Elem.idr |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,21 @@ | ||
import Data.SnocList | ||
import Data.SnocList.Elem | ||
|
||
decHomogeneousElem : (el1 : Elem x xs) -> (el2 : Elem x xs) -> Dec (el1 = el2) | ||
decHomogeneousElem Here Here = Yes Refl | ||
decHomogeneousElem (There _) Here = No uninhabited | ||
decHomogeneousElem Here (There _) = No uninhabited | ||
decHomogeneousElem (There el1') (There el2') = case decHomogeneousElem el1' el2' of | ||
Yes Refl => Yes Refl | ||
No contra => No $ \Refl => contra Refl | ||
|
||
decHeterogeneousElem : (el1 : Elem x xs) -> (el2 : Elem y xs) -> Dec (el1 = el2) | ||
decHeterogeneousElem Here Here = Yes Refl | ||
decHeterogeneousElem (There _) Here = No uninhabited | ||
decHeterogeneousElem Here (There _) = No uninhabited | ||
decHeterogeneousElem (There el1') (There el2') = case decHeterogeneousElem el1' el2' of | ||
Yes Refl => Yes Refl | ||
No contra => No $ \Refl => contra Refl | ||
|
||
main : IO () | ||
main = printLn "OK" |
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 @@ | ||
"OK" |
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,3 @@ | ||
. ../../testutils.sh | ||
|
||
run Elem.idr |
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,21 @@ | ||
import Data.Vect | ||
import Data.Vect.Elem | ||
|
||
decHomogeneousElem : (el1 : Elem x xs) -> (el2 : Elem x xs) -> Dec (el1 = el2) | ||
decHomogeneousElem Here Here = Yes Refl | ||
decHomogeneousElem (There _) Here = No uninhabited | ||
decHomogeneousElem Here (There _) = No uninhabited | ||
decHomogeneousElem (There el1') (There el2') = case decHomogeneousElem el1' el2' of | ||
Yes Refl => Yes Refl | ||
No contra => No $ \Refl => contra Refl | ||
|
||
decHeterogeneousElem : (el1 : Elem x xs) -> (el2 : Elem y xs) -> Dec (el1 = el2) | ||
decHeterogeneousElem Here Here = Yes Refl | ||
decHeterogeneousElem (There _) Here = No uninhabited | ||
decHeterogeneousElem Here (There _) = No uninhabited | ||
decHeterogeneousElem (There el1') (There el2') = case decHeterogeneousElem el1' el2' of | ||
Yes Refl => Yes Refl | ||
No contra => No $ \Refl => contra Refl | ||
|
||
main : IO () | ||
main = printLn "OK" |
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 @@ | ||
"OK" |
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,3 @@ | ||
. ../../testutils.sh | ||
|
||
run Elem.idr |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding a brief sentence explaining why / explaining what the refactor achieves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done