
On Mon, Sep 9, 2013 at 1:26 PM, Bryan Vicknair
Deep in a WAI web app, I have a function that converts a String from a web form like "0.12" to an Int 12. Converting "0.12" to the Float 0.12 is working. However, converting the Float 0.12 to the Int 12 does not work as expected unless I use the trace function.
Not answering your question but can't you read . drop 1 . dropWhile (/= '.') $ "0.12" ?
In the following, f = 0.12::Float, gotten from a function that parses "0.12" into 0.12.
In the following expression, the result is: Success (Just 11).
Success $ Just $ truncate (f * 100)
In the following expression, the result is: Success (Just 12)
let expanded = f * 100 ans = truncate expanded in trace (show expanded) $ Success $ Just $ ans
That made me think that "f * 100" had to be strictly evaluated before given to truncate for some reason, so I tried using seq to get the same effect, but that didn't work. Am I correct in assuming that laziness has something to do with this problem?
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- MM "All we have to decide is what we do with the time that is given to us"