Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: best way to proceed with package install (Miguel Negrao)
2. Re: cascade of if statements (Rustom Mody)
----------------------------------------------------------------------
Message: 1
Date: Fri, 2 Nov 2012 11:49:10 +0000
From: Miguel Negrao <[email protected]>
Subject: Re: [Haskell-beginners] best way to proceed with package
install
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252
A 30/10/2012, ?s 18:54, Miguel Negrao escreveu:
> After reading that post and a couple others I tried to install cabal-dev
> which is supposed to help with some of these issues. Ironically it doesn?t
> install either...
Ok, I think that was because I was using ghc 7.0.4, I updated to 7.4 (haskell
platform latest version) and also first uninstalled the haskell platform and
nuked ~/.ghc and ~/.cabal and started over (but now using jobs:8 in
~/.cabal/config after having updated to cabal-install-1.16.0.1 ) and quickly
got up to date. cabal-dev also installed fine. Let?s hope I get an easier ride
from now on. :-)
best,
Miguel
------------------------------
Message: 2
Date: Sat, 3 Nov 2012 14:07:21 +0530
From: Rustom Mody <[email protected]>
Subject: Re: [Haskell-beginners] cascade of if statements
To: beginners <[email protected]>
Message-ID:
<CAJ+TeofcBzx7X3hGkMx=j9xan6hu2jxqknogqkfkjsdqkup...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
On Wed, Oct 31, 2012 at 10:44 PM, Daniel Trstenjak <
[email protected]> wrote:
>
> (<||>) :: Monad m => m Bool -> m Bool -> m Bool
> (<||>) m1 m2 = do
> r1 <- m1
> if r1 then return True else m2
>
>
We can do some algebraic simplification, using the law
*if P then True else Q *is same as *P || Q* :
(<||>) m1 m2 = do
r1 <- m1
r2 <- m2
return (r1 || r2)
Which reminds me of the definition of liftM2
(from Control.Monad):
liftM2 f m1 m2 = do { x1 <- m1; x2 <- m2; return (f x1 x2) }
And so we can golf down to:
(<||>) = liftM2 (||)
Now, instead of using liftM2 from Control.Monad, I could as well use liftA2
from Control.Applicative :
(<||>) = liftA2 (||)
So my questions to the experts:
1> Are these equivalent or am I missing something?
2> Any thumb rules on when to use Control.Monad and when to use
Control.Applicative?
Rusi
--
http://blog.languager.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20121103/4890848c/attachment-0001.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 53, Issue 3
****************************************