On Mon, Nov 15, 2010 at 6:43 PM, Ling Yang <[email protected]> wrote: > ... > One alternate way of doing this, however, is instancing the > typeclasses of the ordinary values with their monadic versions: > > instance (Num a) => Num (Prob a) where > (+) = liftM2 (+) > (*) = liftM2 (*) > abs = liftM abs > signum = liftM signum > fromInteger = return . fromInteger > > instance (Fractional a) => Fractional (Prob a) where > fromRational = return . fromRational > (/) = liftM2 (/)
You may also like to look at Conal Elliott's applicative-numbers package: http://hackage.haskell.org/package/applicative-numbers Bas _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
