
Even if you're sure it's not a Nothing, it might be better to use
maybe (error "Impossible, because (...)") id
Which is the same thing as:
fromMaybe (error "Impossible, because (...)")
On Wed, Apr 22, 2015 at 1:23 PM, Marcin Mrotek
Hello,
Well, you CAN use fromJust, but bear in mind that you should only use it if you are absolutely, positively, 100% sure the Maybe value you are calling fromJust on is of the form (Just something), because your program will error out if you call fromJust on a Nothing. Even if you're sure it's not a Nothing, it might be better to use
maybe (error "Impossible, because (...)") id
instead, so that you at the very least get a meaningful error message in case "impossible" happens ;) Other than that, it's recomennded to either use the maybe function, or pattern matching:
case foo of Just x -> ... Nothing -> ...
instead.
Best regards, Marcin Mrotek _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners