
16 Jun
2006
16 Jun
'06
3:44 p.m.
Thank you. I followed your suggestion and implemented my default Divide as you've shown below. oleg@pobox.com wrote:
If we assume that we need Reciprocate only if we are going to use the 'default' method, the solution becomes obvious. It does involve overlapping and undecidable instances, sorry. These extensions are really useful in practice. Here's the solution:
class Divide a b c | a b -> c where (/) :: a -> b -> c
Here's the most general instance. It applies when nothing more specific does. It is in this case that we insist on being able to take the reciprocal:
instance (Reciprocate b recip, Multiply a recip c) => Divide a b c where (/) x y = x * (recip y)
6915
Age (days ago)
6915
Last active (days ago)
0 comments
1 participants
participants (1)
-
Jeff.Harper@handheld.com