Export lists in modules

John Meacham john at repetae.net
Tue Feb 28 06:26:08 EST 2006


On Tue, Feb 28, 2006 at 08:52:00AM +0100, Johannes Waldmann wrote:
> Cale Gibbard wrote:
> 
> > This is exactly why lists are so common. If people ask why lists are
> > so common in lazy functional languages, they ought also to ask why
> > loops are so common in imperative languages.
> 
> A loop is a sequence of actions. In FP, I don't typically have actions,
> rather I collect values, so I'd need several collections types,
> among them: sequences, and among them: classical left-biased lists.

I think the point was that lists in haskell trancend just being a
collection type or a data structure. They are a generally useful tool
for composing functions. And like cale said, they often subsume loops
and all sorts of other control constructs.

I mean, even a for loop in haskell is done as
mapM action [0..10]

I'd say _most_ uses of lists are deforested away because they are used
to express control and dataflow and arn't actually used as persistant
structures. demoting them to just being a 'collection type' would be a
disservice. That they can be used as a collection is a bonus, but not
their main feature.

the foldr/build trick for deforesting lists is really really cool! look
at ghc core, it is amazing how all your lists just disapear and are
turned into clever function compositions I would have never thought of :)

        John

-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Haskell-prime mailing list