comparison src/cjr_env.sml @ 165:e52dfb1e6b19

Datatypes through cjrize, modulo decoding
author Adam Chlipala <adamc@hcoop.net>
date Tue, 29 Jul 2008 13:50:53 -0400
parents 78d59cf0a0cc
children a991431b77eb
comparison
equal deleted inserted replaced
164:6847741e1f5f 165:e52dfb1e6b19
116 NONE => raise UnboundStruct n 116 NONE => raise UnboundStruct n
117 | SOME x => x 117 | SOME x => x
118 118
119 fun declBinds env (d, loc) = 119 fun declBinds env (d, loc) =
120 case d of 120 case d of
121 DVal (x, n, t, _) => pushENamed env x n t 121 DDatatype (x, n, xncs) =>
122 let
123 val env = pushTNamed env x n NONE
124 in
125 foldl (fn ((x', n', NONE), env) => pushENamed env x' n' (TNamed n, loc)
126 | ((x', n', SOME t), env) => pushENamed env x' n' (TFun (t, (TNamed n, loc)), loc))
127 env xncs
128 end
129 | DStruct (n, xts) => pushStruct env n xts
130 | DVal (x, n, t, _) => pushENamed env x n t
122 | DFun (fx, n, args, ran, _) => 131 | DFun (fx, n, args, ran, _) =>
123 let 132 let
124 val t = foldl (fn ((_, arg), t) => (TFun (arg, t), loc)) ran args 133 val t = foldl (fn ((_, arg), t) => (TFun (arg, t), loc)) ran args
125 in 134 in
126 pushENamed env fx n t 135 pushENamed env fx n t
130 let 139 let
131 val t = foldl (fn ((_, arg), t) => (TFun (arg, t), loc)) ran args 140 val t = foldl (fn ((_, arg), t) => (TFun (arg, t), loc)) ran args
132 in 141 in
133 pushENamed env fx n t 142 pushENamed env fx n t
134 end) env vis 143 end) env vis
135 | DStruct (n, xts) => pushStruct env n xts 144
136 145
137 end 146 end