[Haskell-cafe] Use unsafePerformIO to catch Exception?
Henning Thielemann
lemming at henning-thielemann.de
Fri Mar 27 07:26:05 EDT 2009
On Thu, 26 Mar 2009, wren ng thornton wrote:
> Functions like uncons and viewL are nicer (because they're safe), but they
> can have overhead because they're unnecessarily complete (e.g. the Maybe
> wrapper can be avoided if we know a-priori that Just will be the constructor
> used).
If you know, it's always Just, then don't use Maybe. There must be some
point in your program, from where it is sure, that it is always Just and
that is the point where to leave Maybe. When I searched my old code for
fromJust and head and review it carefully, I could eliminate them in most
cases.
In another thread (Grouping - Map/Reduce) there was a zipWithInf function
which needed a lazy pattern match on (a:as). This indicates to me, that
lists are the wrong data structure and it would be better to replace it by
an always infinite list type with only one 'cons' constructor.
More information about the Haskell-Cafe
mailing list