You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get some weird SO behavior on the following program, which I think Haste tries to avoid by policy to my understanding. (I tried simplifying the code in a few ways, but it wouldn't crash anymore.)
importHaste.ForeignimportHaste.PrimimportData.FunctiondataPoint=PointDoubleDouble
sqdist (Point x y) = x^2+ y^2
calcpi n = fdiv (400*count) $ n^2where fdiv =(/)`on`fromIntegral
count =length$filter ((<=1) . sqdist) points
points = [Point (fdiv j l) $ fdiv i l | i<-[0..l], j<-[0,100..l]]
l = n-1
main = export (toJSStr "calcpi") calcpi
Note the use of [0,100..l] in the second loop - this is to crash faster, because the inner loop is TCO'd but the outer loop results in a few function calls each iteration. However, this only happens the second time it's evaluated:
If I expand the inner loop to [0..l], it will hang indefinitely if I call it with n=5000 first (it probably eventually returns); I would have to call it with lower values of n to successfully blow the stack.
I'm using the latest haste binary release (0.5.5.1). Built with -O2 --opt-all --pretty-print.
The text was updated successfully, but these errors were encountered:
I get some weird SO behavior on the following program, which I think Haste tries to avoid by policy to my understanding. (I tried simplifying the code in a few ways, but it wouldn't crash anymore.)
Note the use of
[0,100..l]
in the second loop - this is to crash faster, because the inner loop is TCO'd but the outer loop results in a few function calls each iteration. However, this only happens the second time it's evaluated:If I expand the inner loop to
[0..l]
, it will hang indefinitely if I call it withn=5000
first (it probably eventually returns); I would have to call it with lower values ofn
to successfully blow the stack.I'm using the latest haste binary release (0.5.5.1). Built with
-O2 --opt-all --pretty-print
.The text was updated successfully, but these errors were encountered: