-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move refinement and singleton types into modules
- Loading branch information
1 parent
6487cea
commit 0bceb3c
Showing
9 changed files
with
56 additions
and
53 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,15 @@ | ||
module Fathom.Data.Refine | ||
|
||
|
||
||| A value that is refined by a proposition. | ||
||| | ||
||| The proof of the proposition is erased at runtime. | ||
||| | ||
||| This is a bit like `(x : A ** B)`, but with the second element erased. | ||
public export | ||
record Refine (0 A : Type) (0 P : A -> Type) where | ||
constructor MkRefine | ||
||| The refined value | ||
val : A | ||
||| The a proof that @val is refined by @P | ||
{auto 0 prf : P val} |
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,23 @@ | ||
module Fathom.Data.Sing | ||
|
||
|
||
||| A singleton type, constrained to be a single value | ||
||| | ||
||| The underlying value and the proof are both erased at runtime, as they can | ||
||| be converted back to the index by reconstructing the value as required. | ||
||| | ||
||| Inspired by the singleton type [found in Adga’s documentation](https://agda.readthedocs.io/en/v2.5.4.1/language/with-abstraction.html#the-inspect-idiom). | ||
public export | ||
record Sing {0 A : Type} (x : A) where | ||
constructor MkSing | ||
||| The underlying value of the singleton (erased at run-time) | ||
0 val : A | ||
||| A proof that @val is the same as the indexed value (erased at run-time) | ||
{auto 0 prf : x = val} | ||
|
||
|
||
||| Convert a singleton back to its underlying value restoring it with a value | ||
||| constructed runtime | ||
public export | ||
val : {0 A : Type} -> {x : A} -> Sing x -> A | ||
val (MkSing _) = x |
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