Skip to content

Commit

Permalink
haskell/core-libraries-committee#33 : Remove uses of MonadFail (ST _)
Browse files Browse the repository at this point in the history
There was a use of `fail` for `Maybe` which is entirely pointless.
  • Loading branch information
andreasabel committed Jan 28, 2022
1 parent 2c757b5 commit 1afa860
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Data/IntMap/EnumMap2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ notMember k (EnumMap m) = M.notMember (fromEnum k) m

{-# INLINE lookup #-}
lookup :: (Enum key) => key -> EnumMap key a -> Maybe a
lookup k (EnumMap m) = maybe (fail "EnumMap.lookup failed") return $ M.lookup (fromEnum k) m
lookup k (EnumMap m) = M.lookup (fromEnum k) m

findWithDefault :: (Enum key) => a -> key -> EnumMap key a -> a
findWithDefault a k (EnumMap m) = M.findWithDefault a (fromEnum k) m
Expand Down
3 changes: 2 additions & 1 deletion lib/Text/Regex/TDFA/NewDFA/Engine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ execMatch r@(Regex { regex_dfa = DFA {d_id=didIn,d_dt=dtIn}
challenge x1@((_si1,ins1),_p1,_o1) x2@((_si2,ins2),_p2,_o2) = {-# SCC "goNext.findTrans.challenge" #-} do
check <- comp offset x1 (newPos ins1) x2 (newPos ins2)
if check==LT then return x2 else return x1
(first:rest) <- mapM prep (IMap.toList sources)
first_rest <- mapM prep (IMap.toList sources)
let first:rest = first_rest
set which destIndex =<< foldM challenge first rest
let dl = IMap.toList dtrans
mapM_ findTransTo dl
Expand Down
3 changes: 2 additions & 1 deletion lib/Text/Regex/TDFA/NewDFA/Engine_FA.hs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ execMatch (Regex { regex_dfa = DFA {d_id=didIn,d_dt=dtIn}
challenge x1@((_si1,ins1),_p1,_o1) x2@((_si2,ins2),_p2,_o2) = {-# SCC "goNext.findTrans.challenge" #-} do
check <- comp offset x1 (newPos ins1) x2 (newPos ins2)
if check==LT then return x2 else return x1
(first:rest) <- mapM prep (IMap.toList sources)
first_rest <- mapM prep (IMap.toList sources)
let first:rest = first_rest
set which destIndex =<< foldM challenge first rest
let dl = IMap.toList dtrans
mapM_ findTransTo dl
Expand Down

0 comments on commit 1afa860

Please sign in to comment.