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

new files

File:
1 edited

Legend:

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

    r24 r27  
    44import Ops 
    55import Data.Supply as S 
     6import Data.Lens.Light 
    67 
    78class LOps l => Exp l where 
     
    2122    cond c tbranch fbranch = if unQ c then tbranch else fbranch 
    2223    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 
     25instance 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) 
    2830            (s3, s4, s5) = S.split3 ss 
    2931            v1           = S.supplyValue s4 
    30             showV1       = S $ \_ _ -> showVar v1 
     32            showV1       = S $ \_ -> showVar v1 
    3133            v2           = S.supplyValue s5 
    32             showV2       = S $ \_ _ -> showVar v2 
     34            showV2       = S $ \_ -> showVar v2 
     35            p = getL prec ctx 
    3336        in showParen (p>0) $  
    3437            showString "case ". 
    35             unS list s1 0 . 
     38            unS list (updateCtx s1 0 ctx) . 
    3639            showString " of [] => ". 
    37             unS nbranch s2 0 . 
     40            unS nbranch (updateCtx s2 0 ctx) . 
    3841            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 
    4246        in showParen (p>0) $  
    4347            showString "if ". 
    44             unS c s1 0 . 
     48            unS c (updateCtx s1 0 ctx). 
    4549            showString " then " . 
    46             unS tbranch s2 0 . 
     50            unS tbranch (updateCtx s2 0 ctx). 
    4751            showString " else " . 
    48             unS fbranch s3 0 
     52            unS fbranch (updateCtx s3 0 ctx) 
Note: See TracChangeset for help on using the changeset viewer.