haskell - Traversable 概念的术语
问题描述
为什么我们将结构的翻转称为“序列”,为什么要谈论“遍历”和“遍历”?
我正在讨论这些概念的haskell中的实现......
class (Functor t, Foldable t) => Traversable t where
{-# MINIMAL traverse | sequenceA #-}
-- | Map each element of a structure to an action, evaluate these actions
-- from left to right, and collect the results. For a version that ignores
-- the results see 'Data.Foldable.traverse_'.
traverse :: Applicative f => (a -> f b) -> t a -> f (t b)
traverse f = sequenceA . fmap f
-- | Evaluate each action in the structure from left to right, and
-- and collect the results. For a version that ignores the results
-- see 'Data.Foldable.sequenceA_'.
sequenceA :: Applicative f => t (f a) -> f (t a)
sequenceA = traverse id
解决方案
它是“排序”,而不是“a” 。即“按特定顺序排列”,这里从左到右。而且是对sequence :: Monad m => [m a] -> m [a]
(注意旧版base
)的概括,可能会让名字更明显。
推荐阅读
- javascript - 将数字转换为单词,但不能使用重复的数字进行转换
- .net - 如何向具有获取属性的类提供数据以进行单元测试
- laravel - 在 Safari 浏览器中从 iOS 移动设备上的 Facebook Messenger 链接重定向时,网站显示空白页
- mongodb - docker-compose 上带有用户密码的 graylog mongdb 配置
- apache-kafka - 融合云kafka集群如何扩容?
- java - 如何忽略一些 Java 的 Files.lines 行尾分隔符
- flutter - 为什么“设置类型的值
' 无法从方法 'toHive' 返回,因为它的返回类型为 'ShProblemHive'。” - ios - Xamarin Forms:防止键盘调整视图大小
- javascript - Ruby 和其他语言(Python、JavaScript)不同的 hmac sha256 结果
- javascript - 每当解决承诺时如何附加到状态?