99problems: different response from ghci <--> runhaskell / ghc

Hi all, trying to solve the problem 6 "reverse a list" I'm getting a different behaviour from ghci / runhaskell. main = do putStrLn $ concat (map show (myReverse [1,2,3])) -- putStrLn $ concat (map show (myReverse [])) myReverse :: [a] -> [a] myReverse [] = [] myReverse (x:xs) = go [] (x:xs) where go :: [a] -> [a] -> [a] go curr (x:xs) | null xs = [x] ++ curr go curr (x:xs) = go ([x] ++ curr) xs the second putStrLn (once uncommented) gives this error in the runhaskell/ghc: Ambiguous type variable `a0' in the constraint: (Show a0) arising from a use of `show' Probable fix: add a type signature that fixes these type variable(s) In the first argument of `map', namely `show' _but_ if I load the same source into ghci I can successfully enter&run the command: Prelude> :reload [1 of 1] Compiling Main ( 05.hs, interpreted ) Ok, modules loaded: Main. *Main> putStrLn $ concat (map show (myReverse [])) *Main> Then if I "help" the type inference changing the myReverse type declaration to: myReverse :: [Int] -> [Int] everything works well So, my question is: _where_ is the difference between ghci / runhaskell? thx

Hi.
So, my question is: _where_ is the difference between ghci / runhaskell?
See here: http://www.haskell.org/ghc/docs/latest/html/users_guide/interactive-evaluati... Cheers, Andres -- Andres Löh, Haskell Consultant Well-Typed LLP, http://www.well-typed.com

thanks Andres
On Fri, Aug 17, 2012 at 11:35 AM, Andres Löh
Hi.
So, my question is: _where_ is the difference between ghci / runhaskell?
See here:
http://www.haskell.org/ghc/docs/latest/html/users_guide/interactive-evaluati...
Cheers, Andres
-- Andres Löh, Haskell Consultant Well-Typed LLP, http://www.well-typed.com
participants (2)
-
Andres Löh
-
GiGi