我有一个带有Type签名的函数
a -> b -> (a, b)
我有
Maybe a
如何映射这样的功能以便我可以
(a->b->(a,b)) -> Maybe a -> (Maybe a, b)
答案 0 :(得分:0)
您需要稍微更改功能定义
g : (a -> b -> (a,b)) -> Maybe a -> b -> (Maybe a, b)
g f ma b =
case ma of
Nothing -> (Nothing, b)
Just a ->
let
r = f a b
in
(Just (first r), second r)