[darcs-devel] [patch1246] issue822: Improve error message with generalized IO type

Ben Franksen ben.franksen at online.de
Fri Jan 9 20:46:13 UTC 2015


Ernesto Rodriguez wrote:
>> One question though: Is the generalization to MonadIO etc really
> necessary to achive the goal i.e. capture the stderr output?
> 
> No it is not necessary. The issue can be resolved w/o doing this. Two
> solutions are possible:
> 
> 1) Throw an exception and not make visible in the type and catch the
> exception in the "tryIdentifyRepoFormat" funtion as currently done. The
> disatvantage of this approach is having an effect (ie. the exeption) not
> visible in the type.
> 
> 2) Changing the function "copyFileOrUrl", "copySsh" and some other
> functions (the ones that now have the MonadIO type) to return an Either
> type. The problem here is that the functions are used in many other places
> in darcs so it would require significant refactoring. This would take some
> more time.
> 
> I can easily  adjust my patch and implement #1, but I don't see any
> shortcommings in having the exception visible in the type.

Ah, I missed the part about the exception being visible in the type now. 
That's indeed an advantage of your approach. It is an interesting technique 
which I haven't seen used anywhere else yet. I wonder how it scales if one 
adds more exception types...

As for disadvantages, my main gripe with more overloading is that the type 
error messages become less useful and harder to understand (another one is 
code complexity). I guess it's a trade-off with me now being slightly in 
favor. I have just checked that your patch works with ghc-7.4.1 (about which 
I had some worries; this is the version you get with debian stable and I 
think the oldest ghc we support). So with that out of the way I think I will 
screen the patch. Looking forward to a follow up w.r.t. fixing error 
messages.

BTW, forgot to say: thanks for the contribution!

Cheers
Ben
-- 
"Make it so they have to reboot after every typo." -- Scott Adams




More information about the darcs-devel mailing list