Changeset 27 for sizechecking/branches/macs/Exp.hs
- Timestamp:
- May 5, 2014, 3:10:33 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sizechecking/branches/macs/Exp.hs
r24 r27 4 4 import Ops 5 5 import Data.Supply as S 6 import Data.Lens.Light 6 7 7 8 class LOps l => Exp l where … … 21 22 cond c tbranch fbranch = if unQ c then tbranch else fbranch 22 23 undefined = Prelude.undefined 23 instance Exp S where 24 nil = S $ \_ _ -> showString "[]" 25 undefined = S $ \_ _ -> showString "undefined" 26 match list nbranch cbranch = S $ \s p -> 27 let (s1, s2, ss) = S.split3 s 24 25 instance SContext s => Exp (S s) where 26 nil = S $ \_ -> showString "[]" 27 undefined = S $ \_ -> showString "undefined" 28 match list nbranch cbranch = S $ \ctx -> 29 let (s1, s2, ss) = S.split3 (getL supply ctx) 28 30 (s3, s4, s5) = S.split3 ss 29 31 v1 = S.supplyValue s4 30 showV1 = S $ \_ _-> showVar v132 showV1 = S $ \_ -> showVar v1 31 33 v2 = S.supplyValue s5 32 showV2 = S $ \_ _ -> showVar v2 34 showV2 = S $ \_ -> showVar v2 35 p = getL prec ctx 33 36 in showParen (p>0) $ 34 37 showString "case ". 35 unS list s1 0.38 unS list (updateCtx s1 0 ctx) . 36 39 showString " of [] => ". 37 unS nbranch s2 0.40 unS nbranch (updateCtx s2 0 ctx) . 38 41 showString "; (" . showVar v1 . showChar ':' . showVar v2 . showString ") => " . 39 unS (cbranch showV1 showV2) s3 0 40 cond c tbranch fbranch = S $ \s p -> 41 let (s1, s2, s3) = S.split3 s 42 unS (cbranch showV1 showV2) (updateCtx s3 0 ctx) 43 cond c tbranch fbranch = S $ \ctx -> 44 let (s1, s2, s3) = S.split3 (getL supply ctx) 45 p = getL prec ctx 42 46 in showParen (p>0) $ 43 47 showString "if ". 44 unS c s1 0.48 unS c (updateCtx s1 0 ctx). 45 49 showString " then " . 46 unS tbranch s2 0.50 unS tbranch (updateCtx s2 0 ctx). 47 51 showString " else " . 48 unS fbranch s3 052 unS fbranch (updateCtx s3 0 ctx)
Note: See TracChangeset
for help on using the changeset viewer.