[Haskell-cafe] Doubting Haskell
Philippa Cowderoy
flippa at flippac.org
Sun Feb 17 08:32:50 EST 2008
On Sun, 17 Feb 2008, Anton van Straaten wrote:
> Is there a benefit to reusing a generic Either type for this sort of thing?
> For code comprehensibility, wouldn't it be better to use more specific
> names? If I want car and cdr, I know where to find it.
>
It's Haskell's standard sum type, with a pile of instances already
written. There's an instance of MonadError such that you only need to see
an Either when you run the computation for example (and then you get an
Either whatever the actual error monad was!). If we had appropriate
language extensions to map an isomorphic Success/Failure type onto it then
I'd probably use them - as it is, the level of inertia around Either is
great enough to mean that's only worth doing if I'm expecting to roll a
third constructor in at some point.
That said, generally I'll wrap it up pretty fast if I have to handle
Either directly. Not that that's necessarily any different to cons, car
and cdr of course, but there's plenty of library support for doing so.
--
flippa at flippac.org
"I think you mean Philippa. I believe Phillipa is the one from an
alternate universe, who has a beard and programs in BASIC, using only
gotos for control flow." -- Anton van Straaten on Lambda the Ultimate
More information about the Haskell-Cafe
mailing list