I'm completely new to Haskell. To grasp the basics I've started working through 'Learn you a Haskell for Great Good'. I'm stuck on the simple matter of loading a function from a file.
The file is called baby.hs
and contains the function
doubleMe x = x + x
and nothing else. I've saved it in /Users/me
.
Typing :load baby
into GHCi, I get the following error:
target `baby' is not a module name or a source file.
I'm working on a Mac and I created my baby.hs
file using TextEdit set to produce a plain text/UTF-8 file. I think my home directory is /Users/me
although I'm not sure how to check this from GHCi, it is from when I check from bash before running GHCi.
Any idea what I'm doing wrong?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With