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: Haskell Platform: Troubleshooting package configuration
errors? (egarrulo)
2. iterateM (Adrian May)
----------------------------------------------------------------------
Message: 1
Date: Sat, 15 Jun 2013 18:49:41 +0200
From: egarrulo <[email protected]>
Subject: Re: [Haskell-beginners] Haskell Platform: Troubleshooting
package configuration errors?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Apparently, "network" is a tricky package (emphasis mine):
Quote: "The library situation is great, with the exception of GUI and
***networking*** utilities, which are notorious for not compiling on all
platforms and breaking on compiler upgrades."
(source:
http://www.reddit.com/r/haskell/comments/14nj0r/what_doesnt_haskell_do_well/c7etz7n)
Well, since Debian 7 has been released already, until I'll upgrade my
Debian 6 box, I'll content myself with the old Haskell environment
(GHC 6.12.1) that ships with Debian 6's package manager.
Thanks everybody for your attention.
Cheers.
-------- Original Message --------
Subject: Re: [Haskell-beginners] Haskell Platform: Troubleshooting
package configuration errors?
Date: Sat, 15 Jun 2013 00:09:21 +0200
From: egarrulo <[email protected]>
To: [email protected]
On 14/06/13 23:30, Peter Jones wrote:
> egarrulo <[email protected]> writes:
>> Error:
>> Configuring the network-2.4.1.2 package failed
>> make: *** [build.stamp] Error 2
------------------------------
Message: 2
Date: Sun, 16 Jun 2013 16:00:24 +0800
From: Adrian May <[email protected]>
Subject: [Haskell-beginners] iterateM
To: "[email protected]" <[email protected]>
Message-ID:
<cad-ubzfm1p-_re+qm5qc77si--nb_jesgmqyek3xfykre7y...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi All,
I just wrote a function to repeatedly transform something inside a monad
using the same transforming function every time. I feel it might be dodgy
though:
iterateM :: (Monad m) => (a -> m a) -> m a -> m [a]
iterateM f sm =
sm >>= \s ->
iterateM f (f s) >>= \ss ->
return (s:ss)
The context is that I was trying to write a state machine that responded to
keyboard input:
data Event = LoYes | LoNo | LoNum -- buttons on your phone
| ReYes | ReNo | ReNum -- buttons on his phone
data State = State { handler :: Event -> IO State }
main =
hSetBuffering stdin NoBuffering >> -- so you don't have to hit return
iterateM (\st -> getEvent >>= handler st) (return idle)
getEvent :: IO Event
getEvent =
getChar >>= \c -> case c of
'y' -> return LoYes
'n' -> return LoNo
'0' -> return LoNum
'Y' -> return ReYes
'N' -> return ReNo
'1' -> return ReNum
_ -> getEvent
idle, ringing, waiting, talking :: State
idle = State $ \e -> case e of
LoYes -> return idle
LoNo -> return idle
LoNum -> putStrLn "\tCalling somebody" >>
return waiting
ReYes -> return idle
ReNo -> return idle
ReNum -> putStrLn "\tIt's for you-hoo" >>
return ringing
-- other states similar
The reason I'm worried is that this is the second time I've needed such a
thing and it seems odd that it's not in the prelude already. Does it leak
memory? Does it have a tail recursion problem? Is the functionality I want
covered by something else? I guess I could consider [a] to be b in a
regular monad but then the (\st -> getEvent >>= handler st) bit would have
to juggle lists which seems meaningless.
Am I missing something or does everybody else have this iterateM in their
personal prelude?
TIA,
Adrian.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130616/8b64c9ad/attachment-0001.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 60, Issue 26
*****************************************