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:  Installing packages (Tymur Porkuian)
   2. Re:  Installing packages (Krzysztof Skrz?tnicki)
   3.  cabal-install can't connect (Kirk Martinez)
   4.  Re: [Haskell-cafe] Just how unsafe is unsafe (Edsko de Vries)
   5. Re:  cabal-install can't connect (Salvatore Insalaco)
   6.  Re: Appending to a list (Heinrich Apfelmus)


----------------------------------------------------------------------

Message: 1
Date: Mon, 9 Feb 2009 01:21:18 +0200
From: Tymur Porkuian <[email protected]>
Subject: Re: [Haskell-beginners] Installing packages
To: Krzysztof Skrz?tnicki <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

>>>> I'm trying to install wxcore-0.11.0 using Cabal. I've downloaded it
>>>> from
>>>> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/wxcore-0.11.0,
>>>> unpacked and tried to follow instructions from
>>>> http://haskell.org/haskellwiki/Cabal/How_to_install_a_Cabal_package,
>>>> but this is what I'm getting:
>>>>
>>>> D:\libraries\wxcore-0.11.0>runhaskell Setup configure
>>>> Setup: sh: runGenProcess: does not exist (No such file or directory)
>>>>
>>>> What does this mean?
>>>
>>> On Windows it usually means that the package has a "configure" shell script
>>> and therefore requires that Cygwin or MSYS be installed.
>>
>> I have installed Cygwin, and still getting the exact same error.
>> Should something else be done after installing it?
>
> Are you running "cabal install" from within Cygwin prompt?

No, I'm not running "cabal install", I'm running "runhaskell Setup
configure" (as written in
http://haskell.org/haskellwiki/Cabal/How_to_install_a_Cabal_package).
"cabal" is not even on the PATH, actually. Now I launched this command
from cygwin, this is what I got:

.../cygdrive/d/libraries/wxcore-0.11.0
$ runhaskell.exe Setup configure
warning:
 Unable to find wxWidgets configuration (wx-config).

checking system:
error:
 Unable to find the 'wx-config' program: wx-config
 Maybe you forgot to run 'make install' on wxWidgets?
 Otherwise, add the install directory of wx-config to your path.

 Or maybe you are trying to compile with Microsoft Visual C++?
 If so, you can specify that on the command line:
 For example: ./configure --with-msc

What is wx-config and where can I get it?


------------------------------

Message: 2
Date: Mon, 9 Feb 2009 00:27:19 +0100
From: Krzysztof Skrz?tnicki <[email protected]>
Subject: Re: [Haskell-beginners] Installing packages
To: [email protected]
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=UTF-8

On Mon, Feb 9, 2009 at 00:21, Tymur Porkuian <[email protected]> wrote:
>>
>> Are you running "cabal install" from within Cygwin prompt?
>
> No, I'm not running "cabal install", I'm running "runhaskell Setup
> configure" (as written in
> http://haskell.org/haskellwiki/Cabal/How_to_install_a_Cabal_package).
> "cabal" is not even on the PATH, actually. Now I launched this command
> from cygwin, this is what I got:
>
> .../cygdrive/d/libraries/wxcore-0.11.0
> $ runhaskell.exe Setup configure
> warning:
>  Unable to find wxWidgets configuration (wx-config).
>
> checking system:
> error:
>  Unable to find the 'wx-config' program: wx-config
>  Maybe you forgot to run 'make install' on wxWidgets?
>  Otherwise, add the install directory of wx-config to your path.
>
>  Or maybe you are trying to compile with Microsoft Visual C++?
>  If so, you can specify that on the command line:
>  For example: ./configure --with-msc
>
> What is wx-config and where can I get it?
>

You need wxWidgets sources: get them at
http://www.wxwidgets.org/downloads/#latest_stable .
After that you need to install them appropriately, so that wx-config
will be in PATH.

All best

Christopher Skrzętnicki


------------------------------

Message: 3
Date: Fri, 6 Feb 2009 10:25:06 -0800
From: Kirk Martinez <[email protected]>
Subject: [Haskell-beginners] cabal-install can't connect
To: "'[email protected]'" <[email protected]>
Message-ID:
        
<aaa7e9adec517141984ab6a6d594eff143198c4...@sj-itmsg02.altera.priv.altera.com>
        
Content-Type: text/plain; charset="us-ascii"

I'm trying to use cabal-install through the firewall at my work and I am 
consistently denied:

C:\>cabal update -v3
Downloading package list from server
'http://hackage.haskell.org/packages/archive'
Sending:
GET http://hackage.haskell.org/packages/archive/00-index.tar.gz HTTP/1.1
User-Agent: cabal-install/0.6.0
Creating new connection to hackage.haskell.org
cabal: connect: failed (Connection refused (WSAECONNREFUSED))

I built cabal-install 0.6.0 and compiled with ghc 6.10.1 without a hitch.  I 
set my http_proxy variable the same as other apps I use which are able to 
connect to other sites via http.  I even patched cabal-install according to 
these 
instructions<http://www.nabble.com/cabal-install-sends-invalid-proxy-password-td20976277.html>,
 but I still get this same "Connection refused".  Seems it's not even getting 
to the proxy.  This is on Windows XP SP2.

Any help or suggestions would be greatly appreciated!  Installing package 
dependencies by hand is something I thought I left behind in the 90's...

Thanks,
Kirk Martinez

________________________________
Confidentiality Notice.
This message may contain information that is confidential or otherwise 
protected from disclosure. If you are not the intended recipient, you are 
hereby notified that any use, disclosure, dissemination, distribution, or 
copying of this message, or any attachments, is strictly prohibited. If you 
have received this message in error, please advise the sender by reply e-mail, 
and delete the message and any attachments. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20090206/4ef47dcb/attachment-0001.htm

------------------------------

Message: 4
Date: Fri, 6 Feb 2009 09:53:52 +0000
From: Edsko de Vries <[email protected]>
Subject: [Haskell-beginners] Re: [Haskell-cafe] Just how unsafe is
        unsafe
To: Jake McArthur <[email protected]>
Cc: Beginners Haskell <[email protected]>,  Haskell Cafe
        <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Hi,

> My opinion is that unsafeXXX is acceptable only when its use is
> preserved behind an abstraction that is referentially transparent and
> type safe. Others may be able to help refine this statement.

I would agree with this. The problem is that impurity spreads easily.
For example, suppose we have this truly random number generator,
'random'. As soon as we have this, then *almost every* function is
potentially impure:

f :: Integer -> Integer
f x = random + x

g :: [Integer]
g = repeat random

etc. etc. The compiler has no way of tracking impurity other than
through the type system which is, of course, exactly what monads do. 

To echo the sentiment above, the only safe way to use unsafePerformIO is
to hide it behind a function that *is* guaranteed to be pure (i.e.,
returns the same values for the same arguments, can be inlined, etc.).
And even then, I would recommend against it.  Let me give a *practical*
reason why. 

For a long time, I would never even have considered unsafePerformIO, but
I recently had an application that needed unique global identifiers in
lots of places, and I was reluctant to pass state around everywhere;
*but* I could hide it in a few functions, which were themselves pure. It
looked something like:

-- Replace (some) name by a number
quote :: Integer -> Term -> Term

-- Replace a number by (that) name
unquote :: Name -> Term -> Term

-- Typical usage
foo t == let l = getUnsafeUniqueGlobalIdentifier () in
         unquote l . do some stuff . quote l

Since "unquote l . quote l" is an identity operation, 'foo' itself is
pure -- provided that nothing in 'do some stuff' relies on the exact
identity of the identifier. 

--- A rule which I broke at some point, got some very strange behaviour,
and took me ages to debug. This was mostly due to laziness, which made
the point of execution of the unsafe operation to be very difficult to
predict. 

For example, every call to getUnsafeUniqueGlobalIdentifier (it wasn't
actually called that, don't worry :-) yielded a number one higher than
the previous. However, in a list of terms [t1, t2, .., tn] all of which
include some unique idnetifier, it is *not* the generation of the list
that determines whether the identifiers in these terms are incrementing,
but the *evaluation* of the list -- when are the terms forced to normal
form. I was called 'sort' on this list, and sort depended on the values
of these identifiers -- but since sort evaluated the terms in the list
to normal form in a hard to predict order, the order of the list was
anything but sorted! 

--- Moreover, you need all sorts of compiler options or nasty hacks (the
unit argument to getUnsafeUniqueGlobalIdentifier above is no mistake) to
avoid the compiler optimizing your code in ways that you did not expect.

In the end, I ended up rewriting the entire application to avoid the use
of this global unique identifiers, because it was simply too difficult
to get right. I felt I was writing C code again and was chasing bugs due
to dangling pointers and the wrong memory being used. Not a time I want
to return to!

Moral of the story: unless you really really need to and really really
know what you are doing -- do not use unsafePerformIO. Uncontrolled side
effects and lazines will cause extremely hard to track behaviour in your
program, and things are almost guaranteed to go wrong. 

Edsko


------------------------------

Message: 5
Date: Mon, 9 Feb 2009 07:59:25 +0100
From: Salvatore Insalaco <[email protected]>
Subject: Re: [Haskell-beginners] cabal-install can't connect
To: Kirk Martinez <[email protected]>
Cc: "[email protected]" <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

On Fri, Feb 6, 2009 at 7:25 PM, Kirk Martinez <[email protected]> wrote:
> I'm trying to use cabal-install through the firewall at my work and I am
> consistently denied:

In my experience, cabal-install ignores the http_proxy variable on
Windows, and uses the Internet Explorer proxy registry key.
Another problem could be that your proxy is using NTLM authentication,
that cabal doesn't support.

To solve this problem, if your proxy supports BASIC authentication,
just put the proxy informations in the Internet Explorer proxy dialog;
you have to do it even if there's the "automatic proxy configuration"
setting, as cabal is unable to use it.

If your proxy supports NTLM authentication, just download a package
like http://www.geocities.com/rozmanov/ntlm/ and then put its host and
port as proxy in Internet Explorer.

Salvatore


------------------------------

Message: 6
Date: Mon, 09 Feb 2009 11:36:51 +0100
From: Heinrich Apfelmus <[email protected]>
Subject: [Haskell-beginners] Re: Appending to a list
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Francesco Bochicchio wrote:
> Heinrich Apfelmus wrote:
>> 
>> No,  reverse  has nothing to do with laziness and still costs O(n)
>> time. It's just that building the list in linear time and then
>> reversing it in linear time is cheaper than building the list in
>> quadratic time.
> 
> I see. Thanks for the information. I keep thinking to haskell lists
> as they are 'generators', but this is not always the case ... and I
> realize now that there is no way to reverse the list without
> expanding it first.

Well, they are 'generators' from an operational point of view, in that
elements are generated on demand. But other than that, they are just a tree

     :
    / \
   1   :
      / \
     2   :
        / \
       3  ...

>> Now, let's reformulate it so that the result won't be built in
>> reverse. The key is to eliminate the unnecessary accumulating
>> parameter and work with the result of the recursive call to  groups
>> directly:
>> 
>>    groups p xs = let (g,rest) = span p xs in
>>        case rest of
>>            r:est -> let (gs,seps) = groups p est in (g:gs,r:seps)
>>            []    -> ([g], [])
>> 
>> I'd say that this is the canonical implementation.
> 
> The reason I used accumulators is that I try to teach myself to
> always write tail-recursive functions. I have been bitten by stack
> exhaustion in one of my first exercises (working on large amount of
> data), so I thought that non tail-recursive functions should be
> always avoided. But using accumulators often leads to appending to
> lists, so one has to find the balance between the two things...

Due to lazy evaluation, something that looks tail recursive is not
necessarily tail recursive at all; I strongly advise to unlearn your
habit. For example, the version of  groups  that uses an accumulator is
less efficient that the one without.

In general, a lazy approach to performance is best: just use the
simplest possible implementation and postpone performance considerations
to when the program actually takes ages to compute the result.


Concerning stack exhaustion and large amounts of data, there is one very
common pattern worth knowing, namely foldr vs. foldl' , see also

  http://en.wikibooks.org/wiki/Haskell/Performance_Introduction#Space
  http://book.realworldhaskell.org/read/functional-programming.html

Other than that, there is no way around understanding Haskell's
evaluation model properly.


Regards,
apfelmus

-- 
http://apfelmus.nfshost.com



------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 8, Issue 7
***************************************

Reply via email to