instance (Functor m) => Functor (MaybeT m) where
fmap f m = MaybeT $ fmap (\x -> case x of
Just j -> Just (f j)
Nothing -> Nothing
) (runMaybeT m)
我对Functor MaybeT
的实施。但是,在我的眼中,似乎有点丑陋;)来自monadic语义/ monadic解决方案。请建议我一些更好的功能程序员的建议:)。