[Haskell-cafe] Double-dispatch

Clark Gaebel cgaebel at csclub.uwaterloo.ca
Mon Mar 5 22:04:17 CET 2012

Is there any way in Haskell to have the correct function selected
based on the types of two different types? For example, let's say I'm
writing intersection tests:

aABBandAABB :: AABB -> AABB -> Bool
oBBandOBB :: OBB -> OBB -> Bool
oBBandPoint :: OBB -> Point -> Bool

Is there some way (such as with Type Families) that I can write some
sort of generic method for this:

intersects :: Intersectable -> Intersectable -> Bool

which automatically selects the right function to call based on the
types of the two intersectables?

  - clark

More information about the Haskell-Cafe mailing list