John Millikin schrieb:
Earlier today I uploaded the capped-list package; I didn't think there
would be any interest, since it's a relatively trivial data structure,
but already there's been three emails and an IRC convo about it.

In short, this is Heinrich Apfelmus's "Train" type from
<http://www.haskell.org/pipermail/haskell-cafe/2009-December/069895.html>,
which showed up in a thread I posted regarding lazy error handling
<http://www.haskell.org/pipermail/haskell-cafe/2009-November/069825.html>.
The structure of a Train / CappedList (I like my name better) is:

    data Train a b = Wagon a (Train a b) | Loco  b
    data CappedList cap a = Next a (CappedList cap a) | Cap cap

Since uploading, there's been a big problem pointed out to me
regarding this structure, namely the possible definitions of |append|.
Because the list terminus is itself a value, but isn't / shouldn't be
the same type as the elements, either obvious implementation will drop
it.

    append :: CappedList cap a -> CappedList cap a -> CappedList cap a
    append (Cap 0) (Cap 1) = -- either (Cap 0) or (Cap 1), but
information has been lost


For exception handling I need
append :: CappedList (Maybe exception) a -> CappedList (Maybe exception) a -> CappedList (Maybe exception) a

where 'append' appends the second list only, if the first list did not end with an exception.

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to