[Haskell-cafe] Re: Using Get monad to efficiently parse byte-stuffeddata

2010-03-24 Thread Tim Attwood

Going through the data using getWord8 is a no-go. It is just too slow.
My solution so far has been to get the underlying bytestring and work
with that, but obviously defeats the purpose of using the Get monad.
What might be a better solution?


hGetArray with IOUArrays goes perty fast.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Trapping getChar before echo

2010-02-01 Thread Tim Attwood
Last time I tried something like this [on Windows], it didn't seem to 
work. I wanted to trap arrow keys and so forth, but they seem to be being 
used for input history. (I.e., pressing the up-arrow produces 
previously-entered lines of text, and none of this appears to be reaching 
the Haskell program itself.) Has this changed since I tried it last year?


Doesn't work in windows, at least up till 6.10.1. There's a work-around 
though.


{-# LANGUAGE ForeignFunctionInterface #-}

import Data.Char
import Control.Monad (liftM, forever)
import Foreign.C.Types

getHiddenChar = liftM (chr.fromEnum) c_getch
foreign import ccall unsafe conio.h getch
 c_getch :: IO CInt

main = do
  forever $ do
 c - getHiddenChar
 putStrLn $ show (fromEnum c) 



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Strange console IO behavior (at least on Windows)

2009-08-22 Thread Tim Attwood
Yeah, it's broken in windows.  Here's the workaround 
courtesy of Alistar Bayley. (ticket 2189)


{-# LANGUAGE ForeignFunctionInterface #-}

import Data.Char
import Control.Monad (liftM, forever)
import Foreign.C.Types

getHiddenChar = liftM (chr.fromEnum) c_getch
foreign import ccall unsafe conio.h getch
 c_getch :: IO CInt

main = do
  forever $ do
 c - getHiddenChar
 putStrLn $ show (fromEnum c)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Logo fun

2009-06-14 Thread Tim Attwood

Graphics are fun.

Here's my version.
http://s201.photobucket.com/albums/aa280/Zakardis/?action=viewcurrent=lambda_haskell_platform.png 



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe