0
我試圖從一個叫做面文件(編譯罰款)錯誤導入哈斯克爾模塊
import qualified surface.Shapes as Shapes
surfaceImport :: Shape -> Float
surfaceImport (Circle _ r) = pi * r^2
surfaceImport (Rectangle (Point x1 x2) (Point y1 y2)) = (abs $ x1 - x2) * (abs $ y1 - y2)
我收到以下錯誤,當我嘗試編譯這個程序中導入指定形狀Haskell的模塊時
surfaceImport.hs:1:18: error: parse error on input `surface'
Failed, modules loaded: none.
我試圖導入該模塊是本
module Shapes
(
Point(..),
Shape(..),
surface,
nudge,
baseCircle,
baseRectangle
)
在ADVA謝謝NCE 其中
https://downloads.haskell.org/~ghc/7.0.3/docs/html/users_guide/separate-compilation.html –
的模塊的名稱和文件的名稱應該相同。在你的情況下,將文件表面重命名爲Shapes並在你的surfaceImport模塊中導入Shapes。另一個問題是你在導出中有一個叫做surface的函數。您的文件名和功能不應該有相同的名稱。 – siebenschlaefer