我正在尝试在Haskell中构建一个函数。我用以下函数创建了一个纯文本文件:
doubleme x = x + x
我把它保存在baby.txt下。
我从命令行导航到该文件,然后从命令行执行以下操作:
ghci
Prelude> :l baby
它返回:
target ‘baby’ is not a module name or a source file
我想知道我做错了什么以及如何使函数编译?
您应该使用.hs扩展名命名该文件。并使用命令加载它:l在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