
Hello Tomasz, Thursday, February 1, 2007, 1:15:39 PM, you wrote:
while (hGetBuf h buf bufsize == bufsize) crc := updateCrc crc buf bufsize break if crc==0 print crc
inContT $ callCC $ \break -> do flip execStateT 0 $ do whileM (liftM (== bufsize) (hGetBuf h buf bufsize)) $ do modifyM (updateCrc buf bufsize) crc <- get when (crc == 0) (lift (break crc)) print crc
how this can be expressed in Haskell, without losing clarity?
I think it's quite clear what it does.
first. it's longer than original. what we can learn here is that imperative languages have built-in "monadic" features support, including automatic lifting and continuations. OTOH, of course, they don't support type inference. so in one environment we need to explicitly declare types while in other environment we need to explicitly specify lifting operations second. unfortunately, current Haskell libs defined in terms of IO monad, not MonadIO. while this issue, i hope, will be addressed in future, i write programs right now :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com