Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 将数据序列转换为列表?_Haskell - Fatal编程技术网

Haskell 将数据序列转换为列表?

Haskell 将数据序列转换为列表?,haskell,Haskell,是否有一种普遍接受的方式将数据序列(Seq a)转换为列表[a] 我看到有一个fromList,但没有toList,有一个Seq a的实例,这提供了一个方法。e、 g.这将打印[1,2,3,4,5,6,7,8,9,10] import Data.Foldable (toList) import Data.Sequence (fromList) main = print . toList . fromList $ [1..10] 我将教你如何钓鱼:如果你去搜索(你想要的函数的类型签名),第一个

是否有一种普遍接受的方式将数据序列(Seq a)转换为列表[a]

我看到有一个fromList,但没有toList,有一个
Seq a的实例,这提供了一个方法。e、 g.这将打印[1,2,3,4,5,6,7,8,9,10]

import Data.Foldable (toList)
import Data.Sequence (fromList)

main = print . toList . fromList $ [1..10]

我将教你如何钓鱼:如果你去搜索(你想要的函数的类型签名),第一个点击的是dbaupp提到的
toList
函数。Hoogle并不总是能够找到你想要的,但它总是值得检查的。这个答案最重要的部分是:不要忽略实例列表!它们对于类型的完整API通常非常重要。