comparison src/core_util.sml @ 188:8e9f97508f0d

Datatype representation optimization
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 Aug 2008 19:49:21 -0400
parents d11754ffe252
children 9bbf4d383381
comparison
equal deleted inserted replaced
187:fb6ed259f5bd 188:8e9f97508f0d
27 27
28 structure CoreUtil :> CORE_UTIL = struct 28 structure CoreUtil :> CORE_UTIL = struct
29 29
30 open Core 30 open Core
31 31
32 fun classifyDatatype xncs =
33 if List.all (fn (_, _, NONE) => true | _ => false) xncs then
34 Enum
35 else
36 Default
37
32 structure S = Search 38 structure S = Search
33 39
34 structure Kind = struct 40 structure Kind = struct
35 41
36 fun mapfold f = 42 fun mapfold f =
225 and mfe' ctx (eAll as (e, loc)) = 231 and mfe' ctx (eAll as (e, loc)) =
226 case e of 232 case e of
227 EPrim _ => S.return2 eAll 233 EPrim _ => S.return2 eAll
228 | ERel _ => S.return2 eAll 234 | ERel _ => S.return2 eAll
229 | ENamed _ => S.return2 eAll 235 | ENamed _ => S.return2 eAll
230 | ECon (_, NONE) => S.return2 eAll 236 | ECon (_, _, NONE) => S.return2 eAll
231 | ECon (n, SOME e) => 237 | ECon (dk, n, SOME e) =>
232 S.map2 (mfe ctx e, 238 S.map2 (mfe ctx e,
233 fn e' => 239 fn e' =>
234 (ECon (n, SOME e'), loc)) 240 (ECon (dk, n, SOME e'), loc))
235 | EFfi _ => S.return2 eAll 241 | EFfi _ => S.return2 eAll
236 | EFfiApp (m, x, es) => 242 | EFfiApp (m, x, es) =>
237 S.map2 (ListUtil.mapfold (fn e => mfe ctx e) es, 243 S.map2 (ListUtil.mapfold (fn e => mfe ctx e) es,
238 fn es' => 244 fn es' =>
239 (EFfiApp (m, x, es'), loc)) 245 (EFfiApp (m, x, es'), loc))