小编too*_*mas的帖子

func :: Maybe(Int)-> Maybe(Int)

我已经做了一些研究,但找不到任何东西。我不明白这样的功能是如何工作的:

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)

我该如何进行这项工作?

错误信息:

exercises6.hs:83:22: error: parse error on input ‘|’
   |
83 | func Just a = Just a | otherwise = Nothing
   |                      ^
Run Code Online (Sandbox Code Playgroud)

haskell functional-programming maybe

3
推荐指数
1
解决办法
77
查看次数

标签 统计

functional-programming ×1

haskell ×1

maybe ×1