Direct use of if-then-else with function type cause "Program error"
With the following code
run f = f 7 (-3)
programError wd initVal = (if initVal < 0 then showAsUnsiged else const show) wd initVal noProblem wd initVal = f wd initVal where f = if initVal < 0 then showAsUnsiged else const show
showAsUnsiged width nIn = show n where n | nIn < 0 = 2^width + nIn | otherwise = nIn
I get: $ hugs HugsIfFuncBug.lhs __ __ __ __ ____ ___ _________________________________________ || || || || || || ||__ Hugs 98: Based on the Haskell 98 standard ||___|| ||__|| ||__|| __|| Copyright (c) 1994-2002 ||---|| ___|| World Wide Web: http://haskell.org/hugs || || Report bugs to: hugs-bugs@haskell.org || || Version: November 2002 _________________________________________ Haskell 98 mode: Restart with command line option -98 to enable extensions Reading file "/usr/lib/hugs/libraries/Hugs/Prelude.hs": Reading file "/usr/lib/hugs/libraries/Prelude.hs": Reading file "HugsIfFuncBug.lhs": Hugs session for: /usr/lib/hugs/libraries/Hugs/Prelude.hs /usr/lib/hugs/libraries/Prelude.hs HugsIfFuncBug.lhs Type :? for help Main> run noProblem "125" Main> run programError " Program error: {instShow_v14_v1224 (showAsUnsiged instIntegral_v34 instOrd_v27 instNum_v30 (Num_fromInt (Real__sc0_Real (Integral__sc0_Integral instIntegral_v34)) 7))} Main> :q [Leaving Hugs] Thanks. mike
participants (1)
-
Mike Gunter