
Neil, I have added missing show functions for CoreFloat and CoreDouble. While testing, I came across this issue: Haskell: module Vt1 where ... y :: Float -> Float y f = case f of 1.0 -> 2.0 3.45 -> 0.2e-4 0.99 -> 7.463 other -> -3.65 Core: Vt1.y v423 = case (YHC.Internal._eqFloat v423 1.0) of Prelude.True -> 2.0 Prelude.False -> -3.65 It looks like a case expression was converted as an if expression. Hopefully this is only a Core problem because: bash$ cat fltest.hs module Main where y :: Float -> Float y f = case f of 1.0 -> 2.0 3.45 -> 0.2e-4 0.99 -> 7.463 other -> -3.65 main = do putStrLn $ show (y 1.0) putStrLn $ show (y 3.45) putStrLn $ show (y 0.99) putStrLn $ show (y 4.56) bash$ yhc fltest.hs Compiling Main ( fltest.hs ) bash$ yhi Main.hbc 2.0 2.0e-5 7.463 -3.65 i. e. the program works OK. -- Dimitry Golubovsky Anywhere on the Web

Hi Dimitry,
y :: Float -> Float
y f = case f of 1.0 -> 2.0 3.45 -> 0.2e-4 0.99 -> 7.463 other -> -3.65
Oh dear, that definately looks like a bug! I'll look into it later - the Float/Double stuff has so far been entirely unused by my code, so thats probably how these bugs have survived. Thanks Neil

"Dimitry Golubovsky"
y f = case f of 1.0 -> 2.0 3.45 -> 0.2e-4 0.99 -> 7.463 other -> -3.65
Eek! Whilst you have certainly found a bug, it has to be said that pattern-matching against literal floats is a _really_ bad idea in general anyway. I'm hoping that Float patterns will be kicked out of Haskell-prime, so that programmers are forced to think a bit harder about what they really want. Regards, Malcolm

Hi, y x = case x of 1 -> 10 2 -> 20 3 -> 30 _ -> 0 Now gives: Vt1.y v229 = case (YHC.Internal._eqFloat v229 1.0) of Prelude.True -> 10.0 Prelude.False -> case (YHC.Internal._eqFloat v229 2.0) of Prelude.True -> 20.0 Prelude.False -> case (YHC.Internal._eqFloat v229 3.0) of Prelude.True -> 30.0 Prelude.False -> 0.0 I had a problem with the semantics of nested fatbar's that allow failure to escape, with the help of Tom and this example I've tracked it down and squashed that bug. I just pushed the fix. Thanks Neil
participants (3)
-
Dimitry Golubovsky
-
Malcolm Wallace
-
Neil Mitchell