diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-06-03 14:32:01 +0200 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-06-03 14:32:01 +0200 |
commit | e1609eb67ec130790a34bfcbabe02c279aa08dda (patch) | |
tree | 73f02adc9f8413e34ee10ccb729107d998f3dae3 /prototypes | |
parent | e2bd6c4f6a2a5fb3969692ea7ac6d9ef9a66ee7c (diff) |
support variable name preference in pretty print
Diffstat (limited to 'prototypes')
-rw-r--r-- | prototypes/LamMachine.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/prototypes/LamMachine.hs b/prototypes/LamMachine.hs index 0a80ea2c..1cdbd20b 100644 --- a/prototypes/LamMachine.hs +++ b/prototypes/LamMachine.hs | |||
@@ -306,9 +306,9 @@ instance ViewShow Exp where | |||
306 | pShow e@(Exp_ fv x) = showFE green vi fv $ | 306 | pShow e@(Exp_ fv x) = showFE green vi fv $ |
307 | case {-if vi then Exp_ (selfContract fv) x else-} e of | 307 | case {-if vi then Exp_ (selfContract fv) x else-} e of |
308 | Var (Nat i) -> DVar i | 308 | Var (Nat i) -> DVar i |
309 | Let a b -> shLet (pShow a) $ pShow b | 309 | Let a b -> shLet "" (pShow a) $ pShow b |
310 | Seq a b -> DOp "`seq`" (Infix 1) (pShow a) (pShow b) | 310 | Seq a b -> DOp "`seq`" (Infix 1) (pShow a) (pShow b) |
311 | Lam e -> shLam $ pShow e | 311 | Lam e -> shLam "" $ pShow e |
312 | Con s i xs -> foldl DApp (text s) $ pShow <$> xs | 312 | Con s i xs -> foldl DApp (text s) $ pShow <$> xs |
313 | Int i -> pShow' i | 313 | Int i -> pShow' i |
314 | Y e -> "Y" `DApp` pShow e | 314 | Y e -> "Y" `DApp` pShow e |
@@ -341,16 +341,16 @@ instance ViewShow MSt where | |||
341 | 341 | ||
342 | g y DEnvNil = y | 342 | g y DEnvNil = y |
343 | g y z@(DEnvCons p env) = flip g env $ {-showFE red vi (case p of EnvPiece f _ -> f) $-} case p of | 343 | g y z@(DEnvCons p env) = flip g env $ {-showFE red vi (case p of EnvPiece f _ -> f) $-} case p of |
344 | EDLet1 x -> shLet y (h x) | 344 | EDLet1 x -> shLet "" y (h x) |
345 | ELet x -> shLet (pShow x) y | 345 | ELet x -> shLet "" (pShow x) y |
346 | ECase cns xs -> shCase cns y (pShow <$> xs) | 346 | ECase cns xs -> shCase cns y (pShow <$> xs) |
347 | EOp2_1 op x -> shOp2 op y (pShow x) | 347 | EOp2_1 op x -> shOp2 op y (pShow x) |
348 | EOp2_2 op x -> shOp2 op (pShow x) y | 348 | EOp2_2 op x -> shOp2 op (pShow x) y |
349 | 349 | ||
350 | h DExpNil = onred $ white "*" --TODO? | 350 | h DExpNil = onred $ white "*" --TODO? |
351 | h z@(DExpCons p (h -> y)) = showFE blue vi (case p of EnvPiece f _ -> f) $ case p of | 351 | h z@(DExpCons p (h -> y)) = showFE blue vi (case p of EnvPiece f _ -> f) $ case p of |
352 | EDLet1 x -> shLet y (h x) | 352 | EDLet1 x -> shLet "" y (h x) |
353 | ELet x -> shLet (pShow x) y | 353 | ELet x -> shLet "" (pShow x) y |
354 | ECase cns xs -> shCase cns y (pShow <$> xs) | 354 | ECase cns xs -> shCase cns y (pShow <$> xs) |
355 | EOp2_1 op x -> shOp2 op y (pShow x) | 355 | EOp2_1 op x -> shOp2 op y (pShow x) |
356 | EOp2_2 op x -> shOp2 op (pShow x) y | 356 | EOp2_2 op x -> shOp2 op (pShow x) y |
@@ -361,13 +361,13 @@ instance PShow MSt where pShow = viewShow False | |||
361 | shUps a b = DPreOp (-20) (SimpleAtom $ show a) b | 361 | shUps a b = DPreOp (-20) (SimpleAtom $ show a) b |
362 | shUps' a x b = DPreOp (-20) (SimpleAtom $ show a ++ show x) b | 362 | shUps' a x b = DPreOp (-20) (SimpleAtom $ show a ++ show x) b |
363 | 363 | ||
364 | shLam b = DFreshName True $ showLam (DVar 0) b | 364 | shLam n b = DFreshName (Just n) $ showLam (DVar 0) b |
365 | 365 | ||
366 | showLam x (DFreshName u d) = DFreshName u $ showLam (DUp 0 x) d | 366 | showLam x (DFreshName u d) = DFreshName u $ showLam (DUp 0 x) d |
367 | showLam x (DLam xs y) = DLam (DSep (InfixR 11) x xs) y | 367 | showLam x (DLam xs y) = DLam (DSep (InfixR 11) x xs) y |
368 | showLam x y = DLam x y | 368 | showLam x y = DLam x y |
369 | 369 | ||
370 | shLet a b = DFreshName True $ showLet (DLet "=" (shVar 0) $ DUp 0 a) b | 370 | shLet n a b = DFreshName (Just n) $ showLet (DLet "=" (shVar 0) $ DUp 0 a) b |
371 | 371 | ||
372 | showLet x (DFreshName u d) = DFreshName u $ showLet (DUp 0 x) d | 372 | showLet x (DFreshName u d) = DFreshName u $ showLet (DUp 0 x) d |
373 | showLet x (DLet' xs y) = DLet' (DSemi x xs) y | 373 | showLet x (DLet' xs y) = DLet' (DSemi x xs) y |