Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: \x -> x < 0.5 && x > -0.5 (Heinrich Apfelmus)
2. Re: \x -> x < 0.5 && x > -0.5 (Stephen Tetley)
3. Re: Re: \x -> x < 0.5 && x > -0.5 (Brent Yorgey)
4. Re: \x -> x < 0.5 && x > -0.5 (Christian Maeder)
5. haskell on snow leopard (Bernardas Jankauskas)
6. Re: Re: \x -> x < 0.5 && x > -0.5 (Edward Z. Yang)
7. Re: haskell on snow leopard (Luca Ciciriello)
8. Re: haskell on snow leopard (Tom Tobin)
9. Re: SOLVED - Stack overflow, but hard to understand
(Michael Mossey)
10. Re: SOLVED - Stack overflow, but hard to understand
(Magnus Therning)
11. Re: SOLVED - Stack overflow, but hard to understand
(Michael Mossey)
----------------------------------------------------------------------
Message: 1
Date: Tue, 20 Oct 2009 12:08:19 +0200
From: Heinrich Apfelmus <[email protected]>
Subject: [Haskell-beginners] Re: \x -> x < 0.5 && x > -0.5
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Brent Yorgey wrote:
>
> Note that little-r 'reader' is just an informal name for the ((->) e)
> monad, which is what your code was using. Control.Monad.Reader also
> provides the big-R 'Reader' type, which is just a newtype wrapper
> around a little-r reader, and does indeed have a 'runReader' method
> (which just removes the newtype constructor). That is,
>
> newtype Reader r a = Reader { runReader :: r -> a }
>
> C.M.Reader also provides ReaderT, a monad transformer version of Reader.
I thought Control.Monad.Reader also provides the needed
instance Monad ((->) r)
but this is actually provided by Control.Monad.Instances .
Regards,
apfelmus
--
http://apfelmus.nfshost.com
------------------------------
Message: 2
Date: Tue, 20 Oct 2009 16:29:43 +0100
From: Stephen Tetley <[email protected]>
Subject: [Haskell-beginners] Re: \x -> x < 0.5 && x > -0.5
To: [email protected], [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Christian Maeder wrote:
> Hoogle did not find a function of type:
>
> (b -> b -> b) -> (a -> b) -> (a -> b) -> a -> b
>
> or (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
>
> But maybe such a function is worth being added to Data.Function.
Hello Christian
This is the big Phi or S' combinator. I would certainly second its
addition to Data.Function.
sprime p q r s = p (q s) (r s)
Best wishes
Stephen
------------------------------
Message: 3
Date: Tue, 20 Oct 2009 11:37:15 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] Re: \x -> x < 0.5 && x > -0.5
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Tue, Oct 20, 2009 at 04:29:43PM +0100, Stephen Tetley wrote:
> Christian Maeder wrote:
>
> > Hoogle did not find a function of type:
> >
> > (b -> b -> b) -> (a -> b) -> (a -> b) -> a -> b
> >
> > or (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
> >
> > But maybe such a function is worth being added to Data.Function.
>
> Hello Christian
>
> This is the big Phi or S' combinator. I would certainly second its
> addition to Data.Function.
>
> sprime p q r s = p (q s) (r s)
But this function already exists in the standard libraries: it is
called liftM2/liftA2, specialized to the ((->) e) monad/applicative
instance. This is what the rest of the thread has been talking about.
-Brent
------------------------------
Message: 4
Date: Tue, 20 Oct 2009 18:34:23 +0200
From: Christian Maeder <[email protected]>
Subject: [Haskell-beginners] Re: \x -> x < 0.5 && x > -0.5
To: Stephen Tetley <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Stephen Tetley schrieb:
> Christian Maeder wrote:
>
>> Hoogle did not find a function of type:
>>
>> (b -> b -> b) -> (a -> b) -> (a -> b) -> a -> b
>>
>> or (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
>>
>> But maybe such a function is worth being added to Data.Function.
I did not find liftM2 (or liftA2) although I "knew" liftM2 and instance
Functor/Monad ((->) a).
> Hello Christian
>
> This is the big Phi or S' combinator. I would certainly second its
> addition to Data.Function.
>
> sprime p q r s = p (q s) (r s)
At least for documentation purposes (other than this thread) such an
explicit definition makes sense to be put into a source. Be it just to
show the (non-)obvious.
Cheers Christian
Btw. for the actual problem I suggest now:
((< 0.5) . abs)
------------------------------
Message: 5
Date: Tue, 20 Oct 2009 17:39:34 +0100
From: Bernardas Jankauskas <[email protected]>
Subject: [Haskell-beginners] haskell on snow leopard
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes
Hello,
For two past weeks I have been trying to get Haskell working on my
macbook pro with Snow Leopard, but unfortunately I was unable to get it.
There are some solutions on the internet, but these are mostly useful
when you already have ghci and haskell platform installed on your
computer, while I can't even get it installed. I have Xcode 3.1
installed, but it seems that it is not the case.
Maybe you could recommend any solution to this problem?
Sincerely,
Bernardas Jankauskas
P.S.: I have attached two screenshots of what occurs for me when I am
trying to install haskell platform and ghci.
------------------------------
Message: 6
Date: Tue, 20 Oct 2009 12:53:12 -0400
From: "Edward Z. Yang" <[email protected]>
Subject: Re: [Haskell-beginners] Re: \x -> x < 0.5 && x > -0.5
To: beginners <[email protected]>
Message-ID: <1256057556-sup-7...@ezyang>
Content-Type: text/plain; charset=UTF-8
Excerpts from Christian Maeder's message of Tue Oct 20 12:34:23 -0400 2009:
> Stephen Tetley schrieb:
> > Christian Maeder wrote:
> >
> >> Hoogle did not find a function of type:
> >>
> >> (b -> b -> b) -> (a -> b) -> (a -> b) -> a -> b
> >>
> >> or (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
> >>
> >> But maybe such a function is worth being added to Data.Function.
>
> I did not find liftM2 (or liftA2) although I "knew" liftM2 and instance
> Functor/Monad ((->) a).
Perhaps a useful feature to add to Hoogle would be the ability to print both
the generic type instance, and then a "specialized" version based off of the
query that was made.
Cheers,
Edward
------------------------------
Message: 7
Date: Tue, 20 Oct 2009 19:20:42 +0200
From: Luca Ciciriello <[email protected]>
Subject: Re: [Haskell-beginners] haskell on snow leopard
To: Bernardas Jankauskas <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
I belive I undertood that you have tried to install the Haskell
platform. Had you tried to install just GHC using the Mac installer
that you can find in: http://haskell.org/ghc/download_ghc_6_10_4.html ?
Luca.
P.S.
I Think attachment are filtered in this mailing list.
On Oct 20, 2009, at 6:39 PM, Bernardas Jankauskas wrote:
> Hello,
>
> For two past weeks I have been trying to get Haskell working on my
> macbook pro with Snow Leopard, but unfortunately I was unable to get
> it.
> There are some solutions on the internet, but these are mostly
> useful when you already have ghci and haskell platform installed on
> your computer, while I can't even get it installed. I have Xcode 3.1
> installed, but it seems that it is not the case.
>
> Maybe you could recommend any solution to this problem?
>
> Sincerely,
> Bernardas Jankauskas
>
> P.S.: I have attached two screenshots of what occurs for me when I
> am trying to install haskell platform and ghci.
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 8
Date: Tue, 20 Oct 2009 13:18:49 -0500
From: Tom Tobin <[email protected]>
Subject: Re: [Haskell-beginners] haskell on snow leopard
To: Luca Ciciriello <[email protected]>
Cc: [email protected], Bernardas Jankauskas <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
On Tue, Oct 20, 2009 at 12:20 PM, Luca Ciciriello
<[email protected]> wrote:
> I belive I undertood that you have tried to install the Haskell platform.
> Had you tried to install just  GHC using the Mac installer that you can find
> in: http://haskell.org/ghc/download_ghc_6_10_4.html ?
That's what finally worked for me, FWIW.
I was also able to install the 6.12.1 RC on Snow Leopard.
------------------------------
Message: 9
Date: Tue, 20 Oct 2009 12:32:57 -0700
From: Michael Mossey <[email protected]>
Subject: Re: [Haskell-beginners] SOLVED - Stack overflow, but hard to
understand
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Okay, I figured this out. mapM is not lazy, at least not for a monad that
has state and under the circumstance you demand the state out the other side.
I may rewrite the program. Or I may consider the ISS principle. ("Increase
the stack, stupid.")
-Mike
------------------------------
Message: 10
Date: Wed, 21 Oct 2009 06:38:01 +0100
From: Magnus Therning <[email protected]>
Subject: Re: [Haskell-beginners] SOLVED - Stack overflow, but hard to
understand
To: Michael Mossey <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
On 20/10/09 20:32, Michael Mossey wrote:
> Okay, I figured this out. mapM is not lazy, at least not for a monad that
> has state and under the circumstance you demand the state out the other
> side.
If I understand what you are saying then this behaviour isn't unexpected. If
you have a monad with state, and you ask for the final state, then it's likely
that everything happening in that particular monad will has to be evaluated.
> I may rewrite the program. Or I may consider the ISS principle.
> ("Increase the stack, stupid.")
You may also be able to improve the situation by adding a bit of strictness.
In some cases the thunks resulting from laziness can take up a lot of space.
Forcing evaluation, at well thought out locations in your program, may both
speed things up and reduce memory/stack usage.
/M
--
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnusï¼ therningï¼org Jabber: magnusï¼ therningï¼org
http://therning.org/magnus identi.ca|twitter: magthe
------------------------------
Message: 11
Date: Wed, 21 Oct 2009 01:44:38 -0700
From: Michael Mossey <[email protected]>
Subject: Re: [Haskell-beginners] SOLVED - Stack overflow, but hard to
understand
To: Magnus Therning <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
Magnus Therning wrote:
> On 20/10/09 20:32, Michael Mossey wrote:
>> Okay, I figured this out. mapM is not lazy, at least not for a monad that
>> has state and under the circumstance you demand the state out the other
>> side.
>
> If I understand what you are saying then this behaviour isn't
> unexpected. If
> you have a monad with state, and you ask for the final state, then it's
> likely
> that everything happening in that particular monad will has to be
> evaluated.
Hi Magnus,
Yes, that's what I was trying to imply. I realized it is mathematically
impossible for mapM to be lazy for a monad with state.
mapM doesn't seem to be lazy anywhere. For example, this program
main = do
buffers <- forM ["file1.txt","file2.txt","file3.txt"] readFile
print . take 1 . concat $ buffers
will, according to my experiments with the profiler, read all three files.
It's possible to imagine lazy behavior here, but no doubt there is a
technical reason against it.
>
>> I may rewrite the program. Or I may consider the ISS principle.
>> ("Increase the stack, stupid.")
>
> You may also be able to improve the situation by adding a bit of
> strictness.
> In some cases the thunks resulting from laziness can take up a lot of
> space.
> Forcing evaluation, at well thought out locations in your program, may both
> speed things up and reduce memory/stack usage.
You are probably right... I am having trouble spanning the gap between "my
current understanding" and "well thought-out locations." Real World Haskell
has a chapter on this, so I may look there.
I was able to get the program to run by removing all places that I had
created a chain of Rand computations that forced evaluation of the last
one. I replaced these with computations that did not require evaluation of
the last one.
However, my program was still forced to read more files than it really
needed in the end, as the above snippet demonstrates.
Thanks,
Mike
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 16, Issue 16
*****************************************