Magicloud Magiclouds <magicloud.magiclo...@gmail.com> wrote:

>   Read often throws runtime errors, which breaks the robust of the
> problem. How to deal with it? Without lost too much proformance (so
> reads is a no).
>   At least, if its error could be catched, that'd be better.

You might like to try using a real parser instead of read.  For
instance, the polyparse package provides module Text.Parse which
provides parser analogues for all of the Prelude instances of Read.  It
provides nice-ish error messages, or in the lazy variation, catchable
exceptions.

It also gives you a nice framework to write your own instances.
The DrIFT tool can automatically derive these instances for your own
datatypes, if you don't want to do it by hand.  (I expect it is easy to
teach the 'derive' tool to do it too.)

Regards,
    Malcolm
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to