-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Relay] Add hd,tl,nth for list in Prelude #2771
Conversation
@MarisaKirisame @slyubomirsky Please take a look. |
LGTM. I think we should sort of add a 'partial' annotation and require match to be annotated as such, if it is partial. It could be implemented by having a boolean field in Match. Another option is, provide an explicit panic construct that signal a runtime error, force all match to be total, provide a partial match helper that add a default case that throw "not matched". |
@MarisaKirisame Or we can follow other general purpose language(like |
@wweic there's two orthgonal issue: for ocaml, (0: is exception, and 1: is compiler warning). I agree with your suggestion on (0:), but I am not sure about following ocaml on (1:). |
The code, other than the open question of how to handle incomplete matches, LGTM For my part, I think if we do want to allow incomplete matches (I would prefer Relay to always be total, but that could be impractical), then we should check at compile-time that matches be complete and require the user to annotate deliberately partial matches. |
Thanks @MarisaKirisame @slyubomirsky @wweic this is now merged |
Adding these common helpers for
list
. Following OCaml's name.