On Wed, Feb 4, 2009 at 1:09 PM, Manlio Perillo <manlio_peri...@libero.it> wrote: > In Haskell, something like > > (/) :: (Num a, Real b) => a -> a -> b
You probably want (Real a, Fractional b) => a -> a -> b. Int is an instance of Real... Real is the class of types that can be converted to Rational. Then we can define (/.) :: (Real a1, Real a2, Fractional a) => a1 -> a2 -> a x /. y = fromRational $ toRational x / toRational y whose type is more general than the one I gave above, but we can restrict it to that by changing the signature, if you like. > (//) :: (Num a, Integral b) => a -> a -> b Again, Num is inappropriate, but we can define something similar: (//) :: (Integral b, Real a, Real a1) => a -> a1 -> b x // y = floor $ toRational x / toRational y Hope that helps, Max _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe