Ignore:
Timestamp:
May 3, 2014, 5:01:55 PM (11 years ago)
Author:
gobi
Message:

expression

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sizechecking/branches/macs/Ops.hs

    r21 r23  
    1010class (Lambda l) => LOps l where 
    1111    infixop :: String -> Int -> (a -> b -> c) -> l a -> l b -> l c 
     12    infixopr :: String -> Int -> (a -> b -> c) -> l a -> l b -> l c 
     13    infixopl :: String -> Int -> (a -> b -> c) -> l a -> l b -> l c 
    1214    fun :: String -> a -> l a 
    1315 
    1416    (+) :: l Int -> l Int -> l Int 
    15     (+) = infixop "+" 4 (Prelude.+) 
     17    (+) = infixopl "+" 6 (Prelude.+) 
    1618 
    1719    (-) :: l Int -> l Int -> l Int 
    18     (-) = infixop "-" 4 (Prelude.-) 
     20    (-) = infixopl "-" 6 (Prelude.-) 
    1921 
    2022    (*) :: l Int -> l Int -> l Int 
    21     (*) = infixop "*" 5 (Prelude.*) 
     23    (*) = infixopl "*" 7 (Prelude.*) 
    2224 
    2325 
    2426instance LOps Q where 
    25     infixop _ _ f lhs rhs = Q (eval lhs `f` eval rhs) 
     27    infixopl _ _ f lhs rhs = Q (eval lhs `f` eval rhs) 
     28    infixop  _ _ f lhs rhs = Q (eval lhs `f` eval rhs) 
     29    infixopr _ _ f lhs rhs = Q (eval lhs `f` eval rhs) 
    2630    fun _ = Q 
    2731 
     
    2933    fun name _ = S (\_ p -> Prelude.showsPrec p name) 
    3034 
    31     infixop name prec _ lhs rhs = S(\s p -> 
     35    infixopl name prec _ lhs rhs = S(\s p -> 
    3236        let (s1, s2) = S.split2 s 
    3337        in Prelude.showParen (p Prelude.> prec) $ 
     
    3640            unS rhs s2 (Prelude.succ prec) 
    3741        ) 
     42    infixop name prec _ lhs rhs = S(\s p -> 
     43        let (s1, s2) = S.split2 s 
     44        in Prelude.showParen (p Prelude.> prec) $ 
     45            unS lhs s1 (Prelude.succ prec) . 
     46            Prelude.showString name . 
     47            unS rhs s2 (Prelude.succ prec) 
     48        ) 
     49    infixopr name prec _ lhs rhs = S(\s p -> 
     50        let (s1, s2) = S.split2 s 
     51        in Prelude.showParen (p Prelude.> prec) $ 
     52            unS lhs s1 (Prelude.succ prec) . 
     53            Prelude.showString name . 
     54            unS rhs s2 prec 
     55        ) 
Note: See TracChangeset for help on using the changeset viewer.