Addition on Peano numbers at type level

235 Views Asked by At

I have defined types for the Peano numbers

class Plus (n :: T) (m :: T) (r :: T) | r n -> m
instance Plus 'Zero m m
instance Plus n m r => Plus ('Succ n) m ('Succ r)

Now I find myself having two constraints Plus a b c and Plus c d e.

How can I define an addition operation on my class such that the compiler is able to derive Plus a (b + d) e?

0

There are 0 best solutions below