On Tue, Jul 27, 2010 at 3:57 PM, Dietrich Epp <d...@zdome.net> wrote:
> The "strMsg" method is used to implement the "fail" method in the resulting > method, and calls to "fail" might be inserted into your code even if you > don't explicitly call it. An example in GHCi: > Prelude> :m + Control.Monad.Error > Prelude Control.Monad.Error> do { Just x <- return Nothing ; return x } :: > Either String Int > Left "Pattern match failure in do expression at <interactive>:1:5-8" > > On 2010 July 27, at 15:32, Gerald Gutierrez wrote: > >> Reading the Control.Monad.Error documentation, I see that the Error class >> has noMsg and strMsg as its only two functions. >> Now, I understand that you can define your own Error instances such as in >> example 1 of the documentation, so why the need to always support strings >> via noMsg/strMsg ? What uses these? And if in my code, I will never throw an >> error with a string, am I supposed to implement these functions and then >> ignore them? >> > I see. So strings must be supported in the case of a bug which cannot be caught at compile time? In other words, if I get an error with a string, I'm pretty much guaranteed it is a bug, i.e. a pattern match error as the "fail" documentation says.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe