I met the following code in GHC.Prim :
...
negateFloat# :: Float
negateFloat# = let x = x in x
-- |Truncates a @Float#@ value to the nearest @Int#@.
-- Results are undefined if the truncation if truncation yields
-- a value outside the range of @Int#@.
float2Int# :: Float
float2Int# = let x = x in x
expFloat# :: Float
expFloat# = let x = x in x
logFloat# :: Float
logFloat# = let x = x in x
...
In particular:
float2Int# shouldn't even check type- None of the functions accepts an argument and therefore does not look correct
- None of the functions apply the mathematical operation that they require.
- All functions are "infinitely recursive":
let x = x
I know that the extension is called "MagicHash", but it cannot be magical. What gives?
(I think I should add a disclaimer that I have no idea what, in fact -XMagicHash, I just assumed that he allowed the syntax #and nothing more.)
source
share