[Haskell-cafe] Re: Are there standard idioms for lazy,
pure error handling?
Heinrich Apfelmus
apfelmus at quantentunnel.de
Fri Dec 4 07:20:19 EST 2009
Ketil Malde wrote:
> Although I don't care for the cutesy naming suggested in the 'Train'
> datatype [...]
>
> data TerminatedList a e = Then a (TerminatedList a e)
> | Finally e
>
> (So you could do e.g: 4 `Then` 5 `Then` 1 `Finally` "success!". Of
> course, you might prefer symbols instead.)
I don't mind Then and Finally as constructors. The thing about the
Train is not so much the suggestive constructor names Wagon/Loco or
Cabin/Caboose but that the concept itself has an evocative and short
name, Train .
In contrast, TerminatedList feels too much like an agglomeration of
technical terms to me ("weak head normal form") where the names are
fairly unrelated to the actual definition. (This particularly applies to
"weak", one could as well have dubbed the whole thing "blue head normal
form" without any loss of meaning.) Unfortunately, TerminatedList is
also too long for extended use in type signatures. Something more
evocative and short, similar to the good old "queue" or "stack" would be
great.
How about "trail" or "track", like in
data Trail a b = Then a (Trail a b)
| End b
the idea being that the trail of say a dog eventually leads to the dog
itself.
Another, not entirely serious, suggestion: ;)
data Life a b = Work a (Life a b)
| TheEnd b
Regards,
Heinrich Apfelmus
--
http://apfelmus.nfshost.com
More information about the Haskell-Cafe
mailing list