我已经做了一些研究,但找不到任何东西。我不明白这样的功能是如何工作的:
func :: Maybe (Int) -> Maybe (Int)
Run Code Online (Sandbox Code Playgroud)
我应该如何进行模式匹配?我已经尝试过了,但是没有用:
func Just a = Just a | otherwise = Nothing
func Nothing = Just Nothing | otherwise = Nothing
Run Code Online (Sandbox Code Playgroud)
我该如何进行这项工作?
错误信息:
Run Code Online (Sandbox Code Playgroud)exercises6.hs:83:22: error: parse error on input ‘|’ | 83 | func Just a = Just a | otherwise = Nothing | ^