moduleData.Number.Natural(Natural)wheredataNatural=Z|SNaturalinstanceShowNaturalwhereshowsPrecpn=showsPrecp(toIntegern)instanceEqNaturalwherex==y=x`compare`y==EQinstanceOrdNaturalwhereZ`compare`Z=EQZ`compare`S_=LTS_`compare`Z=GTSx`compare`Sy=x`compare`yinstanceNumNaturalwhereZ+y=ySx+y=S(x+y)x-Z=xZ-S_=error"Natural: (-)"Sx-Sy=x-yZ*y=ZSx*y=y+x*yabsx=xsignumZ=Zsignum(S_)=SZfromIntegerx|x<0=error"Natural: fromInteger"fromInteger0=ZfromIntegerx=S(fromInteger(x-1))instanceIntegralNaturalwhere-- Not the most efficient version, but efficiency isn't the point of this module. :)quotRemxy=ifx<ythen(0,x)elselet(q,r)=quotRem(x-y)yin(q+1,r)div=quotmod=remtoIntegerZ=0toInteger(Sx)=1+toIntegerxinstanceRealNaturalwheretoRational=toRational.toIntegerinstanceEnumNaturalwheretoEnum=fromIntegralfromEnum=fromIntegral