簡體   English   中英

如何將文件加載到ghci中

[英]How to load files into ghci

我正在嘗試在Haskell中構建一個函數。 我使用以下功能創建了一個純文本文件:

doubleme x = x + x

我將其保存在baby.txt下。

我從命令行導航到文件,然后從命令行執行以下操作:

ghci
Prelude> :l baby

它返回:

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

我想知道我在做什么錯以及如何使函數編譯?

您應該以.hs擴展名命名文件。 並在ghci中使用命令:l加載它

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM