我有以下定义:
env = DataMap.fromList [
                ("foo",42), ("bar",69),
                ("baz",27), ("qux",0)
               ]
doSomething:: String →  Writer [String] Int
doSomething s = do
            let v = DataMap.lookup s env
            case v of
                Nothing →  fail $  s ++ " not found"
                Just a →  do
                            tell [s ++ " →  " ++ (show a)]
                            return a
这段代码真正让我烦恼的是在 doSomething 中使用模式匹配。它完全违背了使用单子的目的。有没有什么方法可以只使用单子函数而不使用单子转换器来重写 doSomething 函数?