[jhc] Control.Exception
John Meacham
john at repetae.net
Sat Aug 29 20:49:00 EDT 2009
On Sat, Aug 29, 2009 at 12:07:51PM -0700, Taral wrote:
> On Fri, Aug 28, 2009 at 5:22 PM, John Meacham<john at repetae.net> wrote:
> > That said, I am still undecided about imprecise exceptions. (catching
> > pattern match failures and error calls). They inhibit the optimizer and
> > signal bugs, not catchable exceptions. I may introduce a flag to control
> > this behavior though.. imprecise exceptions are occasionally useful for
> > things like writing an interpreter...
>
> Perhaps a flag to ignore impossible-to-reach _ cases at the end of a
> match block? Then one can simply add:
>
> _ -> throw xyz
>
> to the end of blocks where one wants these exceptions.
You can do this anyway, or could if jhc's throw support worked :),
for every case expression:
case ... of
Foo -> y
Bar -> z
jhc adds an alternate at the end
_ -> error "Unmatched case at file:line-number"
then the simplifier will delete any unreachable alternatives. So no need
for a switch, impossible to reach alternatives of any form are always
deleted.
John
--
John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/
More information about the jhc
mailing list