
Message: 15 From: Xiao-Yong Jin
John Lato writes: So I have another question. Is the following function safe and legitimate?
safeDiv :: (Exception e, Integral a) => a -> a -> Either e a safeDiv x y = unsafePerformIO . try . evaluate $ div x y
I believe it should be okay to use this 'safeDiv'. What do you think?
Your question is unclear. Are you asking if this function can be safely used with current Haskell standards and implementations or are you asking should the Haskell specification make a guarantee that this function will do what you want? I would answer "no" either way, but for different reasons. Common to both is: Don't use unsafe* functions unless you can prove that your usage is safe. That is proof as in mathematical usage; it must be rigorous and complete. John Lato