Skip to content
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

Partial trait #78

Closed
lukaszcz opened this issue Sep 7, 2023 · 0 comments · Fixed by #85
Closed

Partial trait #78

lukaszcz opened this issue Sep 7, 2023 · 0 comments · Fixed by #85
Assignees
Labels
enhancement New feature or request

Comments

@lukaszcz
Copy link
Contributor

lukaszcz commented Sep 7, 2023

Once we have traits, we could create a Partial typeclass like in PureScript:

https://book.purescript.org/chapter6.html#nullary-type-classes

This would allow to use partial functions in an encapsulated manner and without depending on the Debug module. Currently, e.g., the head function depends on Debug.fail.

We could rename Debug.fail to Debug.abort.

Add a trait:

trait
type Partial := mkPartial {
   fail : {A : Type} -> A
};

runPartial {A} (f : {{Partial}} -> A) : A := f {{mkPartial __builtin_fail}};
@lukaszcz lukaszcz added the enhancement New feature or request label Sep 7, 2023
@lukaszcz lukaszcz self-assigned this Sep 8, 2023
@lukaszcz lukaszcz transferred this issue from anoma/juvix Sep 8, 2023
@lukaszcz lukaszcz mentioned this issue Sep 28, 2023
paulcadman added a commit that referenced this issue Oct 4, 2023
* Closes #78

---------

Co-authored-by: Paul Cadman <git@paulcadman.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant