-
Notifications
You must be signed in to change notification settings - Fork 239
@partial metadata for partial/non-total function with a pure type signature #1139
Comments
The only thing that makes me nervous here is that it's somewhat of a lie. A function lacking |
@bgamari This is indeed a valid concern. My opinion would be to be honest regarding the limitations of this metadata, with maybe some kind of tooltip on the metadata, that would explain that this does not equate a formal proof of totality and is user-defined (or something like that). |
I think it might be better to flip it around : rather than just saying it’s
partial, it should be a “has failure modes”. Eg length and most other
recursive / finite length assuming algorithms will fail in the sense of an
infinite loop on a cyclic list !
May throw exception is one annotation
May nonterminate on certain lazy / infinite structures is another.
Maybe step zero is we start a document that tracks all the safety
properties different functions in base require (what conditions for
infinite loop, throwing an exception based on inputs/state etc). Then
figure out what we may want from a documentation and or tooling support.
I worry that unless we first write down all these and look at it
holistically, we may miss an opportunity to do something cool with the
whole big picture.
…On Sun, Mar 22, 2020 at 5:24 AM Hécate ***@***.***> wrote:
@bgamari <https://github.com/bgamari> This is indeed a valid concern. My
opinion would be to be honest regarding the limitations of this metadata,
with maybe some kind of tooltip on the metadata, that would explain that
this does not equate a formal proof of totality and is user-defined (or
something like that).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1139 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAABBQTVRFQU54VMKMJ5J2DRIXKLXANCNFSM4LQ4AKFA>
.
|
Thank you Carter for the insight! On my side, I suggest we first go with marking functions for which a (direct) code path to undefined/error/errorWithoutStacktrace/throw is possible. |
Hello, @Kleidukos asked me to work on the annotation's UI integration. I'll take look on how I can help. |
Tixie is a wonderful designer and I have had the chance of working with her in the past. |
i'd really like it to be collapsable :) |
so
|
restating part of a discussion on irc, i was suggesting "@partiality", or something like that, be the grammatical analogue of |
note that there is a typo in that image, should be 'Exception', not 'Excepetion'. Additionally, I think 'has failure modes' is a step in the right direction. |
i do think the WARNING SIGIL Partiality piece should then have the text under it |
@cartazio So something like
This function is partial and may raise a runtime exception…
|
Yes! |
I feel
Now, with this proposal, we have a specialized syntax for a tiny subcase of the entire problem. With things like Instead there should be a sufficiently simple way to mark failures:
This allows to express failures in a sufficiently powerful way. The downside is that there's no special syntax for the different cases. But I'm not sure if that's necessary (and with effects systems it might become even more of a problem). When there's a block of |
Hi @hasufell, thanks for chiming in. :)
In our specific case, we wish to express untyped runtime errors, in the same vein as GHC's !2930. So by that definition, I don't think we should go as far as to mark
Now that is an interesting middle line that raises some questions, which are quite legitimate. However, I would like it to be known that I do not wish to operate in a mode similar to GHC proposals where something needs to be debated for 30 days and 30 nights before being set in stone forever, and be passed as tradition to our children. |
Well, as I said. untyped runtime errors can be expressed with
No, this is an assumption. A function that returns Most haskell code I've worked with is a wild combination of those 3 cases. E.g. foo :: MonadIO m => [String] -> ExceptT String m Int
foo xs = do
let bar = head xs -- partial
contents <- liftIO $ readFile bar -- IO exception
parsedContents <- parse contents -- may short-circuit ExceptT
... |
Okay I think I've misunderstood you, I thought you meant that because an function returned an |
It can. It's up to the discretion of the maintainer. If the type is unexpressive (e.g. String) and there are multiple different failure cases, this might be a good idea. |
fails is the wrong grammar i think. or maybe i need to reread julians remarks :) |
failures are partiality. nontermination, nonlocal control, deadlocks, they are all "stuck" states per se. I guess its useful to distinguish things that are explicit failures |
Hrmm. I guess it’s def true that we should think of this all as what it
really is: a markup tool for software authors.
…On Sun, Mar 29, 2020 at 12:02 PM Julian Ospald ***@***.***> wrote:
Okay I think I've misunderstood you, I thought you meant that because an
function returned an Either it should be marked with @fails
<https://github.com/fails>. My bad.
It can. It's up to the discretion of the maintainer. If the type is
unexpressive (e.g. String) and there are multiple different failure cases,
this might be a good idea.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1139 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAABBQUQCYFEMMDUKVOW4U3RJ5WINANCNFSM4LQ4AKFA>
.
|
Hello! What is the situation with |
@kindaro Hi, we're going to migrate this ticket to GitLab in the following week, and I'll make public announcements regarding the roadmap; as well as public consultations. Thank you for your interest, I am still thinking about it. Perhaps the recent warnings on List.head/tail can be a source of inspiration. |
So what is the right way for me to go on? What actions should I take? I have just finished reading haskell/core-libraries-committee#87 — this seems to be what you refer to as «recent warnings on List.head/tail». Is there something else you would offer me to look at? I did not grasp what you mean by «public announcements regarding the roadmap» and «public consultations». Would you have a moment to clarify this? |
@kindaro Nothing special, just advertise on Discourse that the development of Haddock will be more active, bring transparency regarding its roadmap, be more receptive to ideas and contributions. |
Hello maintainers and contributors,
Following this merge request in
base
's documentation, and an interesting comment from Ben Gamari, I lay before you the possibility of having an additional metadata annotation:to indicate the fact that a function with a seemingly innocent type signature (such as
maximum :: (Foldable t, Ord a) => t a -> a
) might in fact raise a runtime exception.There are of course some other things to sort out, notably at the UI/UX level.
Does haskell.org or any of the corporate sponsors have any people with this skillset that could be of any help?
I hope this will lead to some interesting advances in how we document our Haskell code. :)
cc @bgamari @cartazio
The text was updated successfully, but these errors were encountered: