On 6 Jun 2015 11:46, "Matt Oliveri" <[email protected]> wrote:
> What you still haven't told me is whether "a" from your examples is
> itself a type. If so, what are its elements? If not, how can you apply
> a type class to it? Without this information, you cannot expect me to
> make much sense of this. Maybe it'd help if you actually showed me the
> definition of Triangle.
class Point2D container unit where
x_coord :: container -> unit
y_coord :: container -> unit
instance Point2D (Vector Float) Float where
x_coord c = c[0]
y_coord c = c[1]
class Triangle container point where
point1 :: container -> point
point2 :: container -> point
point3 :: container -> point
instance Triangle Point2D where
point1 p = p[0]
point2 p = p[1]
point3 p = p[2]
We don't care what the generic container is used to hold the points, nor do
we care about how many dimensions the points have.
class RightTriangle container unit where ...
So RightTriangle is a predicate that is true if the type is a right
triangle.
So the point is functions like scale:
scale :: Polygon a unit => unit -> a -> a
a is a type constrained by the type-classes, that's all we ever need to
know about it.
>
> >> What you describe sounds like the intersection of functions on int
> >> with functions on float. This does not tell us what the intersection
> >> of int and float is. There are multiple subtype orders that are
> >> sensible. I was thinking of int and float as unrelated, so their
> >> intersection is empty.
> >
> > Consider:
> >
> > f : Int /\ Float -> String
>
> Consider it considered. What's the point? Do you still deny that (Int
> /\ Float) can be defined as empty?
Int /\ Float can be either type but you may not be able to do any
operations on it. You still have to propagate it through functions like
'id'. So this type is definitely inhabited.
Keean.
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev