我是新來的Haskell,我堅持了一個例子。我想用或許型實驗,但我的代碼不會編譯:哈斯克爾函數定義的錯誤:在範圍上並不
divide100By :: Int a -> Maybe a
divide100By x = case (Int x) of
Nothing -> Nothing
Just x -> 100/x
main = putStrLn ("Result: " ++ show (divide100By 5))
但我總是得到錯誤:
Not in scope: data constructor 'Int'
我怕我不太在Haskell中獲取函數定義(divide100By :: Int a - >也許是一個部分)...有人可以告訴我這裏有什麼問題嗎?
'Int'並不需要一個類型參數,所以你要'divide100By ::詮釋 - >也許Int'。你的函數體也有至少3個其他問題... – Alec