Mark partial functions as such

Richard Eisenberg rae at cs.brynmawr.edu
Fri Aug 31 14:57:03 UTC 2018


Because I was silly and didn't look for it. That can and should be included, yes.

> On Aug 31, 2018, at 10:53 AM, David Feuer <david.feuer at gmail.com> wrote:
> 
> Why isn't the call to error in div what you mean?
> 
> On Fri, Aug 31, 2018, 10:49 AM Richard Eisenberg <rae at cs.brynmawr.edu <mailto:rae at cs.brynmawr.edu>> wrote:
> In a response not cc'd to the list, a contributor (not sure if they want public identification) suggests:
> 
> > I think we want something like "partial even given input you can successfully DeepSeq"
> 
> That's the specification of the feature I'm after. I think all the commentary about infinite lists, etc., would lead also to good documentation additions. (For example, it would be fantastic if every function precisely documented its strictness, preferably with some standard notation, but this is not the problem I'm trying to solve here.)
> 
> Also, it was suggested that the documentation be checked -- that is, we could imagine a {-# TOTAL ... #-} or {-# PARTIAL ... #-} pragma that GHC could check on compilation and Haddock could include in the documentation. This would also be great, but much more than I'm proposing here.
> 
> 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. Of course, having a similar note on functions like div (where the problem isn't a call to error) and length (that will loop on infinite lists) is good, but not really what I'm proposing here.
> 
> Thanks,
> Richard
> 
> > On Aug 30, 2018, at 8:10 PM, Richard Eisenberg <rae at cs.brynmawr.edu <mailto:rae at cs.brynmawr.edu>> wrote:
> > 
> > Proposal: Mark partial functions in `base` as partial
> > 
> > Motivation: I'm about to teach Haskell to a classful of beginners. In my experience, they will soon reach for functions like `head` and `tail`, because pattern-matching is foreign to them. I would love just to be able to say "Don't use partial functions", but many students will not easily be able to tell partial functions from total ones.
> > 
> > I do expect this problem to work itself out rather quickly, and then students will be able to identify partial functions, but loudly marking partial functions as partial seems like a small service to everyone and a bigger one to newbies. I don't see any downsides.
> > 
> > Thoughts?
> > 
> > Thanks,
> > Richard
> > _______________________________________________
> > Libraries mailing list
> > Libraries at haskell.org <mailto:Libraries at haskell.org>
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries <http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries>
> 
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org <mailto:Libraries at haskell.org>
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries <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/74263a49/attachment.html>


More information about the Libraries mailing list