[Haskell-cafe] Naming scheme for partial functions

Michael Snoyman michael at snoyman.com
Fri Feb 7 02:59:36 UTC 2014


Thanks for the input. We ended up going with an `Ex` suffix, e.g. headEx,
lastEx.


On Fri, Feb 7, 2014 at 4:53 AM, Tikhon Jelvis <tikhon at jelv.is> wrote:

> For what it's worth, OCaml's Core library does this with _exn, so they
> would call a partial last "last_exn". I would actually prefer an
> abbreviation of some sort (like exn) as long as it's a consistent
> convention. Using a full word like "exception" or "partial" adds to much
> noise in my opinion, especially if the base name (like "last") is shorter
> than the suffix!
>
> Also, I think a suffix would be better than a prefix, if only to group
> things conveniently when sorted alphabetically.
>
>
> On Thu, Jan 30, 2014 at 9:36 AM, Atze van der Ploeg <atzeus at gmail.com>wrote:
>
>> unprovenLast ?
>> On Jan 30, 2014 6:33 PM, "Michael Snoyman" <michael at snoyman.com> wrote:
>>
>>> Greg Weber and I have been discussing some changes to
>>> mono-traversable[1]. One of the modules we provide is Data.NonNull, which
>>> provides total versions of functions like `last`. A change we're looking at
>>> would require having a partial version of `last` defined in a separate
>>> typeclass (IsSequence), which would allowing for more optimized
>>> implementations of the total `last` function for datatypes which support it
>>> (e.g., strict ByteStrings).
>>>
>>> But what should we name it? I'm sure everyone's familiar with the
>>> `unsafe` naming convention, but that's not appropriate here: standard usage
>>> shows `unsafe` meaning a function which can cause a segfault.
>>>
>>> I initially named it `partialLast`, but partial can also imply partial
>>> function application. Greg brought up the idea of suffixing the function
>>> with something like `Throws` or `Errors`, which I think I'm a bit partial
>>> to myself[2].
>>>
>>> So my questions are:
>>>
>>> * Is there some already used naming scheme out there for partial
>>> functions which I've missed?
>>> * Do people have any ideas to throw into the mix?
>>>
>>> Michael
>>>
>>> [1] https://github.com/snoyberg/mono-traversable/pull/21
>>> [2] Pardon the pun.
>>>
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>>
>>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140207/e15826a5/attachment.html>


More information about the Haskell-Cafe mailing list