ghc installation on mac osx 10.4.11(intel), Xcode 2.4?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

ghc installation on mac osx 10.4.11(intel), Xcode 2.4?

7stud-2
Hi,

I just bought Real World Haskell, and I'm trying to get the
ghc compiler set up.  The installer for the latest version
of ghc, 6.10.1, is for Leopard(osx 10.5).  What should
I install for osx 10.4.11(Tiger)?

Also, a question about "Beware of enumerating floating
point numbers" on p. 11.  The book doesn't explain
what it means to enumerate floating point numbers
without a step, so when it says to beware of
the non-intuitive behavior of:

ghci> [1.0..1.8]

how would a reader know what the intuitive behavior is?
Is the step .1, .01, .001?  Is there a default
step?  Who knows?


On p. 10 there is an error.  Below the last code example
 on the page, it says:

"In the latter case, the list is quite sensibly missing the
endpoint of the enumeration, because it isn't an
element of the series we defined."

But the last line of the code example is this:

ghci> [10,9..1]
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

which quite clearly includes both endpoints.




Reply | Threaded
Open this post in threaded view
|

ghc installation on mac osx 10.4.11(intel), Xcode 2.4?

Thomas Davie

On 24 Feb 2009, at 08:21, 7stud wrote:

> Hi,
>
> I just bought Real World Haskell, and I'm trying to get the
> ghc compiler set up.  The installer for the latest version
> of ghc, 6.10.1, is for Leopard(osx 10.5).  What should
> I install for osx 10.4.11(Tiger)?

Try using the version in MacPorts.

> Also, a question about "Beware of enumerating floating
> point numbers" on p. 11.  The book doesn't explain
> what it means to enumerate floating point numbers
> without a step, so when it says to beware of
> the non-intuitive behavior of:
>
> ghci> [1.0..1.8]
>
> how would a reader know what the intuitive behavior is?
> Is the step .1, .01, .001?  Is there a default
> step?  Who knows?

I'd say that if you can't figure out what it should do, that's pretty  
non intuitive, no?

Bob
Reply | Threaded
Open this post in threaded view
|

ghc installation on mac osx 10.4.11(intel), Xcode 2.4?

Daniel Fischer-4
In reply to this post by 7stud-2
Am Dienstag, 24. Februar 2009 08:21 schrieb 7stud:

> Hi,
>
> Also, a question about "Beware of enumerating floating
> point numbers" on p. 11.  The book doesn't explain
> what it means to enumerate floating point numbers
> without a step, so when it says to beware of
> the non-intuitive behavior of:
>
> ghci> [1.0..1.8]
>
> how would a reader know what the intuitive behavior is?
> Is the step .1, .01, .001?  Is there a default
> step?  Who knows?
>

Experienced Haskellers know :-)
The default step is 1, and

Prelude> [1.0 .. 1.8]
[1.0,2.0]

, which is what is meant by "the non-intuitive behaviour".
Of course, a learner won't know, so a request to the authors: elaborate that
in the second edition.

The fact behind it is that [a .. b] is syntactic sugar for

enumFromTo a b

, enumFromTo is a method in the class Enum. As the name suggests, this class
is for types where you can enumerate the elements, every element - except
boundary elements - should have a well defined predecessor and successor.
So, enumFromTo a b is in these cases the sequence of elements c with
index a <= index c <= index b, the indices increasing by 1.
This doesn't make much sense for floating point types or Rational, of course.
However, arithmetic sequences do make a lot of sense for these types, so they
are made instances of the class Enum, too. Since their elements don't have a
natural indexing, these instances are by necessity somewhat broken.
The enumFrom and enumFromTo methods proceed in steps of 1, which in absence of
a reasonable successor function is probably the best choice. However,
enumFromTo a b doesn't stop when the value exceeds b, but when it exceeds
b+1/2.
The behaviour is defined in section 6.3.4 of the Haskell report.

>
> On p. 10 there is an error.  Below the last code example
>  on the page, it says:
>
> "In the latter case, the list is quite sensibly missing the
> endpoint of the enumeration, because it isn't an
> element of the series we defined."
>
> But the last line of the code example is this:
>
> ghci> [10,9..1]
> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
>
> which quite clearly includes both endpoints.
>

They probably meant to write

[10,8 .. 1].


Reply | Threaded
Open this post in threaded view
|

Re: ghc installation on mac osx 10.4.11(intel), Xcode 2.4?

7stud-2
In reply to this post by Thomas Davie
Thomas Davie <tom.davie <at> gmail.com> writes:

>
>
> On 24 Feb 2009, at 08:21, 7stud wrote:
>
> > Hi,
> >
> > I just bought Real World Haskell, and I'm trying to get the
> > ghc compiler set up.  The installer for the latest version
> > of ghc, 6.10.1, is for Leopard(osx 10.5).  What should
> > I install for osx 10.4.11(Tiger)?
>
> Try using the version in MacPorts.
>

I did some more digging around at haskell.org, and I
discovered a download for 6.8.2 for mac osx 10.4, so
I downloaded and installed that.  Will that be ok?

For anyone who can't figure out how to install
ghc, cd into the ghc folder that is created when you
unzip the download.  Then read the INSTALL file.
To install, I did the following:

$ ./configure

$ sudo make install

At the end of which, I got the message:
-----------
Installation of ghc-6.8.2 was successful.

To use, add /usr/local/bin to your PATH.

Warning: this binary distribution does NOT contain documentation!
-----------


> > Also, a question about "Beware of enumerating floating
> > point numbers" on p. 11.  The book doesn't explain
> > what it means to enumerate floating point numbers
> > without a step, so when it says to beware of
> > the non-intuitive behavior of:
> >
> > ghci> [1.0..1.8]
> >
> > how would a reader know what the intuitive behavior is?
> > Is the step .1, .01, .001?  Is there a default
> > step?  Who knows?
>
> I'd say that if you can't figure out what it should do, that's pretty  
> non intuitive, no?
>

I would agree.  :)





Reply | Threaded
Open this post in threaded view
|

Re: ghc installation on mac osx 10.4.11(intel), Xcode 2.4?

7stud-2
In reply to this post by Daniel Fischer-4
Daniel Fischer <daniel.is.fischer <at> web.de> writes:
>
> Experienced Haskellers know
> The default step is 1, and
>

Thanks for the explanation.

> >
> > But the last line of the code example is this:
> >
> > ghci> [10,9..1]
> > [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
> >
> > which quite clearly includes both endpoints.
> >
>
> They probably meant to write
>
> [10,8 .. 1].
>


Actually, after examining the text several more times,
the code block has three examples:

ghci> [1.0, 1.25..2.0]
[1.0,1.25,1.5,1.75,2.0]
ghci> [1, 4..15]
[1,4,7,10,13]
ghci> [10, 9..1]
[10,9,8,7,6,5,4,3,2,1]

and apparently "In the latter case" was meant to refer
 to the middle example.