Show
Ignore:
Timestamp:
08/18/06 20:47:21 (2 years ago)
Author:
audreyt
Message:

* Glorious refactoring of the SubAssoc? type.

Instead of using a string such as "left" "right" "non", we now
use the SubAssoc? type, which simplified the logic in many places.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim/List.hs

    r12317 r12422  
    160160op2ReduceL keep list sub = do 
    161161    code <- fromVal sub 
    162     op2Reduce keep list $ VCode code{ subAssoc = "left" } 
     162    op2Reduce keep list $ VCode code{ subAssoc = A_left } 
    163163 
    164164op2Reduce :: Bool -> Val -> Val -> Eval Val 
     
    182182            evl (App (Val sub) Nothing (map Val xs)) 
    183183    case subAssoc code of 
    184         "right" -> do 
     184        A_right -> do 
    185185            let args' = reverse args 
    186186            reduceMn args' n (doFold . reverse) 
    187         "chain" -> if arity /= 2            -- FIXME: incorrect for scans 
     187        A_chain -> if arity /= 2            -- FIXME: incorrect for scans 
    188188            then fail 
    189189                "When reducing using a chain-associative sub,\nthe sub must take exactly two arguments." 
     
    196196                reduceM doFold' (head args) (tail args) 
    197197                return $ VBool True 
    198         "non"   -> fail $ "Cannot reduce over non-associativity" 
     198        A_non   -> fail $ "Cannot reduce over non-associativity" 
    199199        _       -> reduceMn args n doFold -- "left", "pre" 
    200200    where