本文介绍了为什么我们有map,fmap和liftM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

map 存在以简化列表和历史原因的操作(请参阅)。

- ,第20页



fmap 和 liftM 存在,因为monads不是自动函子在Haskell中:

- ,第33页

编辑:agustuss历史 map 和 fmap :

-

map :: (a -> b) -> [a] -> [b]

fmap :: Functor f => (a -> b) -> f a -> f b

liftM :: Monad m => (a -> b) -> m a -> m b

Why do we have three different functions that do essentially the same thing?

map exists to simplify operations on lists and for historical reasons (see What's the point of map in Haskell, when there is fmap?).

-- Typeclassopedia, page 20

fmap and liftM exist because monads were not automatically functors in Haskell:

-- Typeclassopedia, page 33

Edit: agustuss's history of map and fmap:

-- What's the point of map in Haskell, when there is fmap?

这篇关于为什么我们有map,fmap和liftM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 14:27