
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) -Ross On Jun 3, 2009, at 1:18 PM, Vasili I. Galchin wrote:
Hi Andrew (Bromage),
I reversed the parameter order to Data.Map.lookup and calling fromJust to pull out value from Maybe wrapper ... all as you suggested:
remLookupFwd :: (ReVars m t) => SimplRe t -> ReM m t (ReInfo t) remLookupFwd re = do fwd <- gets resFwdMap let { Just reinfo = fromJust(M.lookup re fwd) } -- PROBLEM return reinfo
I am still getting a type mismatch:
Swish\HaskellRDF\Dfa\Dfa.lhs:162:29: Couldn't match expected type `Maybe t' against inferred type `ReInfo t1' In the expression: fromJust (M.lookup re fwd) In a pattern binding: Just reinfo = fromJust (M.lookup re fwd) In the expression: do fwd <- gets resFwdMap let Just reinfo = fromJust (M.lookup re fwd) return reinfo
Vasili _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe