[Haskell-cafe] Same compiled program behaving differently when called from ghci and shell

Bruno Damour llama at ruomad.net
Sun Nov 21 00:49:52 EST 2010

I have a very strange (for me) problem that I manage to reduce to this :
I have a small program that reads a file with 1 only character (è = e8)
The program is ftest2.hs :

import IO

import Data.Maybe

tfind s = lookup (head s) $ zip ['\xe8', '\xde'] "12"

main    = do

             h<- readFile "g:\\CODE\\rlib\\test.txt"

             putStrLn h

             print $ tfind h

I compile it from command line :

ghc --make ftest2.hs

Now the weird results :
1/ cmd line:



Just '2'

2/ ghci

Prelude>  :!ftest2.exe


Just '2'


Prelude>  :! ftest2.exe


Just '1'

I tested different variants, there is always a difference.
Any idea to help me trace this behaviour ?

More information about the Haskell-Cafe mailing list