On Fri, Nov 11, 2005 at 01:20:05PM +0200, Einar Karttunen wrote:
It seems that the type of throwDyn and throwDynTo are dangerously close.
ThrowDyn works in with any of the arguments of throwDynTo, which can
cause evil situations.
throwDyn :: Typeable exception = exception - b
Which means e.g. throwDyn someThreadId SomeException will work
when you wanted to say throwDynTo someThreadId SomeException
and they both have types which unify with IO ().
How evil! ;-)
I think using a
class Typeable = DynamicException a where ...
and throwDyn :: DynamicException a = a - b
could make more sense.
You could also do something like:
newtype Exn a = Exn a -- not Typeable
throwDyn' :: Typeable exception = Exn exception - b
throwDyn' (Exn e) = throwDyn e
used as
throwDyn' (Exn (some-typeably-thingy))
then neither (throwDyn' someThreadId SomeException) nor
(throwDyn' someThreadId (Exn SomeException)) will compile.
And you won't have to create instances of DynamicException, but it is
probably more ugly.
Best regards
Tomasz
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe