Error loading function from file in GHCi

As @clintm suggests, first fix your doubleMe function. What you have will give errors --- but not the errors you're reporting.

The simplest way to get ghci to find your file is to make sure you start ghci from the same directory your file is saved in. Open a terminal window, and type

cd /Users/me
ls

ls lists the contents of the current directory; you should see your file. If you do, great! Type ghci at the bash prompt, and :load baby should work. If not, you haven't saved your file where you think you have. Go back to TextEdit or use Spotlight to see where you've really put it.


You're missing the module line. The first line of baby.hs should be

module Baby where

As far as doubleMe is concerned, you are missing declaring x as an argument to the function.

doubleMe x = x + x

Otherwise, your function doesn't know what x is.


Try using the complete path, for example:

:load /Users/me/baby.hs

You should also be able to use relative paths. Try navigating to the directory that baby.hs is in first:

% cd /Users/me
% ghci
GHCi blah blah blah
Prelude> :load baby.hs

When you get that working, then try leaving off the .hs. I'm not 100% sure under what circumstances that works.