[Haskell-beginners] Sub-second precision

Henk-Jan van Tuyl hjgtuyl at chello.nl
Sun Jul 25 12:30:09 EDT 2010


On Sat, 24 Jul 2010 22:09:15 +0200, Alex Rozenshteyn  
<rpglover64 at gmail.com> wrote:

> I'm trying to write a simple timer application (mostly to learn gui
> programming), and I'd like it to display 1/100ths of a second.  I know I  
> can
> fake this with threadDelay, but I was wondering if there's a way to get
> current time to more precision than one second.
>

That depends on the type of GUI you are using, of course. If you use  
wxHaskell, you can do it like this:

>   t <- timer f [ interval   := 10
>                , on command := repaint
>                ]

where f is the frame handle; you don't need to use t anywhere. The  
interval is defined in milliseconds.

Regards,
Henk-Jan van Tuyl


-- 
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
--


More information about the Beginners mailing list