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. cascade of if statements (Emmanuel Touzery)
3. Re: cascade of if statements (Emmanuel Touzery)
----------------------------------------------------------------------
Message: 1
Date: Tue, 30 Oct 2012 18:54:31 +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 09:33, Chadda? Fouch? escreveu:
> There is some good explanations of that phenomenon around under the
> name "Butterfly effect" like :
> http://cdsmith.wordpress.com/2011/01/17/the-butterfly-effect-in-cabal/
>
> This is really painful when you start to have accumulated a number of
> packages, and the more dependencies, the more likely you are to hit
> this...
> Which is why most people now recommend using sandboxes for
> installations, to allows you to have several different packages
> database and not have to scratch your whole GHC installation once
> you've damaged it (there are always alternative to this radical step,
> but it takes more time than restarting from zero so nobody use them).
> Basically, as soon as you hit a problem with a cabal installation that
> would require a reinstall, you restart from a new sandbox. The
> solutions to do that are virthualenv, capri or cabal-dev and the next
> release of cabal itself should have a sandbox mode.
>
> The proper solution would be to allow several version of the same
> package version to cohabit but that's pretty complicated and not yet
> possible.
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...
miguelnegrao@Mac-Miguel:~$ cabal install cabal-dev
Resolving dependencies...
[1 of 1] Compiling Main (
/var/folders/ps/fvzyp6yj5k743k1clpmt24kw0000gn/T/cabal-dev-0.9.1-11243/cabal-dev-0.9.1/Setup.hs,
/var/folders/ps/fvzyp6yj5k743k1clpmt24kw0000gn/T/cabal-dev-0.9.1-11243/cabal-dev-0.9.1/dist/setup/Main.o
)
Linking
/var/folders/ps/fvzyp6yj5k743k1clpmt24kw0000gn/T/cabal-dev-0.9.1-11243/cabal-dev-0.9.1/dist/setup/setup
...
ld: warning: could not create compact unwind for _ffi_call_unix64: does not use
RBP or RSP based frame
unrecognized option `--disable-benchmarks'
Failed to install cabal-dev-0.9.1
cabal: Error: some packages failed to install:
cabal-dev-0.9.1 failed during the configure step. The exception was:
ExitFailure 1
miguelnegrao@Mac-Miguel:~$ cabal -V
cabal-install version 1.16.0.1
using version 1.16.0.2 of the Cabal library
Is this a lost cause ? :-)
best,
Miguel
------------------------------
Message: 2
Date: Wed, 31 Oct 2012 11:25:05 +0100
From: Emmanuel Touzery <[email protected]>
Subject: [Haskell-beginners] cascade of if statements
To: [email protected]
Message-ID:
<CAC42RekvnS1nirSdqqu0KzPTZdsBeF8EXKDL2De=bn3mb63...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hello,
I am wondering if this code can be made a bit nicer?
I am checking if a file exists... and then if it exists I'm checking
whether it's older than two hours from now. It is a bit annoying to have
that second block in the else (i could make a second function but i think
it all belongs in this function).
This structure makes me think about the Maybe monad, where it would
automatically exit after it would find out that the file doesn't exists,
instead of having a cascade of if statements inside one another.
But this function is already in the IO monad (maybe I'm thinking about
this in the wrong way though).
Any idea for an improvement?
-- don't re-fetch if I fetched in the last 2 hours
needToFetchAgain :: FilePath -> IO Bool
needToFetchAgain export_filename = do
exists <- doesFileExist export_filename
if (not exists)
then return False
else do
modif <- getModificationTime export_filename
curTime <- getClockTime
let diff = diffClockTimes curTime modif
return $ tdSec diff >= (3600*2) -- 2 hours
Thank you!
Emmanuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20121031/fc1fd3e8/attachment-0001.htm>
------------------------------
Message: 3
Date: Wed, 31 Oct 2012 11:27:34 +0100
From: Emmanuel Touzery <[email protected]>
Subject: Re: [Haskell-beginners] cascade of if statements
To: [email protected]
Message-ID:
<cac42ren84x44yojmbf40b_mr0+ag0ay1+crwy-yqlcfhaz_...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
hmm otherwise the return False must be a return True, stupid bug:
-- don't re-fetch if I fetched in the last 2 hours
needToFetchAgain :: FilePath -> IO Bool
needToFetchAgain export_filename = do
exists <- doesFileExist export_filename
if (not exists)
then return True
else do
modif <- getModificationTime export_filename
curTime <- getClockTime
let diff = diffClockTimes curTime modif
return $ tdSec diff >= (3600*2) -- 2 hours
On Wed, Oct 31, 2012 at 11:25 AM, Emmanuel Touzery <[email protected]>wrote:
> Hello,
>
> I am wondering if this code can be made a bit nicer?
>
> I am checking if a file exists... and then if it exists I'm checking
> whether it's older than two hours from now. It is a bit annoying to have
> that second block in the else (i could make a second function but i think
> it all belongs in this function).
>
> This structure makes me think about the Maybe monad, where it would
> automatically exit after it would find out that the file doesn't exists,
> instead of having a cascade of if statements inside one another.
>
> But this function is already in the IO monad (maybe I'm thinking about
> this in the wrong way though).
>
> Any idea for an improvement?
>
> -- don't re-fetch if I fetched in the last 2 hours
> needToFetchAgain :: FilePath -> IO Bool
> needToFetchAgain export_filename = do
> exists <- doesFileExist export_filename
> if (not exists)
> then return False
> else do
> modif <- getModificationTime export_filename
> curTime <- getClockTime
> let diff = diffClockTimes curTime modif
> return $ tdSec diff >= (3600*2) -- 2 hours
>
> Thank you!
>
> Emmanuel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20121031/3fa25d56/attachment-0001.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 52, Issue 34
*****************************************