[Haskell-cafe] Re: Is "take" behaving correctly?

Dan Piponi dpiponi at gmail.com
Wed Sep 12 13:39:31 EDT 2007

On 9/12/07, PR Stanley <prstanley at ntlworld.com> wrote:
>  >  The same should apply to head and tail. head or tail  of [] should be
>  Disagree, strongly. Its not even possible for head,
>  What's the logic behind this?

You don't need anything sophisticated for this. What possible total
function could have signature [a] -> a? If you provide an argument of
[] it has to conjure up a value of type a from somewhere. Where could
it possibly get such a value for every single type a?

For example, define

> data Void -- the type with no elements (using -fglasgow-exts)

x = [] :: [Void] is a perfectly good list but head x has to be of type
Void which has no elements.

More information about the Haskell-Cafe mailing list