On Fri, Jun 5, 2015 at 5:41 AM, Keean Schupke <ke...@fry-it.com> wrote: > > On 5 June 2015 at 10:19, Matt Oliveri <atma...@gmail.com> wrote: >> >> I don't know which Haskell feature you're talking about, but if >> RightTriangle were a refinement of Triangle, then it'd be a subtype, >> so you could call "area", which takes a Triangle, with a >> RightTriangle. So you can associate rightness with the type _and_ get >> code reuse. >> >> What's more interesting is scaling, which works for any triangle, but >> also preserves rightness. (And so do rotation and translation.) These >> would have the intersection of two types: >> [other stuff]->Triangle->Triangle >> and >> [other stuff]->RightTriangle->RightTriangle >> > > Except I would never do it like that, and I don't like intersection types. > > I would define a type-class for points, a type class for polygons, and I > would constrain the functions accordingly, using further type classes. So a > RightTriangle is a set of constraints on a poly of points. The functions are > written using the type-class functions. It works the same in C++, and the > type level calculations are easier in C++.
That's fine, Keean. I was saying how you could do it with refinement types. You don't have to do it that way if you don't like it. _______________________________________________ bitc-dev mailing list bitc-dev@coyotos.org http://www.coyotos.org/mailman/listinfo/bitc-dev