[Haskell-cafe] Bringing Erlang to Haskell

Joel Reymont joelr1 at gmail.com
Tue Dec 13 06:31:25 EST 2005


Thank you Bulat, makes total sense. This list is a treasure trove of  
a resource.

I guess this is what happens when you go from Erlang to Haskell :-).  
I'm conditioned to think of everything as a process and uses  
processes for everything.

On Dec 13, 2005, at 11:17 AM, Bulat Ziganshin wrote:

> import Control.Concurrent
> import Control.Monad
> import System.IO
> import System.IO.Unsafe
>
> main = do h <- openBinaryFile "test" WriteMode
>           for [1..100] $ \n ->
>             forkIO $
>               for [1..] $ \i ->
>                 logger h ("thread "++show n++" msg "++show i)
>           getLine
>           hClose h
>
> lock = unsafePerformIO$ newMVar ()
>
> logger h msg = withMVar lock $ const$ do
>                  hPutStrLn h msg
>                  putStrLn msg
>
> for = flip mapM_

--
http://wagerlabs.com/







More information about the Haskell-Cafe mailing list