我遇到的问题是这样的:
以与 mapMaybe 类似的方式,定义函数:composeMaybe :: (a->Maybe b) -> (b -> Maybe c) -> (a-> Maybe c) 组合两个引发错误的函数。
Maybe a 类型和 mapMaybe 函数的编码如下:
data Maybe a = Nothing | Just a
mapMaybe g Nothing = Nothing
mapMaybe g (Just x) = Just (g x)
我尝试使用这样的组合:
composeMaybe f g = f.g
但它不编译。
谁能指出我正确的方向?