Mercurial > meta
comparison variant.ur @ 29:7530b2b54353
Update for Ur/Web's new type class handling
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 29 Jul 2012 12:27:36 -0400 |
parents | f55f66c6fdee |
children |
comparison
equal
deleted
inserted
replaced
28:f55f66c6fdee | 29:7530b2b54353 |
---|---|
135 (fn [nm::_] [v::_] [r::_] [[nm] ~ r] | 135 (fn [nm::_] [v::_] [r::_] [[nm] ~ r] |
136 (k : mkLabelsAccum r) | 136 (k : mkLabelsAccum r) |
137 [s::_] [[nm = v] ++ r ~ s] => k [[nm = v] ++ s] ++ {nm = make [nm]}) | 137 [s::_] [[nm = v] ++ r ~ s] => k [[nm = v] ++ s] ++ {nm = make [nm]}) |
138 (fn [s::_] [[] ~ s] => {}) fl [[]] ! | 138 (fn [s::_] [[] ~ s] => {}) fl [[]] ! |
139 | 139 |
140 class type_case = fn ts t a => (a -> variant ts) -> a -> t | 140 con type_case ts t a = (a -> variant ts) -> a -> t |
141 | 141 |
142 fun declareCase [ts] [t] [a] (f : (a -> variant ts) -> a -> t) : type_case ts t a = f | 142 fun declareCase [ts] [t] [a] (f : (a -> variant ts) -> a -> t) : type_case ts t a = f |
143 fun typeCase [ts] [t] (v : variant ts) (dstrs : $(map (type_case ts t) ts)) (fl : folder ts) : t | 143 fun typeCase [ts] [t] (v : variant ts) (dstrs : $(map (type_case ts t) ts)) (fl : folder ts) : t |
144 (* Ur/Web not clever enough to calculate these folders, it seems *) | 144 (* Ur/Web not clever enough to calculate these folders, it seems *) |
145 = match v (@Record.ap [fn a => a -> variant ts] [fn a => a -> t] fl dstrs (@mkLabels fl)) | 145 = match v (@Record.ap [fn a => a -> variant ts] [fn a => a -> t] fl dstrs (@mkLabels fl)) |