Show
Ignore:
Timestamp:
07/17/06 18:46:52 (2 years ago)
Author:
cjeris
Message:

Make hyperops distribute into lists, sort of: they propagate down into lists now, but references
are forcibly dereferenced, which is wrong.

Files:
1 modified

Legend:

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

    r10356 r11585  
    316316        | VRef x' <- x 
    317317        = doHyper =<< readRef x' 
     318        | VList x' <- x 
     319        = op1HyperPrefix sub x 
    318320        | otherwise 
    319321        = enterEvalContext cxtItemAny $ App (Val $ VCode sub) Nothing [Val x] 
     
    344346    = fail "Hyper OP only works on lists" 
    345347    where 
    346     doHyper x y = enterEvalContext cxtItemAny $ App (Val $ VCode sub) Nothing [Val x, Val y] 
     348    doHyper x y  
     349        | VRef x' <- x, VRef y' <- y 
     350        = join $ liftM2 doHyper (readRef x') (readRef y') 
     351        | VRef x' <- x 
     352        = (flip doHyper $ y) =<< readRef x' 
     353        | VRef y' <- y 
     354        = doHyper x =<< readRef y' 
     355        | VList x' <- x 
     356        = op2Hyper sub x y 
     357        | VList y' <- y 
     358        = op2Hyper sub x y 
     359        | otherwise 
     360        = enterEvalContext cxtItemAny $ App (Val $ VCode sub) Nothing [Val x, Val y] 
    347361    hyperLists [] [] = return [] 
    348362    hyperLists xs [] = return xs