Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
Haskell hacking
[go: Go Back, main page]


Haskell Hacking: a journal of Haskell programming



2006-10-19

Back from San Francisco

Back from San Francisco, after spending a week there for the Google Summer of Code Summit. I'll write more about that in the next few days. Getting back, and I notice that it's really feeling like summer in Sydney now: it's 30-odd degrees, and our cactus is flowering for the first time. Nina Cat thinks its good weather for sleeping, as usual.

/home :: /random :: permalink :: rss

Tshirt

And of course, the real reason we all participated in the Google Summer of Code: the tshirts! Mine finally arrived, the day after I get back from the GSoC summit, oh well :)

/home :: /haskell :: permalink :: rss

2006-10-04

Roll your own network code in Haskell

This week a medium length tutorial on network programming in Haskell. We build a concise IRC bot, and toss some custom control structures and a monad into the mixture. A small taste:

-- The 'Net' monad, a wrapper over IO, carrying the bot's immutable state.
type Net = ReaderT Bot IO
data Bot = Bot { socket :: Handle }

-- Set up actions to run on start and end, and run the main loop
main :: IO ()
main = bracket connect disconnect loop

listen :: Handle -> Net ()
listen h = forever $ do
    s <- io (hGetLine h)
    io (putStrLn s)
    when (ping s) $ pong s

Read the tutorial.

/home :: /haskell :: permalink :: rss

About

Real World Haskell

RWH Book Cover

Archives

Recommended

Blog Roll

Syndicate