Re: [Haskell-cafe] simple servers

2012-09-19 Thread 山本和彦
>> All system calls issued from the network package use non-blocking. >> You don't have to worry about blocking at all. > > Almost. Especially when interfacing with C code you should include the > "-threaded" option to GHC to link against the multi-threaded run-time > system. Otherwise your Hask

Re: [Haskell-cafe] simple servers

2012-09-19 Thread Ertugrul Söylemez
Kazu Yamamoto (山本和彦) wrote: > > One last question. When writing C code, using epoll apis explicitly > > can impose some blocking. Is the same to be said for GHC.Event? > > I don't understand your question. > > All system calls issued from the network package use non-blocking. > You don't have to

Re: [Haskell-cafe] An easy way to represent and modify graphs?

2012-09-19 Thread Strake
Pointers. Seriously. In Haskell one could use STRef rather than the cumbersome Foreign.Ptr, though STRef too can be kludgy. I know not whether safe, pure, immutable pointers would be possible in Haskell, but in my experience STRef can work well enough. Cheers, Strake __

[Haskell-cafe] Haskell Weekly News: Issue 244

2012-09-19 Thread Daniel Santa Cruz
Welcome to issue 244 of the HWN, an issue covering crowd-sourced bits of information about Haskell from around the web. This issue covers the week of September 9 to September 15, 2012. Inbox As you might have heard, GHC 7.6.1 is out for all platforms. I would say "get it while it is still hot",

Re: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists

2012-09-19 Thread Dan Doel
On Wed, Sep 19, 2012 at 8:36 PM, wren ng thornton wrote: >> P.S. It is actually possible to write zip function using Boehm-Berarducci >> encoding: >> http://okmij.org/ftp/ftp/Algorithms.html#zip-folds > > > Of course it is; I just never got around to doing it :) If you do, you might want

Re: [Haskell-cafe] simple servers

2012-09-19 Thread 山本和彦
Hi, > Is it true that writing a simple server using forkIO now integrates > native event loops implicitly? Yes. IO manager handles event driven stuff. Thanks to this, we can enjoy (light) thread programming using forkIO. > One last question. When writing C code, using epoll apis explicitly > c

Re: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists

2012-09-19 Thread wren ng thornton
On 9/18/12 4:27 AM, o...@okmij.org wrote: There has been a recent discussion of ``Church encoding'' of lists and the comparison with Scott encoding. I'd like to point out that what is often called Church encoding is actually Boehm-Berarducci encoding. That is, often seen newtype ChurchList a =

Re: [Haskell-cafe] foldl vs. foldr

2012-09-19 Thread wren ng thornton
On 9/18/12 8:32 AM, Jan Stolarek wrote: Hi list, I have yet another question about folds. Reading here and there I encountered statements that foldr is more important than foldl, e.g. in this post on the list: http://www.haskell.org/pipermail/haskell-cafe/2012-May/101338.html I want to know are

Re: [Haskell-cafe] [ANNOUNCE] Fmark markup language

2012-09-19 Thread Mario Blažević
On 12-09-18 07:37 PM, Richard O'Keefe wrote: On 19/09/2012, at 1:43 AM, Stefan Monnier wrote: The problem with that is that some people DO end some headings with a full stop; for them your special syntax is not natural. Markdown/ReST is already using the "no syntax" idea (e.g. compared to pr

[Haskell-cafe] ANNOUCE: one-liner-0, SYB-like generics with constraint kinds

2012-09-19 Thread Sjoerd Visscher
Hi all, I am pleased to announce the first release of One-Liner, a package for writing short and concise generic instances of type classes. It works a bit like Scrap-Your-Boilerplate, but it uses the new constraint kinds instead of the Typeable class. On hackage: http://hackage.haskell.org/pac

Re: [Haskell-cafe] How to implement nested loops with tail recursion?

2012-09-19 Thread Johan Tibell
On Wed, Sep 19, 2012 at 8:00 PM, wrote: > So how do I force IO actions whose results are discarded (including IO ()) to > be strict? In your particular case it looks like you want Data.IORef.modifyIORef'. If your version of GHC doesn't include it you can write it like so: -- |Strict version of

Re: [Haskell-cafe] How to implement nested loops with tail recursion?

2012-09-19 Thread Claude Heiland-Allen
Hi! On 19/09/12 19:00, sdiy...@sjtu.edu.cn wrote: > So how do I force IO actions whose results are discarded (including IO ()) to > be strict? () <- foo :: IO () -- should work as it pattern matches, can wrap it in a prettier combinator !_ <- foo :: IO a -- could work with -XBangPatterns I've n

Re: [Haskell-cafe] How to implement nested loops with tail recursion?

2012-09-19 Thread sdiyazg
So how do I force IO actions whose results are discarded (including IO ()) to be strict? main = do s<-newIORef (1::Int) let f :: Int -> Int -> IO Int f 0 !acc = return acc -- note strict accumulator f n !acc = do

Re: [Haskell-cafe] How to implement nested loops with tail recursion?

2012-09-19 Thread Johan Tibell
On Wed, Sep 19, 2012 at 7:24 PM, wrote: > main = do > let > f 0 acc = return acc > f n acc = do > v <- return 1 > f (n-1) (v+acc) > f 100 100 >>= print Try this main = do let f :

Re: [Haskell-cafe] How to implement nested loops with tail recursion?

2012-09-19 Thread sdiyazg
A follow-up question. I still haven't got the monadic version working, and the real use case involves IO actions. I looked at http://www.haskell.org/haskellwiki/Recursion_in_a_monad and adapted the 'tail-recursive' snippet on the page into main = do let f 0 acc = return

Re: [Haskell-cafe] How to implement nested loops with tail recursion?

2012-09-19 Thread sdiyazg
Now I have discovered the right version... main = print (f 1 0::Int) where f i s = (if i<=2 then (f (i+1) (s + g 1 0)) else s) where g j s = (if j<=2 then (g (j+1) (s + i*j)) else s) - 原始邮件 - 发件人: sdiy...@sjtu.edu.cn 收件人: haskell-cafe@haskell.org 发送时间: 星期三,

[Haskell-cafe] simple servers

2012-09-19 Thread brad clawsie
Hi cafe looking at http://www.haskell.org/haskellwiki/Simple_Servers The last two solutions compared are forkIO vs. explicit event support (based on what was System.Event). Further reading appears to indicate that event support has been integrated into the runtime. Is it true that writing a si

[Haskell-cafe] How to implement nested loops with tail recursion?

2012-09-19 Thread sdiyazg
I need to implement fast two-level loops, and I am learning using seq to make calls tail-recursive. I write programs to compute main = print $ sum [i*j|i::Int<-[1..2],j::Int<-[1..2]] This program (compiled with -O2) runs twenty times slower than the unoptimized (otherwise the loop gets

Re: [Haskell-cafe] Partial statical linking

2012-09-19 Thread Brandon Allbery
On Wed, Sep 19, 2012 at 7:06 AM, Jason Dusek wrote: > What I attempted was building a binary with only some C libraries > statically linked, with this command line: > > # Build https://github.com/erudify/sssp on Ubunut 12.04 > ghc -outputdir ./tmp -v --make -O2 sssp.hs -o sssp.ubuntu \ >

Re: [Haskell-cafe] Partial statical linking

2012-09-19 Thread Jason Dusek
2012/9/19 Christian Maeder : > I usually just copy those .a files (that should be linked statically) into > `ghc --print-libdir`. Wow, it worked! But this isn't the sort of change I'd to a user's system that I'd like to encode in a Makefile... -- Jason Dusek pgp // solidsnack // C1EBC57DC55144F35

Re: [Haskell-cafe] Partial statical linking

2012-09-19 Thread Christian Maeder
Hi, I usually just copy those .a files (that should be linked statically) into `ghc --print-libdir`. HTH Christian Am 19.09.2012 13:06, schrieb Jason Dusek: 2011/12/1 Irene Knapp : The typical trick to force GHC to statically link a C library is to give the full path to the .a of it as one

Re: [Haskell-cafe] Partial statical linking

2012-09-19 Thread Jason Dusek
2011/12/1 Irene Knapp : > The typical trick to force GHC to statically link a C library > is to give the full path to the .a of it as one of the object > files in the GHC invocation that does the final linking. This > means you don't need any -l or -L flags pertaining to that > library. Some libr

[Haskell-cafe] ANNOUNCE: som-1.0

2012-09-19 Thread Amy de Buitléir
Do you have some data that you'd like to understand better? I'm happy to announce a new package called som that may help: http://hackage.haskell.org/package/som https://github.com/mhwombat/som/wiki (wiki) A Kohonen Self-organising Map (SOM) maps input patterns onto a regular grid (usually

[Haskell-cafe] ANNOUNCE: grid-2.0

2012-09-19 Thread Amy de Buitléir
I'm happy to announce a new major release of the grid package: http://hackage.haskell.org/package/grid https://github.com/mhwombat/grid/wiki (wiki) WHAT'S NEW: The GridMap module provides ordered maps from tiles on a grid to values. This module is a wrapper around Grid and Map, in order

Re: [Haskell-cafe] [Haskell] Well-Typed and Skills Matter offer Haskell courses in London in October

2012-09-19 Thread Andres Löh
Hi. > Oops, I hit send too prematurely, sorry for the seeming bluntness (but it is > still a blunt message, can't apologize for that I suppose): No need to apologize. There's a need for informal meetings as much (or even more) as there is for courses and conferences. > Perhaps a monthly informal

Re: [Haskell-cafe] [Haskell] Well-Typed and Skills Matter offer Haskell courses in London in October

2012-09-19 Thread Claude Heiland-Allen
Hi list, Oops, I hit send too prematurely, sorry for the seeming bluntness (but it is still a blunt message, can't apologize for that I suppose): On 19/09/12 09:14, Claude Heiland-Allen wrote: On 19/09/12 08:52, Andres Löh wrote: Registration for all these events is open. I hope to see many

Re: [Haskell-cafe] [Haskell] Well-Typed and Skills Matter offer Haskell courses in London in October

2012-09-19 Thread Andres Löh
> Is there an informal hangout without the £225 price-tag Certainly a great idea. I guess there's most likely some informal meeting after the Haskell eXchange. Perhaps Neil Mitchell knows if there are any concrete plans yet? He's been putting together the program for the conference. Cheers, And

Re: [Haskell-cafe] [Haskell] Well-Typed and Skills Matter offer Haskell courses in London in October

2012-09-19 Thread Claude Heiland-Allen
On 19/09/12 08:52, Andres Löh wrote: Registration for all these events is open. I hope to see many of you there. Is there an informal hangout without the £225 price-tag Cheers, Andres ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org ht