[Haskell-beginners] question on types
Daniel Fischer
daniel.is.fischer at googlemail.com
Fri Jul 29 04:19:39 CEST 2011
On Friday 29 July 2011, 03:26:33, Jake Penton wrote:
>
> Ok, thanks. I have some studying to do about haskell types, clearly.
>
> 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?
Sure, you can write the same thing in many different ways:
f :: a
f = f
f :: a
f = let x = x in x
f :: a
f = error "Foo"
but all definitions of "f :: a" that compile yield (some kind of) bottom,
since _|_ is the only value that is common to all types (whether an attempt
to evaluate such a value yields actual nontermination or an exception
message depends; the first two don't terminate in ghci but result in
"<<loop>>" when used in a compiled programme).
>
> - Jake -
More information about the Beginners
mailing list