Mark partial functions as such

Henrik Nilsson Henrik.Nilsson at nottingham.ac.uk
Fri Aug 31 15:36:15 UTC 2018


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.






More information about the Libraries mailing list