-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor Uninhabited implementation for Elem types (#3412)
- Loading branch information
Showing
20 changed files
with
153 additions
and
9 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,27 @@ | ||
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 | ||
|
||
decHomogeneousElem' : (el1 : Elem x xs) -> (el2 : Elem x xs) -> Dec (el1 = el2) | ||
decHomogeneousElem' = decHomogeneousElem | ||
|
||
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 | ||
|
||
decHeterogeneousElem' : (el1 : Elem x xs) -> (el2 : Elem y xs) -> Dec (el1 = el2) | ||
decHeterogeneousElem' = decHeterogeneousElem | ||
|
||
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,45 @@ | ||
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 | ||
|
||
decHomogeneousElem' : (el1 : Data.List1.Elem.Elem x xs) -> (el2 : Data.List1.Elem.Elem x xs) -> Dec (el1 = el2) | ||
decHomogeneousElem' = decHomogeneousElem | ||
|
||
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 | ||
|
||
decHeterogeneousElem' : (el1 : Data.List1.Elem.Elem x xs) -> (el2 : Data.List1.Elem.Elem y xs) -> Dec (el1 = el2) | ||
decHeterogeneousElem' = decHeterogeneousElem | ||
|
||
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,27 @@ | ||
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 | ||
|
||
decHomogeneousElem' : (el1 : Elem x xs) -> (el2 : Elem x xs) -> Dec (el1 = el2) | ||
decHomogeneousElem' = decHomogeneousElem | ||
|
||
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 | ||
|
||
decHeterogeneousElem' : (el1 : Elem x xs) -> (el2 : Elem y xs) -> Dec (el1 = el2) | ||
decHeterogeneousElem' = decHeterogeneousElem | ||
|
||
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,27 @@ | ||
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 | ||
|
||
decHomogeneousElem' : (el1 : Elem x xs) -> (el2 : Elem x xs) -> Dec (el1 = el2) | ||
decHomogeneousElem' = decHomogeneousElem | ||
|
||
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 | ||
|
||
decHeterogeneousElem' : (el1 : Elem x xs) -> (el2 : Elem y xs) -> Dec (el1 = el2) | ||
decHeterogeneousElem' = decHeterogeneousElem | ||
|
||
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 |