<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Dear David,<div class=""><br class=""><div class="">given that "data [a] =  [] | (a : [a])" in Haskell is viewed co-inductively and hence admits infinite lists,<div class="">then any function f : [a] -> b  is total only if it returns a result.</div><div class="">Does this mean it must terminate?</div><div class=""><br class=""></div><div class="">In a strict world, yes.</div><div class=""><br class=""></div><div class="">In the lazy world, it's a little more complicated than that.</div><div class=""><br class=""></div><div class="">Consider  map id :: [a] -> [a]</div><div class=""><br class=""></div><div class="">is map id partial? It won't terminate if given an infinite list, but it will produce partial results on demand indefinitely - so I say it is total.</div><div class=""><br class=""></div><div class="">However , length applied to [0..] (say) will never return any partial or complete result, and so I would say it's partial.</div><div class=""><br class=""></div><div class="">I too am going to start teaching Haskell newbies, so this is of interest - to what extend to we use "stories for children"</div><div class=""><br class=""></div><div class="">One suggestion: if you don't start with laziness, and they  initially consider lists as finite, then length :: [a] -> Int  is total, where [a] is interpreted as finite lists.</div><div class="">When laziness enters the picture, then points out that having [a] include infinite lists means that some hitherto total function become partial, on that expanded domain.</div><div class=""><br class=""></div><div class="">Perhaps the added documentation should also comment for list and ADT based functions where the infinite forms influence totality/partiality?</div><div class=""><br class=""></div><div class="">Regards, Andrew</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 31 Aug 2018, at 03:09, David Feuer <<a href="mailto:david.feuer@gmail.com" class="">david.feuer@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="auto" class="">Yes, I think so. What about functions like length? length (repeat ()) is bottom. repeat () is not bottom. Ergo, length is partial. But I don't think we want to say that!</div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Aug 30, 2018, 10:05 PM Daniel Díaz Casanueva <<a href="mailto:dhelta.diaz@gmail.com" class="">dhelta.diaz@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">+1 from me too. The partiality of a function seems to me like something that should be documented.<br class=""><div class=""><br class=""></div><div class="">Best,</div><div class="">Daniel</div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">Am Fr., 31. Aug. 2018 um 02:10 Uhr schrieb Richard Eisenberg <<a href="mailto:rae@cs.brynmawr.edu" target="_blank" rel="noreferrer" class="">rae@cs.brynmawr.edu</a>>:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Proposal: Mark partial functions in `base` as partial<br class="">
<br class="">
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.<br class="">
<br class="">
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.<br class="">
<br class="">
Thoughts?<br class="">
<br class="">
Thanks,<br class="">
Richard<br class="">
_______________________________________________<br class="">
Libraries mailing list<br class="">
<a href="mailto:Libraries@haskell.org" target="_blank" rel="noreferrer" class="">Libraries@haskell.org</a><br class="">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br class="">
</blockquote></div>
_______________________________________________<br class="">
Libraries mailing list<br class="">
<a href="mailto:Libraries@haskell.org" target="_blank" rel="noreferrer" class="">Libraries@haskell.org</a><br class="">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br class="">
</blockquote></div>
_______________________________________________<br class="">Libraries mailing list<br class=""><a href="mailto:Libraries@haskell.org" class="">Libraries@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries<br class=""></div></blockquote></div><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">--------------------------------------------------------------------<br class="">Andrew Butterfield     Tel: +353-1-896-2517     Fax: +353-1-677-2204<br class="">Lero@TCD, Head of Foundations & Methods Research Group<br class="">School of Computer Science and Statistics,<br class="">Room G.39, O'Reilly Institute, Trinity College, University of Dublin<br class="">                         <a href="http://www.scss.tcd.ie/Andrew.Butterfield/" class="">http://www.scss.tcd.ie/Andrew.Butterfield/</a><br class="">--------------------------------------------------------------------</div>
</div>
<br class=""></div></div></div></body></html>