From: Larry Coleman
Subject: Re: PLOT: A non-parenthesized, infix Lisp!
Date: 
Message-ID: <38e4692a-9a3f-4d1c-bbcc-177c4264f26b@d38g2000prn.googlegroups.com>
On Apr 20, 4:41 pm, "Dmitry A. Kazakov" <·······@dmitry-kazakov.de>
wrote:
> On Mon, 20 Apr 2009 13:08:16 -0700 (PDT), Marco Antoniotti wrote:
> > On Apr 20, 6:31 pm, "Dmitry A. Kazakov" <·······@dmitry-kazakov.de>
> > wrote:
> >> On Mon, 20 Apr 2009 07:22:33 -0700 (PDT), Marco Antoniotti wrote:
> >>> On Apr 20, 11:39 am, "Dmitry A. Kazakov" <·······@dmitry-kazakov.de>
> >>> wrote:
> >>>> The very question as you posed it is meaningless. An illegal program cannot
> >>>> be correct or incorrect. It is not a program.
>
> >>> Only in a very strict and restrictive programming language.
>
> >> Yep, that is the whole point. That is the property of a *formal* language.
>
> > Then why does the following works:
>
> > ======================
> > Prelude> 40 + 2.0
> > 40 + 2.0
> > 42.0
> > ======================
>
> Very bad, suggesting that 2.0 is floating point and so the result. The
> obvious problem with floating-point is that it is inexact. So the meaning
> of 40+2.0 is diffuse. Does it round towards zero if normalizes?
>
Just to clarify, numeric literals in Haskell are treated a little
differently than you are probably used to:

Prelude> :t 40
40 :: (Num t) => t
Prelude> :t 2.0
2.0 :: (Fractional t) => t

For those who don't know Haskell, the first type is "a type that is a
member of the type class Num" and the second is "a type that is a
member of the type class Fractional".

The types of 40 and 2.0 are not fully specified until they need to be.
If they are bound to an expression that is defined as a float, they
will be converted behind the scenes at run time. Since float is a
subclass of Fractional, this can be verified at compile time. So the
meaning is not diffuse, it just depends on the context (none in this
case).

Prelude> :t 40 + 2.0
40 + 2.0 :: (Fractional t) => t

Now in this expression the result still does not have a fully
specified type, we just know that it's not an integer because Int
isn't a subclass or member of Fractional. It could be a float, or a
rational, or any other type that's a member of the Fractional type
class, depending on how it's used.