[Haskell-cafe] Re: help with threadDelay

2006-11-22 Thread Simon Marlow

Ian Lynagh wrote:

[moving to glasgow-haskell-bugs]

On Wed, Nov 15, 2006 at 11:40:12PM +, Neil Davies wrote:


however when -threaded is used you get some interesting effects,
including returning too early:

Tgt/Actual = 0.000125/0.34s, diff = -0.91s



Thanks for the report; I can reproduce it on Linux/amd64.

OK, so the bug here is that threadDelay n might return after less than n
microseconds.

This looks like it's caused by truncation problems when converting times
to ticks (where a tick is 1/50 of a second), e.g. while trying to sleep
for 1.953125s one run started at 1164157960.773726s which is
  (Int) 1164157960 * 50 + 773726 * 50 / 100
= (Int) 58207898038.6863
= 58207898038 ticks
and woke the thread up at 1164157962.708609s which is
  (Int) 1164157962 * 50 + 708609 * 50 / 100
= (Int) 58207898135.4305
= 58207898135 ticks

The difference is 58207898135 - 58207898038 = 97 ticks.

Meanwhile we're trying to sleep for
  (Int) 50 * 1.953125
= (Int) 97.65625
= 97 ticks

However, 1164157962.708609s - 1164157960.773726s = 1.93488311767578s
which is 0.0182418823242201s too short.

The problem is that we have counted 0.6863 ticks before the start time,
not counted 0.4305 ticks before the finish time and have been waiting
0.65625 ticks too short a time. Thus we have counted
(0.6863-0.4305 + 0.65625) / 50 == 0.018241 too much time.

I think the answer is that

let target = now + usecs `quot` tick_usecs

in GHC/Conc.lhs should be

let target = 1 + now + (usecs + tick_usecs - 1) `quot` tick_usecs

I'm also a bit dubious about the use of the constant 50 for the number
of ticks per second, but the results with +RTS -V0.001 don't look any
more wrong so perhaps I just need to get some sleep.


The hardcoded 50 in GHC/Conc.lhs matches up with TICK_FREQ in 
libraries/base/includes/HsBase.h.  It could probably be made larger without any 
ill effects.  I agree that we should round up the target time to the nearest 
tick rather than rounding down, though.


Cheers,
Simon

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


Re: [Haskell-cafe] Why are new releases of libraries required for every GHC release?

2006-11-22 Thread Duncan Coutts
On Wed, 2006-11-22 at 09:12 +, DavidA wrote:
 Some recent comments suggested that every time there is a new GHC release, 
 there needs to be a new wxHaskell release (or insert name of other library 
 here) to work with it. This seems to be true even for minor upgrades, like 
 6.4.1 - 6.4.2.

These GUI libs tend only to break on major releases like 6.2 - 6.4 and
6.4 - 6.6. In both cases this was due to changes in the way packages
are managed. Since these GUI libs are both pretty large and made of
several packages they were affected. Many simpler projects were fine
with the transition.

 Why is this? Does GHC break binary compatibility at every release? Is this 
 avoidable?

Yes this is what you're thinking about with minor upgrades like 6.4.1 -
6.4.2, so any binary packages, eg windows installers need to be rebuilt
from source to work with the new ghc version.

 This makes using Haskell unnecessarily hard compared to other platforms. 

Well, usually it's only a rebuild so as long as your build system is ok,
it's not too hard.

Duncan

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


Re: [Haskell-cafe] Type Error. Why!?

2006-11-22 Thread Henning Thielemann

On Wed, 22 Nov 2006, Neil Mitchell wrote:

 http://www.haskell.org/hawiki/MonomorphismRestriction
 
 Is there really not a page on the new wiki that explains that MR? We
 should also have a nice big FAQ, as this is often asked about.

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


Re: [Haskell-cafe] Articles on programming with (IO) exceptions in Haskell?

2006-11-22 Thread Bulat Ziganshin
Hello Magnus,

Tuesday, November 21, 2006, 9:07:40 PM, you wrote:

 I'm having problems finding a good introduction to exceptions.  Yet
 Another Haskell Tutorial leaves it for chapter 10, which is empty.  I'd
 prefer something that suits a noob.  :-)

Tackling the awkward squad: monadic input/output, concurrency,
exceptions, and foreign-language calls in Haskell
http://research.microsoft.com/Users/simonpj/papers/marktoberdorf/marktoberdorf.ps.gz




-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


[Haskell-cafe] Re: help with threadDelay

2006-11-22 Thread Neil Davies

Ian/Simon(s) Thanks - looking forward to the fix. It will help with
the real time enviroment that I've got.

Follow on query: Is there a way of seeing the value of this interval
from within the Haskell program?  Helps in the calibration loop.

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


Re: [Haskell-cafe] trivial ghc problem, help needed

2006-11-22 Thread Donald Bruce Stewart
clawsie:
 i have a program tb.hs:
 
 ---
 module Main where
 import Network.URI (URI(..), URIAuth(..), parseURI)
 
 myFunc :: String - Maybe URI
 myFunc u = parseURI u
 
 main = do { return () }
 ---
 
 when i attempt to build it with ghc, i get the following output:
 
 tb.o: In function `Main_myFunc_info':
 (.text+0x11): undefined reference to
 `networkzm2zi0_NetworkziURI_parseURI_closure'
 tb.o: In function `Main_myFunc_srt':
 (.rodata+0x0): undefined reference to
 `networkzm2zi0_NetworkziURI_parseURI_closure'
 collect2: ld returned 1 exit status
 
 any clue why? i would send this to the ghc list but i presume my issue
 is due to a trivial misunderstanding of the language

Assuming you have the Network package installed, you need to tell the
compile to link in the extra network library. The above is a linker
error.

Adding
--make
or
-package network

to the command line should do the trick.

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


[Haskell-cafe] YCR2JS Programmers Guide Draft available

2006-11-22 Thread Dimitry Golubovsky

Hi,

I have finished typing in the draft of low-level programming guide for
Yhc Core to Javascript converter. Everyone interested in future use of
this tool is encouraged to read and review the Guide. Its purpose is
to give some ideas about interaction of Haskell programs converted
into Javascript with a web browser on the lowest possible level,
without application frameworks and support libraries  (just because
these haven't been developed).

Any feedback and ideas are appreciated.

The document is located at:

http://haskell.org/haskellwiki/Yhc/Javascript/Programmers_guide

Thanks.

--
Dimitry Golubovsky

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