Mark partial functions as such

Ryan Trinkle ryan.trinkle at gmail.com
Fri Aug 31 15:49:28 UTC 2018


This is probably not really for the libraries list, but in the same vein as
this discussion, I think it would be extremely helpful to have a way of
banning functions that does *not* require changing the upstream library.  I
would be thrilled to have a machine-checked ban on use of the 'head',
'tail', etc.

On Fri, Aug 31, 2018 at 11:36 AM Henrik Nilsson <
Henrik.Nilsson at nottingham.ac.uk> wrote:

> Hi,
>
> Richard Eisenberg wrote:
>
>  > Maybe here's a concrete example:
>  >
>  > > -- | /Contains a call to 'error'./ Extract the first element of a
>  > list, which must be non-empty.
>  > > head                    :: [a] -> a
>  >
>  > In the end, it's the call to error that I want noted.
>
> Yes, whether the code of a function directly or indirectly calls "error"
> is well-defined property that could be documented.
>
> But note that this does not coincide with the following:
>
>  > > I think we want something like "partial even given input you can
>  > > successfully DeepSeq"
>  >
>  > That's the specification of the feature I'm after
>
> Consider e.g.
>
>     apply f x = f x
>
> As e.g.
>
>     apply head [] == _|_
>
> we'd have to conclude by the above definition that "apply" is partial.
> But it clearly does not "call error".
>
> Just to be clear, this does not correspond to how I understand
> partiality. Lots of higher order functions, like "map", then would have
> to called partial. And I am not sure that would be so helpful for
> the purpose of alerting (new) programmers to functions that one
> might argue should be avoided.
>
> So maybe something very clear and easy to understand, such as "contains
> call to error" is the best approach.
>
> Best,
>
> /Henrik
>
>
>
> This message and any attachment are intended solely for the addressee
> and may contain confidential information. If you have received this
> message in error, please contact the sender and delete the email and
> attachment.
>
> Any views or opinions expressed by the author of this email do not
> necessarily reflect the views of the University of Nottingham. Email
> communications with the University of Nottingham may be monitored
> where permitted by law.
>
>
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20180831/63dbc39a/attachment.html>


More information about the Libraries mailing list