mifrai
mifrai

Reputation: 103

Convert Data.Sequence to a List?

Is there a generally accepted way of converting a Data.Sequence (Seq a) to a list [a]?

I see there's a fromList, but no toList

Upvotes: 9

Views: 4494

Answers (1)

huon
huon

Reputation: 102206

There is a Foldable instance for Seq a, and this provides a toList method. e.g. this will print [1,2,3,4,5,6,7,8,9,10]

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

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

Upvotes: 20

Related Questions