[Haskell-cafe] Re: Are there standard idioms for lazy, pure error handling?

wren ng thornton wren at freegeek.org
Mon Dec 7 23:49:45 EST 2009

Nicolas Pouillard wrote:
> Excerpts from Henning Thielemann's message of Mon Dec 07 20:36:27 +0100 2009:
>> @Apfelmus:
>> For practical purposes I think Train should have swapped type parameters 
>> in order to make Functor act on the type of the list elements.
>> data Train b a = Wagon a (Train b a)
>>                 | Loco  b
> The functor on the Loco/Caboose makes sense too and swapping the arguments
> is less natural to read.

Indeed, Train is a bifunctor. Choosing one over the other is as 
arbitrary as choosing one over the other for (,) or Either. The only 
difference here is that the two functors aren't "the same". There are 
reasons for wanting both instances depending on how the structure is 
being used.

It's times like this that I wish Haskell had real type-level functions, 
at least for swap and compose, without the need for newtype wrappers or 
type-family peculiarities.

Live well,

More information about the Haskell-Cafe mailing list