Monoid instances by rolf

o="Monoid";e="mempty";a="`mappend`"
f=lambda m:"("+[", ",","][m>0].join([[o+" %c"%j,"%c"%j,e,"%c1"%j,"%c2"%j,"%c1 %s %c2"%(j,a,j)][m]for j in range(97,99+n)])+")"
for n in range(25):print"instance",f(0),"=>",o,f(1),"where\n   ",e,"=",f(2)+"\n   ",f(3),a,f(4),"=",f(5)+"\n"

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top