Changeset 7591

Show
Ignore:
Timestamp:
10/13/05 13:14:33 (3 years ago)
Author:
autrijus
Message:

* change liftM to fmap for more golfing value...

Location:
src/Pugs
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/AST/Internals.hs

    r7590 r7591  
    12871287 
    12881288findSym :: String -> Pad -> Maybe (TVar VRef) 
    1289 findSym name pad = liftM head (lookupPad name pad) 
     1289findSym name pad = fmap head (lookupPad name pad) 
    12901290 
    12911291instance MonadEval Eval 
  • src/Pugs/Compile.hs

    r7579 r7591  
    7979        entries = sortBy padSort $ padToList pad 
    8080        canCompile (name@('&':_), xs) | length xs > 1 = do 
    81             liftM concat $ mapM (\x -> canCompile (name, [x])) xs 
     81            fmap concat $ mapM (\x -> canCompile (name, [x])) xs 
    8282        canCompile (name@('&':_), [(_, sym)]) = do 
    8383            ref <- liftSTM $ readTVar sym 
  • src/Pugs/Eval/Var.hs

    r7579 r7591  
    271271            _               -> Nothing 
    272272    subs :: Int -> [(String, Val)] -> Eval [((Bool, Bool, Int, Int), VCode)] 
    273     subs slurpLen subSyms = (liftM catMaybes) $ (`mapM` subSyms) $ \(_, val) -> do 
     273    subs slurpLen subSyms = fmap catMaybes . forM subSyms $ \(_, val) -> do 
    274274        sub@(MkCode{ subReturns = ret, subParams = prms }) <- fromVal val 
    275275        let rv = return $ arityMatch sub (length (maybeToList invs ++ args)) slurpLen 
  • src/Pugs/Parser.hs

    r7579 r7591  
    15761576    nameExps <- many1 $ do 
    15771577        string "::" 
    1578         (parens ruleExpression) <|> (liftM (Val . VStr . concat) $ sequence [ruleTwigil, many1 wordAny]) 
     1578        (parens ruleExpression) <|> (fmap (Val . VStr . concat) $ sequence [ruleTwigil, many1 wordAny]) 
    15791579    -- Optimization: We don't have to construct a symbolic deref syn (":::()"), 
    15801580    -- but can use a simple Var, if nameExps consists of only one expression 
     
    19671967        -- XXX: This looks slightly odd to me -- is one forced to say 
    19681968        --  $::("?SELF") instead? 
    1969         (parens ruleExpression) <|> (liftM (Val . VStr) $ do 
     1969        (parens ruleExpression) <|> (fmap (Val . VStr) $ do 
    19701970            choice 
    19711971                [ string "!"  --  $! 
    19721972                , string "/"  --  $/ 
    1973                 , liftM concat $ sequence [ruleTwigil, many1 wordAny] ]) 
     1973                , fmap concat $ sequence [ruleTwigil, many1 wordAny] ]) 
    19741974    return $ Syn (sigil:"::()") nameExps 
    19751975 
     
    21692169        qLiteral1 qStart qEnd flags 
    21702170      else do -- XXX an ugly kludge providing crude heredocs 
    2171         endMarker <- (liftM (string) $ many1 wordAny) 
     2171        endMarker <- (fmap string $ many1 wordAny) 
    21722172        qEnd; ruleWhiteSpaceLine 
    21732173        qLiteral1 (fail "never match") endMarker flags 
  • src/Pugs/Prim/List.hs

    r6793 r7591  
    220220op2Map list sub = do 
    221221    args  <- fromVal list 
    222     arity <- liftM length $ (fromVal sub >>= return . subParams) 
     222    arity <- fmap length $ (fromVal sub >>= return . subParams) 
    223223    evl  <- asks envEval 
    224224    vals <- mapMn args arity $ \x -> do