comparison src/explify.sml @ 45:3c1ce1b4eb3d

Explifying functors
author Adam Chlipala <adamc@hcoop.net>
date Thu, 19 Jun 2008 17:11:24 -0400
parents a9f3ce2d1b9b
children 0a5c312de09a
comparison
equal deleted inserted replaced
44:a9f3ce2d1b9b 45:3c1ce1b4eb3d
90 90
91 and explifySgn (sgn, loc) = 91 and explifySgn (sgn, loc) =
92 case sgn of 92 case sgn of
93 L.SgnConst sgis => (L'.SgnConst (map explifySgi sgis), loc) 93 L.SgnConst sgis => (L'.SgnConst (map explifySgi sgis), loc)
94 | L.SgnVar n => (L'.SgnVar n, loc) 94 | L.SgnVar n => (L'.SgnVar n, loc)
95 | L.SgnFun _ => raise Fail "Explify functor signature" 95 | L.SgnFun (m, n, dom, ran) => (L'.SgnFun (m, n, explifySgn dom, explifySgn ran), loc)
96 | L.SgnWhere _ => raise Fail "Explify where" 96 | L.SgnWhere (sgn, x, c) => (L'.SgnWhere (explifySgn sgn, x, explifyCon c), loc)
97 | L.SgnError => raise Fail ("explifySgn: SgnError at " ^ EM.spanToString loc) 97 | L.SgnError => raise Fail ("explifySgn: SgnError at " ^ EM.spanToString loc)
98 98
99 fun explifyDecl (d, loc : EM.span) = 99 fun explifyDecl (d, loc : EM.span) =
100 case d of 100 case d of
101 L.DCon (x, n, k, c) => (L'.DCon (x, n, explifyKind k, explifyCon c), loc) 101 L.DCon (x, n, k, c) => (L'.DCon (x, n, explifyKind k, explifyCon c), loc)
107 and explifyStr (str, loc) = 107 and explifyStr (str, loc) =
108 case str of 108 case str of
109 L.StrConst ds => (L'.StrConst (map explifyDecl ds), loc) 109 L.StrConst ds => (L'.StrConst (map explifyDecl ds), loc)
110 | L.StrVar n => (L'.StrVar n, loc) 110 | L.StrVar n => (L'.StrVar n, loc)
111 | L.StrProj (str, s) => (L'.StrProj (explifyStr str, s), loc) 111 | L.StrProj (str, s) => (L'.StrProj (explifyStr str, s), loc)
112 | L.StrFun _ => raise Fail "Explify functor" 112 | L.StrFun (m, n, dom, ran, str) => (L'.StrFun (m, n, explifySgn dom, explifySgn ran, explifyStr str), loc)
113 | L.StrApp _ => raise Fail "Explify functor app" 113 | L.StrApp (str1, str2) => (L'.StrApp (explifyStr str1, explifyStr str2), loc)
114 | L.StrError => raise Fail ("explifyStr: StrError at " ^ EM.spanToString loc) 114 | L.StrError => raise Fail ("explifyStr: StrError at " ^ EM.spanToString loc)
115 115
116 val explify = map explifyDecl 116 val explify = map explifyDecl
117 117
118 end 118 end