From 5c38ded1a699a06da954610323574af284fe2738 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 27 Aug 2009 13:46:35 +0200 Subject: [PATCH] Update normal form example. --- Chapters/Normalization.tex | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/Chapters/Normalization.tex b/Chapters/Normalization.tex index a8194de..2acd1c8 100644 --- a/Chapters/Normalization.tex +++ b/Chapters/Normalization.tex @@ -62,27 +62,35 @@ An example of a program in canonical form would be: \startlambda -- All arguments are an inital lambda - λx.λc.λd. - -- There is one let expression at the top level + λa.λd.λsp. + -- There are nested let expressions at top level let + -- Unpack the state by coercion + s = sp :: (Word, Word) + -- Extract both registers from the state + r1 = case s of (fst, snd) -> fst + r2 = case s of (fst, snd) -> snd -- Calling some other user-defined function. - s = foo x - -- Extracting result values from a tuple - a = case s of (a, b) -> a - b = case s of (a, b) -> b - -- Some builtin expressions - rh = add c d - rhh = sub d c + d' = foo d -- Conditional connections - rl = case b of - High -> rhh + out = case a of + High -> r1 + Low -> r2 + r1' = case a of + High -> d + Low -> r1 + r2' = case a of + High -> r2 Low -> d - r = case a of - High -> rh - Low -> rl + -- Packing a tuple + s' = (,) r1' r2' + -- Packing the state by coercion + sp' = s' :: State (Word, Word) + -- Pack our return value + res = (,) sp' out in -- The actual result - r + res \stoplambda When looking at such a program from a hardware perspective, the top level -- 2.30.2