Strange behavior in GHC-compiled code