Mercurial > urweb
comparison src/explify.sml @ 162:06a98129b23f
Add datatype import constructor annotations; datatypes through explify
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 29 Jul 2008 12:30:04 -0400 |
parents | 34ccd7d2bea8 |
children | c7a6e6dbc318 |
comparison
equal
deleted
inserted
replaced
161:a5ae7b3e37a4 | 162:06a98129b23f |
---|---|
93 | 93 |
94 fun explifySgi (sgi, loc) = | 94 fun explifySgi (sgi, loc) = |
95 case sgi of | 95 case sgi of |
96 L.SgiConAbs (x, n, k) => SOME (L'.SgiConAbs (x, n, explifyKind k), loc) | 96 L.SgiConAbs (x, n, k) => SOME (L'.SgiConAbs (x, n, explifyKind k), loc) |
97 | L.SgiCon (x, n, k, c) => SOME (L'.SgiCon (x, n, explifyKind k, explifyCon c), loc) | 97 | L.SgiCon (x, n, k, c) => SOME (L'.SgiCon (x, n, explifyKind k, explifyCon c), loc) |
98 | L.SgiDatatype _ => raise Fail "Explify SgiDatatype" | 98 | L.SgiDatatype (x, n, xncs) => SOME (L'.SgiDatatype (x, n, map (fn (x, n, co) => |
99 | L.SgiDatatypeImp _ => raise Fail "Explify SgiDatatypeImp" | 99 (x, n, Option.map explifyCon co)) xncs), loc) |
100 | L.SgiDatatypeImp (x, n, m1, ms, s, xncs) => | |
101 SOME (L'.SgiDatatypeImp (x, n, m1, ms, s, map (fn (x, n, co) => | |
102 (x, n, Option.map explifyCon co)) xncs), loc) | |
100 | L.SgiVal (x, n, c) => SOME (L'.SgiVal (x, n, explifyCon c), loc) | 103 | L.SgiVal (x, n, c) => SOME (L'.SgiVal (x, n, explifyCon c), loc) |
101 | L.SgiStr (x, n, sgn) => SOME (L'.SgiStr (x, n, explifySgn sgn), loc) | 104 | L.SgiStr (x, n, sgn) => SOME (L'.SgiStr (x, n, explifySgn sgn), loc) |
102 | L.SgiSgn (x, n, sgn) => SOME (L'.SgiSgn (x, n, explifySgn sgn), loc) | 105 | L.SgiSgn (x, n, sgn) => SOME (L'.SgiSgn (x, n, explifySgn sgn), loc) |
103 | L.SgiConstraint _ => NONE | 106 | L.SgiConstraint _ => NONE |
104 | 107 |
112 | L.SgnError => raise Fail ("explifySgn: SgnError at " ^ EM.spanToString loc) | 115 | L.SgnError => raise Fail ("explifySgn: SgnError at " ^ EM.spanToString loc) |
113 | 116 |
114 fun explifyDecl (d, loc : EM.span) = | 117 fun explifyDecl (d, loc : EM.span) = |
115 case d of | 118 case d of |
116 L.DCon (x, n, k, c) => SOME (L'.DCon (x, n, explifyKind k, explifyCon c), loc) | 119 L.DCon (x, n, k, c) => SOME (L'.DCon (x, n, explifyKind k, explifyCon c), loc) |
117 | L.DDatatype _ => raise Fail "Explify DDatatype" | 120 | L.DDatatype (x, n, xncs) => SOME (L'.DDatatype (x, n, map (fn (x, n, co) => |
118 | L.DDatatypeImp _ => raise Fail "Explify DDatatypeImp" | 121 (x, n, Option.map explifyCon co)) xncs), loc) |
122 | L.DDatatypeImp (x, n, m1, ms, s, xncs) => | |
123 SOME (L'.DDatatypeImp (x, n, m1, ms, s, map (fn (x, n, co) => | |
124 (x, n, Option.map explifyCon co)) xncs), loc) | |
119 | L.DVal (x, n, t, e) => SOME (L'.DVal (x, n, explifyCon t, explifyExp e), loc) | 125 | L.DVal (x, n, t, e) => SOME (L'.DVal (x, n, explifyCon t, explifyExp e), loc) |
120 | L.DValRec vis => SOME (L'.DValRec (map (fn (x, n, t, e) => (x, n, explifyCon t, explifyExp e)) vis), loc) | 126 | L.DValRec vis => SOME (L'.DValRec (map (fn (x, n, t, e) => (x, n, explifyCon t, explifyExp e)) vis), loc) |
121 | 127 |
122 | L.DSgn (x, n, sgn) => SOME (L'.DSgn (x, n, explifySgn sgn), loc) | 128 | L.DSgn (x, n, sgn) => SOME (L'.DSgn (x, n, explifySgn sgn), loc) |
123 | L.DStr (x, n, sgn, str) => SOME (L'.DStr (x, n, explifySgn sgn, explifyStr str), loc) | 129 | L.DStr (x, n, sgn, str) => SOME (L'.DStr (x, n, explifySgn sgn, explifyStr str), loc) |