comparison src/monoize.sml @ 1734:d2b3fada532e

Fix generation of normal datatypes from polymorphic variants
author Adam Chlipala <adam@chlipala.net>
date Sun, 29 Apr 2012 20:37:45 -0400
parents 02533f681ad2
children f9e5a8e09cdf
comparison
equal deleted inserted replaced
1733:ab24a7cb2a64 1734:d2b3fada532e
67 case RM.find (!pvars, r') of 67 case RM.find (!pvars, r') of
68 NONE => 68 NONE =>
69 let 69 let
70 val n = choosePvar () 70 val n = choosePvar ()
71 val fs = map (fn (x, t) => (x, choosePvar (), t)) r' 71 val fs = map (fn (x, t) => (x, choosePvar (), t)) r'
72 val r = ListMergeSort.sort (fn (((L.CName x, _), _), ((L.CName y, _), _)) => String.compare (x, y) = GREATER
73 | _ => raise Fail "Monoize: pvar, not CName") r
72 val (r, fs') = ListPair.foldr (fn ((_, t), (x, n, _), (r, fs')) => 74 val (r, fs') = ListPair.foldr (fn ((_, t), (x, n, _), (r, fs')) =>
73 ((x, n, SOME t) :: r, 75 ((x, n, SOME t) :: r,
74 SM.insert (fs', x, n))) ([], SM.empty) (r, fs) 76 SM.insert (fs', x, n))) ([], SM.empty) (r, fs)
75 in 77 in
76 pvars := RM.insert (!pvars, r', (n, fs)); 78 pvars := RM.insert (!pvars, r', (n, fs));