[Haskell-cafe] Re: head as a total function

Jón Fairbairn jon.fairbairn at cl.cam.ac.uk
Thu Sep 7 13:15:18 EDT 2006


oleg at pobox.com writes:

> Jo'n Fairbairn wrote in response to Neil Mitchell:
> > No, that's the wrong approach because it relies on detecting
> > something that (a) the programmer probably knows already and
> > (b) is undecidable in general. It would be far better for
> > the programmer to express this knowledge in the
> > programme.
> 
> It is indeed possible -- and quite easy -- to write programs where
> head and tail are total functions. That issue was discussed, for
> example, at the end of an old message:

Oh, indeed. Come to think of it, in Ponder the list type was
something like (to translate into invalid Haskell)

   type List t = Maybe (NonEmptyList t)
   type NonEmptyList t = (t, List t)

but while I did some little experiments that took advantage
of that, I wasn't quite avant-garde enough to leave head and
tail out of the language (back then it was hard enough to
get people to try functional programming at all, and leaving
out the friendly-seeming functions would have made it just
too strange)

> P.S. Algol68 was my favorite language too.

I wrote the Ponder compiler in A68C...


-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2006-07-14)



More information about the Haskell-Cafe mailing list