%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Dynamic semantics %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % The definitions in this file do *not* strictly correspond to any specific % code in GHC. They are here to provide a reasonable operational semantic % interpretation to the typing rules presented in the other ott files. Thus, % your mileage may vary. In particular, there has been *no* attempt to % write any formal proofs over these semantics. % % With that disclaimer disclaimed, these rules are a reasonable jumping-off % point for an analysis of FC's operational semantics. If you don't want to % worry about mutual recursion (and who does?), you can even drop the % environment S. grammar defns OpSem :: '' ::= defn S |- e --> e' :: :: step :: 'S_' {{ com Single step semantics }} {{ tex \begin{array}{l} [[S]] \labeledjudge{op} [[e]] [[-->]] [[e']] \end{array} }} by S(n) = e ----------------- :: Var S |- n --> e S |- e1 --> e1' ------------------- :: App S |- e1 e2 --> e1' e2 ----------------------------- :: Beta S |- (\n.e1) e2 --> e1[n |-> e2] g0 = sym (nth 0 g) g1 = nth 1 g not e2 is_a_type not e2 is_a_coercion ----------------------------------------------- :: Push S |- ((\n.e1) |> g) e2 --> (\n.e1 |> g1) (e2 |> g0) ---------------------------------------- :: TPush S |- ((\n.e) |> g) t --> (\n.(e |> g n)) t g0 = nth 1 (nth 0 g) g1 = sym (nth 2 (nth 0 g)) g2 = nth 1 g ------------------------------- :: CPush S |- ((\n.e) |> g) g' --> (\n.e |> g2) (g0 ; g' ; g1) --------------------------------------- :: Trans S |- (e |> g1) |> g2 --> e |> (g1 ; g2) S |- e --> e' ------------------------ :: Cast S |- e |> g --> e' |> g S |- e --> e' ------------------------------ :: Tick S |- e { tick } --> e' { tick } S |- e --> e' --------------------------------------- :: Case S |- case e as n return t of --> case e' as n return t of altj = K -> u u' = u[n |-> e] sbb] // bb /> ecc] // cc /> -------------------------------------------------------------- :: MatchData S |- case K as n return t of --> u' altj = lit -> u ---------------------------------------------------------------- :: MatchLit S |- case lit as n return t of --> u[n |-> lit] altj = _ -> u no other case matches ------------------------------------------------------------ :: MatchDefault S |- case e as n return t of --> u[n |-> e] T ~#k T = coercionKind g forall . forall . @-> T = dataConRepType K (t1cc @ nth aa g] // aa /> _Nom] // bb />) // cc /> --------------------------- :: CasePush S |- case (K ) |> g as n return t2 of --> \\ case K as n return t2 of ----------------- :: LetNonRec S |- let n = e1 in e2 --> e2[n |-> e1] S, ei] // i /> |- u --> u' ------------------------------------ :: LetRec S |- let rec in u --> let rec in u' --------------- :: LetRecApp S |- (let rec in u) e' --> let rec in (u e') ---------------- :: LetRecCast S |- (let rec in u) |> g --> let rec in (u |> g) --------------- :: LetRecCase S |- case (let rec in u) as n0 return t of --> \\ let rec in (case u as n0 return t of ) --------------- :: LetRecFlat S |- let rec in (let rec in u) --> let rec ;; in u fv(u) \inter = empty --------------------------------- :: LetRecReturn S |- let rec in u --> u