Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load files into ghci

Tags:

haskell

ghci

I'm trying to build a function in Haskell. I created a plain text file with the following function:

doubleme x = x + x

I saved it under baby.txt.

I navigated to the file from the command line, then I did the following from the command line:

ghci
Prelude> :l baby

it returned:

target ‘baby’ is not a module name or a source file

I was wondering what I'm doing wrong and how to make the function compile?

like image 659
junibug Avatar asked Oct 23 '25 14:10

junibug


1 Answers

You should name the file with .hs extension. and loading it using command :l in ghci

Prelude> :l baby.hs
[1 of 1] Compiling Main             ( baby.hs, interpreted )
Ok, one module loaded.
*Main>
*Main>
*Main>
*Main> :t doubleme
doubleme :: Num a => a -> a
like image 188
suhao399 Avatar answered Oct 26 '25 09:10

suhao399



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!