On 5 June 2015 at 10:19, Matt Oliveri <[email protected]> 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++. Keean.
_______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
