# Making monadic code more concise

11 messages
Open this post in threaded view
|

## Making monadic code more concise

Open this post in threaded view
|

## Re: Making monadic code more concise

Open this post in threaded view
|

## Re: Making monadic code more concise

Open this post in threaded view
|

## Re: Making monadic code more concise

Open this post in threaded view
|

## Re: Making monadic code more concise

 In reply to this post by Ling Yang On Mon, Nov 15, 2010 at 6:43 PM, Ling Yang <[hidden email]> 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-numbersBas _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe
Open this post in threaded view
|

## Re: Making monadic code more concise

Open this post in threaded view
|

## Re: Making monadic code more concise

Open this post in threaded view
|

## Re: Making monadic code more concise

Open this post in threaded view
|

## Re: Making monadic code more concise

 On Nov 16, 2010, at 12:36 PM, Ling Yang wrote: >  Are only > 'trivial' results possible, or that the incomputability problems are   > just moved > into type space? That's typically the case, under Rice's theorem. A construct is derivable if it works for all cases (i.e., it's a "free   theorem"), or if it works for none.  If it works for some, you need to   encode the differences between the cases yourself. _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe