[Haskell-beginners] question on types

Brandon Allbery allbery.b at gmail.com
Fri Jul 29 04:22:09 CEST 2011


On Thu, Jul 28, 2011 at 21:26, Jake Penton <djp at arqux.com> wrote:

> Does that mean then that there is no definition possible of f other than
> 'undefined'? I mean this compiles:
>
> f::a
> f = undefined
>
> But is there any other possible second line defining f?
>

Only more complicated forms of the same thing:

> f = error "impossible value"
> f = let x = x in x -- infinite evaluation

You'll occasionally see discussion of the role of "bottom" in the language;
that's what this is.  Technically, bottom is the least defined value of a
type, and since in standard Haskell all types are "lifted" (their values are
computed via thunks of some kind; this is what enables laziness) bottom
inhabits every type, and is the only "value" that does so.  (Various
extensions introduce and make use of unlifted types, which are always
strict; as such, they can never really be bottom, as any attempt to use
bottom in the context of an unlifted type leads to a runtime error, infinite
loop, crash, or other form of nontermination.)

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110728/7c510039/attachment.htm>


More information about the Beginners mailing list