[Haskell-cafe] RE: Nested Lists

Paul Keir pkeir at dcs.gla.ac.uk
Thu Jun 4 12:09:29 EDT 2009

Emil, Felipe,

Thanks. I don't know Type Families, but take the point that
the input can be parameterised with something something other
than a list. i.e. (8 :+: 4 :+: 2 :+: ()) presumably has the
same type as (4 :+: 2 :+: ()).

My intention was to use common list functions on the sublists,
but always then a concat for each level, to return to a flat list.
With that in mind I made the following oddity, which in any case
doesn't compile due to its use of infinite types.

app (f:fs) es = appUp (f:fs) es

  where len = genericLength (f:fs)
        appUp   []     es = appDown es len
        appUp   (f:fs) es = appUp (map map fs) (f es)
        appDown es len    = appDown (concat es) (len - 1)
        appDown es 0      = es


I agree with you, a tree would be much better for this. Thanks.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090604/31290354/attachment.html

More information about the Haskell-Cafe mailing list