[Haskell-beginners] Sub-second precision
Alex Rozenshteyn
rpglover64 at gmail.com
Sun Jul 25 14:27:31 EDT 2010
I'm using gtk2hs (although I might try and see how wxHaskell compares when
I've got more working).
As for the repainting, I don't think I was clear enough in my initial post:
my problem isn't how to change the value every 1/100 of a second but how to
ensure that the value I write doesn't get hugely inaccurate. I was thinking
that I'd use the system time as the data and just draw when appropriate, but
I hadn't found something that was precise enough.
I ended up finding System.Posix.Clock, which does what I need, but I don't
know if there's something more standard.
On Sun, Jul 25, 2010 at 7:30 PM, Henk-Jan van Tuyl <hjgtuyl at chello.nl>wrote:
> 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
> --
>
--
Alex R
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100725/69932f03/attachment.html
More information about the Beginners
mailing list