Ross Mellgren schrieb: > You've applied two solutions to get the value out -- pattern matching > (Just reinfo) and fromJust. You should use one or the other, but not both: > > -- pattern matching > remLookupFwd :: (ReVars m t) => SimplRe t -> ReM m t (ReInfo t) > remLookupFwd re > = do fwd <- gets resFwdMap > let { Just reinfo = M.lookup re fwd } -- PROBLEM > return reinfo > > -- fromJust > remLookupFwd :: (ReVars m t) => SimplRe t -> ReM m t (ReInfo t) > remLookupFwd re > = do fwd <- gets resFwdMap > let { reinfo = fromJust (M.lookup re fwd) } > -- PROBLEM > return reinfo > > BTW, I would personally write this as one line (untested) > > gets (fromJust . M.lookup re . resFwdMap)
fromJust should be avoided, since it is partial and if it results in an error, the error message points to the implementation of fromJust, not its application. Pattern matching is better, but 'maybe' and 'fromMaybe' are best. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe