Changeset 23 for sizechecking/branches/macs/Ops.hs
- Timestamp:
- May 3, 2014, 5:01:55 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sizechecking/branches/macs/Ops.hs
r21 r23 10 10 class (Lambda l) => LOps l where 11 11 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 12 14 fun :: String -> a -> l a 13 15 14 16 (+) :: l Int -> l Int -> l Int 15 (+) = infixop "+" 4(Prelude.+)17 (+) = infixopl "+" 6 (Prelude.+) 16 18 17 19 (-) :: l Int -> l Int -> l Int 18 (-) = infixop "-" 4(Prelude.-)20 (-) = infixopl "-" 6 (Prelude.-) 19 21 20 22 (*) :: l Int -> l Int -> l Int 21 (*) = infixop "*" 5(Prelude.*)23 (*) = infixopl "*" 7 (Prelude.*) 22 24 23 25 24 26 instance 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) 26 30 fun _ = Q 27 31 … … 29 33 fun name _ = S (\_ p -> Prelude.showsPrec p name) 30 34 31 infixop name prec _ lhs rhs = S(\s p ->35 infixopl name prec _ lhs rhs = S(\s p -> 32 36 let (s1, s2) = S.split2 s 33 37 in Prelude.showParen (p Prelude.> prec) $ … … 36 40 unS rhs s2 (Prelude.succ prec) 37 41 ) 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.