[Haskell-cafe] Bit streams

2008-06-18 Thread Andrew Coppin
OK, so today I tried to write my first program using the Binary library. 
And I've hit a snag: It appears the library will only handle data that 
is byte-aligned. So if I try to write three Bool values, it uses three 
bytes, not three bits.


Before I sit down and spend 3 months designing my own library from 
scratch, does anybody know of an existing library that allows you to do 
what Binary does, but with single-bit precision? [I presume Binary is 
byte-aligned for efficiency...]


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell's type system

2008-06-18 Thread Don Stewart
ronwalf:
 I'm trying to wrap my head around the theoretical aspects of haskell's
 type system. Is there a discussion of the topic separate from the
 language itself?
 
 Since I come from a rather logic-y background, I have this
 (far-fetched) hope that there is a translation from haskell's type
 syntax to first order logic (or an extension there-of).  Is this done?
  Doable?

A quick link to get you started on the topic, I'm sure others will add
more material.

Haskell's type system is based on System F, the polymorphic lambda
calculus. By the Curry-Howard isomorphism, this corresponds to
second-order logic.

The GHC compiler itself implements Haskell and extensions by encoding
them in System Fc internally, which extends System F with support for
non-syntactic type equality..  JHC, I believe, encodes Haskell into a
pure type system internally, some sort of higher order dependently-typed
polymorphic lambda calculus.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Jonathan Cast
On Tue, 2008-06-17 at 18:45 +0200, Karoly Negyesi wrote:
 Hi,
 
 The PHP community is discussing the adding of closures and lambdas to
 the language, see the proposal at http://wiki.php.net/rfc/closures
 
 If someone with knowledge of both languages could take a quick look it
 would be great.

I program in Perl for a living, so hopefully you'll understand when I
say

(a) I would *never* want to use an implementation of closures like that.
(b) Closures as proposed are *far* better than not having closures.

jcc


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: Mueval 0.3

2008-06-18 Thread Gwern Branwen
Hiya everyone. So I've uploaded Mueval 0.3 (release early, release often) 
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mueval-0.3.

What's new? Well, I changed the printing output to be cleaner, and I made 
printing the inferred type optional (through a --print-type flag). In addition, 
I've made sure it can run (for me, at least) under -N4, and the watchdog 
threads should be sturdier. (Plus extra tests.)

However, I've been hearing that a number of people (3 at last count) have been 
having a lot of trouble with the ResourceLimits stuff.

So, I have a few requests of people who install mueval:
* First, does it work out of the box, with no tweaking of the resource limits?
* Second, if it doesn't work out of the box, which resource limits did you need 
to disable or increase?
* Thirdly, if you changed the resource limits, could you run ./build.sh and 
tell me whether all the tests pass?

Finally, I've been pondering removing the rlimits entirely since they are both 
very unportable, empirically derived, and apparently don't even work 
consistently on Linux. Any thoughts?

--
gwern
PABX MEMEX 868 1* TSCI @ shelter Yukon el ASLET


signature.asc
Description: Digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] blas bindings, why are they so much slower the C?

2008-06-18 Thread Anatoly Yakovenko
here is the C:

#include cblas.h
#include stdlib.h

int main() {
   int size = 1024;
   int ii = 0;
   double* v1 = malloc(sizeof(double) * (size));
   double* v2 = malloc(sizeof(double) * (size));
   for(ii = 0; ii  size*size; ++ii) {
  double _dd = cblas_ddot(0, v1, size, v2, size);
   }
   free(v1);
   free(v2);
}

this is the haskell:

module Main where

import Data.Vector.Dense.IO

main = do
   let size = 1024
   v1::IOVector Int Double - newListVector size [0..]
   v2::IOVector Int Double - newListVector size [0..]
   mapM_ (\ ii - do v1 `getDot` v2) [0..size*size]

time ./testdot

real0m0.017s
user0m0.010s
sys 0m0.010s

time ./htestdot

real0m4.692s
user0m4.670s
sys 0m0.030s

so like 250x difference

htestdot.prof is no help

   Tue Jun 17 20:46 2008 Time and Allocation Profiling Report  (Final)

  htestdot +RTS -p -RTS

   total time  =3.92 secs   (196 ticks @ 20 ms)
   total alloc = 419,653,032 bytes  (excludes profiling overheads)

COST CENTREMODULE   %time %alloc

main   Main  88.3   83.0
CAFMain  11.7   17.0



individualinherited
COST CENTRE  MODULE
   no.entries  %time %alloc   %time %alloc

MAIN MAIN
 1   0   0.00.0   100.0  100.0
 CAF Main
   216   7  11.7   17.0   100.0  100.0
  main   Main
   222   1  88.3   83.088.3   83.0
 CAF GHC.Float
   187   1   0.00.0 0.00.0
 CAF GHC.Handle
   168   3   0.00.0 0.00.0
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Karoly Negyesi
  (a) I would *never* want to use an implementation of closures like that.
  (b) Closures as proposed are *far* better than not having closures.

Could you elaborate on a) ?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell's type system

2008-06-18 Thread Luke Palmer
On Tue, Jun 17, 2008 at 2:40 PM, Ron Alford [EMAIL PROTECTED] wrote:
 I'm trying to wrap my head around the theoretical aspects of haskell's
 type system. Is there a discussion of the topic separate from the
 language itself?

 Since I come from a rather logic-y background, I have this
 (far-fetched) hope that there is a translation from haskell's type
 syntax to first order logic (or an extension there-of).  Is this done?
  Doable?

Sort of, via the Curry-Howard Correspondence.  Haskell's type system
corresponds to a constructive logic (no law of excluded middle).
Arbitrary quantifiers are also introduced via the RankNTypes (I think
that's what it's called) extension.

Haskell's type system is a straightforward polymorphic type system for
the lambda calculus, so researching the Curry-Howard Correspondence
will probably get you what you want.

Luke
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Richard A. O'Keefe

I believe C# already has lambdas, and Java is supposed to be getting
them.  PHP is playing catchup, is all.  (Oh, and Eiffel has 'agents',
and I think I saw something about C++ Next Degeneration, and ...)
Heck, the idea has only been around in computing since the 1950s...


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Something like scan1

2008-06-18 Thread Achim Schneider
Is there a generalisation of scan1, such that eg.

foo (+) [0,1] (1,2) = [0,1,1,2,3,5,8,13,...]

?

I came up with it while thinking about the equivalence of laziness and
strictness resp. pull and push.

To be more specific, I was thinking about ArrowLoop and how that beast
generalises over time-varying values. It's some kind of helixoid fixed
point (which might not help at all if your visualisation is
incompatible with mine).


-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Jonathan Cast
On Wed, 2008-06-18 at 06:36 +0200, Karoly Negyesi wrote:
   (a) I would *never* want to use an implementation of closures like that.
   (b) Closures as proposed are *far* better than not having closures.
 
 Could you elaborate on a) ?

I dislike the habit of implicit declaration --- strongly --- and the
consequent need for the lexical keyword (although at this point PHP's
stuck with it).  I can see myself forgetting to use lexical far more
often than accidentally leaving off a `my' in Perl I should have used (I
hardly ever shadow variable names anyway, so if I forget `my' is usually
a use strict 'vars' error).

I dislike curly braces.  Syntax that extends as far to the right as
possible tends to end up with fewer delimiters and a cleaner appearance.
It's basically a way to replace a bunch of closing braces with a
single ) or (in Haskell, implicit) ;

lintPat p0 $ \ ty0 - lintPat p1 $ \ ty1 - lint e

vs

lintPat($p0, sub { my ($ty0) = @_; lintPat($p1, sub { my ($ty1) = @_;
lint($e) })})

Four closing delimiters seems excessive.

Nit: `function' is verbose.  ML uses fun or fn (I forget which and am
too lazy to google).  Perl's regular keyword is sub, so they use that.

There are worse fates than duck typing (C++ comes to mind :), and given
a language with neither lexical closures/anonymous functions nor HM
typing, I'd complain about the lack of lambdas first.  But, still, no HM
means no type classes.  That ultimately becomes limiting.  (I still
haven't seen a decent implementation of monads in a dynamically typed
language).  But PHP is probably pretty much stuck with it.

Not to criticize, mind you --- the proposal looks excellent for what it
does.  But I like what Haskell does worlds better.

jcc


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Compiling large code with old machine

2008-06-18 Thread Dominic Steinitz
Samuel Silva silva.samuel at gmail.com writes:

 
 Hello
 
 I'm using GHC to compile around 700K of Haskell Code generated by HaXml.
 How I compile this code.
 My machine is Windows-XP(512MB RAM, 1.5GHz) running GHC-6.8.2.
 

Samuel,

You may not want to take this approach. I'm assuming you are generating 
haskell types from a (large) DTD. I went this way (admittedly quite a few 
years ago) for svg. In the end it was much easier to hand generate a few 
combinators to produced the svg. I don't know what your application is but it 
may worth thinking about an alternative to 700k loc.

Dominic.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Bit Streams

2008-06-18 Thread Dominic Steinitz
OK, so today I tried to write my first program using the Binary library. 
And I've hit a snag: It appears the library will only handle data that 
is byte-aligned. So if I try to write three Bool values, it uses three 
bytes, not three bits.

Before I sit down and spend 3 months designing my own library from 
scratch, does anybody know of an existing library that allows you to do 
what Binary does, but with single-bit precision? [I presume Binary is 
byte-aligned for efficiency...]

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Karoly Negyesi
  Not to criticize, mind you --- the proposal looks excellent for what it
  does.  But I like what Haskell does worlds better.

Obviously you like Haskell better given this mailing list :) I am not
here to compare PHP and Haskell, I was just asking advice from people
who know closures and lambdas very well and it seems that I got it in
the words of the proposal looks excellent for what it does.

Thanks a lot.

Karoly Negyesi
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Jules Bean

PR Stanley wrote:
With respect, do you not think it'd be wiser for the community 


[snip]

*disgusted*

This is exactly the sort of message that haskell-cafe does not normally 
contain. Let's not start now.


This is a civilized mailing list. Either comment on the nice gentlemen's 
PHP closure proposal from a language point of view, or don't say anything.


Jules
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell's type system

2008-06-18 Thread Edsko de Vries
On Tue, Jun 17, 2008 at 04:40:51PM -0400, Ron Alford wrote:
 I'm trying to wrap my head around the theoretical aspects of haskell's
 type system. Is there a discussion of the topic separate from the
 language itself?
 
 Since I come from a rather logic-y background, I have this
 (far-fetched) hope that there is a translation from haskell's type
 syntax to first order logic (or an extension there-of).  Is this done?
  Doable?

I'll give you some terms to Google for.

The ideal type system for Haskell (ignoring type classes) is System F.
Haskell'98 doesn't quite get there, but recent extensions such as boxy
types and FPH do. System F corresponds to second order propositional
logic: types correspond to propositions in this logic, and Haskell
programs as the corresponding proofs (by the Curry-Howard isomorphism).

The type system of Haskell'98 is a bit weird from a logical perspective,
and sort of corresponds to the rank 1.5 predicative fragment of second
order propositional logic (I say rank 1.5 because although no
abstraction over rank 1 types is allowed normally, limited abstractions
over rank 1 types is allowed through let-polymorphism -- so this is
*almost* first order logic but not quite: slightly more powerful). 

Regarding type classes, I'm not 100% what the logical equivalent is,
although one can regard a type such as

  forall a. Eq a = a - a

as requiring a proof (evidence) that equality on a is decidable. Where
this sits formally as a logic I'm not sure though.

Edsko
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread PR Stanley



With respect, do you not think it'd be wiser for the community


[snip]

*disgusted*

This is exactly the sort of message that haskell-cafe does not 
normally contain. Let's not start now.


This is a civilized mailing list. Either comment on the nice 
gentlemen's PHP closure proposal from a language point of view, or 
don't say anything.
Paul: Uncivilised you say. Well, I would have thought the civilised 
thing would be to share your concerns discretely with the list 
moderator. Instead you've chosen to make a public show of it.
The Chinese have a saying, and I paraphrase - when you point the 
finger of accusation at someone/something you have three pointing 
back at yourself.


Paul

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANNOUNCE: cabal-install 0.5

2008-06-18 Thread Duncan Coutts
cabal-install 0.5
=

cabal-install version 0.5 is out:
http://haskell.org/cabal/download.html

or get it from hackage:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/cabal-install

If you are already using a cabal-install pre-release then you can just:
$ cabal update
$ cabal install cabal-install

New features in cabal-install
=

Command line improvements
-

The most immediately noticeable thing is that the command line interface
now has all the commands that runhaskell Setup.hs has. Of course it
still has the features to download and install packages from hackage. It
also gained an upload command. So it now provides a command line
interface to the whole Cabal/Hackage system. There’s no need to use
runhaskell Setup.hs ever again.

There is also bash command line completion support included which I find
is a great time saver.

Installing and upgrading


The next big thing is that it includes a new package dependency
resolution system that finds correct and sensible solutions more of the
time and has better default behaviour. The new behaviour should be
similar to other package managers that people are used to.

For example, suppose you’ve got xmonad-0.5 installed and version 0.7 is
the latest on hackage, then

$ cabal install xmonad

will install xmonad-0.7. The older version, xmonad-0.5, will remain
installed.

The behaviour of install is to upgrade as little as possible to satisfy
your request, but sometimes you want to upgrade all the dependencies
too. Supposing now that we have xmonad-0.7 installed, but we’re still
using X11-1.4.1 and the latest version on hackage is X11-1.4.2, then

$ cabal upgrade xmonad

will install X11-1.4.2 and *re-install* xmonad-0.7, this time built
against the newer X11-1.4.2.

So in general, the install command will install the latest version of
things but will try and use any existing installed versions of
dependencies while the upgrade command will also try to use the latest
versions of all dependencies. As a special case, cabal upgrade on its
own will try to upgrade all the packages that you have installed.

For both command there is a --dry-run flag so you can see what would be
installed without actually doing it.

Hugs


Yes, it even works with hugs. That is, cabal-install built by ghc can
manage the installation of packages for hugs. In principle cabal-install
should be able to be run by hugs but currently the zlib binding is using
a function that hugs does not support.

Note that for hugs, Cabal does not know what packages are already
installed because there is no equivalent of the package database that
ghc has. So that means cabal-install cannot do very sensible
installation planning. It should work ok so long as all the dependencies
are already installed.

Windows
---

Yes, it even works on Windows. The one caveat is that cabal-install
cannot currently upgrade itself because Windows makes it hard for a
process to overwrite its own executable file. It needs more complex
trickery with the Win32 API. In the meantime the workaround is to rename
the cabal.exe file first eg to cabal-foo.exe, then run cabal-foo install
cabal-install.

Build reporting
---

One feature that made it into this release is build reporting.
cabal-install keeps logs of all packages that you install (at least
packages from hackage, not local ones). It records a bit of information
about each package, in particular whether the outcome was successful or
not. You can see these build reports in
~/.cabal/packages/$server/build-reports.log.

For example, there is one from my machine for xmonad:

package: xmonad-0.7
os: linux
arch: x86_64
compiler: ghc-6.8.2
client: cabal-install-0.5.1
flags: -testing small_base
dependencies: X11-1.4.2 base-3.0.1.0 containers-0.1.0.1
  directory-1.0.0.0 mtl-1.1.0.0 process-1.0.0.0
  unix-2.3.0.0
install-outcome: InstallOk
docs-outcome: NotTried
tests-outcome: NotTried

The plan in the longer term is to let people upload these build reports
to hackage so we can get a wider range of testing data about the
packages on hackage.


Duncan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bit streams

2008-06-18 Thread Sebastiaan Visser

On Jun 17, 2008, at 10:05 PM, Andrew Coppin wrote:

OK, so today I tried to write my first program using the Binary  
library. And I've hit a snag: It appears the library will only  
handle data that is byte-aligned. So if I try to write three Bool  
values, it uses three bytes, not three bits.


Before I sit down and spend 3 months designing my own library from  
scratch, does anybody know of an existing library that allows you  
to do what Binary does, but with single-bit precision? [I presume  
Binary is byte-aligned for efficiency...]


Andrew,

Maybe you could look at the generic encode/decode in this paper:
people.cs.uu.nl/johanj/publications/ComparingGP.pdf

When you look at some more literature about generic programming the  
(bit-aligned) encode and decode are quite common examples. It  
shouldn't be that hard to de-generify them, if you even want that.


--
Sebastiaan.




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Problem building GHC 6.8.3

2008-06-18 Thread Daniel Fischer
Sorry, probably stupid questions for knowledgeable folks, but after having 
built for a couple of hours, make died with

if ifBuildable/ifBuildable base; then \
  cd base  setup/Setup haddock --html-location='../$pkg' \
   --hyperlink-source; \
fi
Preprocessing library base-3.0.2.0...
Running hscolour for base-3.0.2.0...
Preprocessing library base-3.0.2.0...
Running Haddock for base-3.0.2.0...
Warning: The documentation for package rts-1.0 is not installed. No links to 
it will be generated.
Setup: Haddock's internal GHC version must match the configured GHC version
make[1]: *** [doc.library.base] Fehler 1
make[1]: Leaving directory `/home/dafis/HasCom/ghc-6.8.3/libraries'
make: *** [stage1] Fehler 2

So, what is Haddock's internal GHC version?
Is it the version, haddock was built with?

And what is the configured GHC version, is it the one I'm trying to build or 
the one I'm building with? 
If the former, I seem to have landed in a circulus vitiosus, if the latter, 
that is the GHC, haddock was built with, too.

For the record:
[EMAIL PROTECTED]:~/HasCom/ghc-6.8.3 haddock --version
Haddock version 2.1.0, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008

How should I proceed now?

Thanks,
Daniel
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bit streams

2008-06-18 Thread Malcolm Wallace
Andrew Coppin [EMAIL PROTECTED] wrote:

 It appears the library will only handle
 data that  is byte-aligned. So if I try to write three Bool values, it
 uses three  bytes, not three bits.

The original Binary library, circa 1998, was based on bit-streams rather
than bytes.  You might be able to dig up a copy and bring it back to
life.

http://citeseer.ist.psu.edu/wallace98bits.html
ftp://ftp.cs.york.ac.uk/pub/malcolm/ismm98.html

Regards,
Malcolm
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell's type system

2008-06-18 Thread Daniel Gorín

On Jun 17, 2008, at 11:08 PM, Don Stewart wrote:


Haskell's type system is based on System F, the polymorphic lambda
calculus. By the Curry-Howard isomorphism, this corresponds to
second-order logic.



just nitpicking a little this should read second-order  
propositional logic, right?


daniel
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Janis Voigtlaender

PR Stanley wrote:



With respect, do you not think it'd be wiser for the community



[snip]

*disgusted*

This is exactly the sort of message that haskell-cafe does not 
normally contain. Let's not start now.


This is a civilized mailing list. Either comment on the nice 
gentlemen's PHP closure proposal from a language point of view, or 
don't say anything.


Paul: Uncivilised you say. Well, I would have thought the civilised 
thing would be to share your concerns discretely with the list 
moderator.


Hmm, I wonder who exactly this list moderator is supposed to be. We
are usually adult enough around here to not need someone to look after
us. I think Jules was well entitled to raise his objections about the
tone of your email in public.


Instead you've chosen to make a public show of it.
The Chinese have a saying, and I paraphrase - when you point the finger 
of accusation at someone/something you have three pointing back at 
yourself.


Well, at least not this finger...

--
Dr. Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Alex Sandro Queiroz e Silva

Hallo,

Jules Bean wrote:

PR Stanley wrote:
With respect, do you not think it'd be wiser for the community 


[snip]

*disgusted*

This is exactly the sort of message that haskell-cafe does not normally 
contain. Let's not start now.


This is a civilized mailing list. Either comment on the nice gentlemen's 
PHP closure proposal from a language point of view, or don't say anything.




 Thanks Jules, I was starting to worry about Haskell-café.

-alex
http://www.ventonegro.org/

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bit streams

2008-06-18 Thread Bulat Ziganshin
Hello Andrew,

Wednesday, June 18, 2008, 12:05:31 AM, you wrote:

 what Binary does, but with single-bit precision? [I presume Binary is

http://haskell.org/haskellwiki/Library/AltBinary

it's not maintained, so consider it as last hope :)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Compiling large code with old machine

2008-06-18 Thread Bulat Ziganshin
Hello Dominic,

Wednesday, June 18, 2008, 11:17:07 AM, you wrote:

 I'm using GHC to compile around 700K of Haskell Code generated by HaXml.
 may worth thinking about an alternative to 700k loc.

i think he means bytes, not lines :)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Bit streams

2008-06-18 Thread Bulat Ziganshin
Hello Malcolm,

Wednesday, June 18, 2008, 4:36:40 PM, you wrote:

 The original Binary library, circa 1998, was based on bit-streams rather
 than bytes.  You might be able to dig up a copy and bring it back to
 life.

 http://citeseer.ist.psu.edu/wallace98bits.html
 ftp://ftp.cs.york.ac.uk/pub/malcolm/ismm98.html

well, i've seen ghc-compatible Binary library flying around which
supported bit fields. it was in pre-hackage days, but it should be
pretty easy to find this module


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread PR Stanley

PR Stanley wrote:

With respect, do you not think it'd be wiser for the community


[snip]

*disgusted*

This is exactly the sort of message that haskell-cafe does not 
normally contain. Let's not start now.


This is a civilized mailing list. Either comment on the nice 
gentlemen's PHP closure proposal from a language point of view, or 
don't say anything.
Paul: Uncivilised you say. Well, I would have thought the civilised 
thing would be to share your concerns discretely with the list moderator.


Hmm, I wonder who exactly this list moderator is supposed to be. We
are usually adult enough around here to not need someone to look after
us. I think Jules was well entitled to raise his objections about the
tone of your email in public.

Paul: As you say, we are adult enougharound here to not need someone 
to look after us. So I don't need you or any other interfearing 
busybody to tell me what I can and can't say on Haskell Cafe. I 
expressed an opinion in a tongue-in-cheek way and at the end of my 
message expressed in clear terms that those were merely my views.
Now, if you, Jules, Alex or some other  wannabe Hitler have a problem 
with my freedom of expression then your best solution is to saddle up 
and get the hell out yourselves. This is the wrong place for setting 
up your tinpot dictatorship, Doctor!
I am grateful for the help I've been getting from the list and my 
understanding of FP has vastly improved since my membership of this 
list but I refuse to tolerate bullies who use the list as a way of 
lifting themselves out of their own shitty lives. Now I am angry!


Instead you've chosen to make a public show of it.
The Chinese have a saying, and I paraphrase - when you point the 
finger of accusation at someone/something you have three pointing 
back at yourself.


Well, at least not this finger...

Paul: you're not making sense.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Janis Voigtlaender

With respect, I will not engage in further communication on that level.

PR Stanley wrote:

PR Stanley wrote:

With respect, do you not think it'd be wiser for the community


[snip]

*disgusted*

This is exactly the sort of message that haskell-cafe does not normally 
contain. Let's not start now.


This is a civilized mailing list. Either comment on the nice gentlemen's 
PHP closure proposal from a language point of view, or don't say anything.
Paul: Uncivilised you say. Well, I would have thought the civilised 
thing would be to share your concerns discretely with the list moderator.


Hmm, I wonder who exactly this list moderator is supposed to be. We
are usually adult enough around here to not need someone to look after
us. I think Jules was well entitled to raise his objections about the
tone of your email in public.

Paul: As you say, we are adult enougharound here to not need someone to 
look after us. So I don't need you or any other interfearing busybody 
to tell me what I can and can't say on Haskell Cafe. I expressed an 
opinion in a tongue-in-cheek way and at the end of my message expressed 
in clear terms that those were merely my views.
Now, if you, Jules, Alex or some other  wannabe Hitler have a problem 
with my freedom of expression then your best solution is to saddle up 
and get the hell out yourselves. This is the wrong place for setting up 
your tinpot dictatorship, Doctor!
I am grateful for the help I've been getting from the list and my 
understanding of FP has vastly improved since my membership of this list 
but I refuse to tolerate bullies who use the list as a way of lifting 
themselves out of their own shitty lives. Now I am angry!


Instead you've chosen to make a public show of it.
The Chinese have a saying, and I paraphrase - when you point the finger 
of accusation at someone/something you have three pointing back at 
yourself.


Well, at least not this finger...

Paul: you're not making sense.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



--
Dr. Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:[EMAIL PROTECTED]


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Luke Palmer
On Wed, Jun 18, 2008 at 1:42 PM, PR Stanley [EMAIL PROTECTED] wrote:
 Now, if you, Jules, Alex or some other  wannabe Hitler have a problem with
 my freedom of expression then your best solution is to saddle up and get the
 hell out yourselves. This is the wrong place for setting up your tinpot
 dictatorship, Doctor!

Just more evidence...

http://en.wikipedia.org/wiki/Godwin's_law

Luke
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread PR Stanley



 Now, if you, Jules, Alex or some other  wannabe Hitler have a problem with
 my freedom of expression then your best solution is to saddle up 
and get the

 hell out yourselves. This is the wrong place for setting up your tinpot
 dictatorship, Doctor!

Just more evidence...

http://en.wikipedia.org/wiki/Godwin's_law

Paul: I think you're missing a big painfully obvious point here, Mr 
smarty pants. No, actually, I think I'll leave it at that. I just 
can't be bothered. However, I'll say this - anyone sticking his 
bloody big hooter into my business in the future will get a similar reaction!

Paul



Luke


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Seth Gordon

PR Stanley wrote:

Blimey! Talk about rearranging the deckchairs :-)


Today's xkcd seems apropos: http://xkcd.com/438/

It seems to me that if a PHP developer sees the Haskell community as a 
resource for advice on programming language implementation, we should 
take this as a compliment to the Haskell community.  Repaying that 
compliment with your language sucks rocks strikes me as unwise.


I'm familiar with a lot of arguments for why PHP is a poorly-designed 
language, and have found them sufficiently persuasive that I haven't 
bothered to learn PHP.  But I don't see any point to repeating those 
arguments on this list.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Something like scan1

2008-06-18 Thread Henning Thielemann


On Wed, 18 Jun 2008, Achim Schneider wrote:


Is there a generalisation of scan1, such that eg.

foo (+) [0,1] (1,2) = [0,1,1,2,3,5,8,13,...]

?


What is the (1,2) for? I could think of


foo f = List.unfoldr (\ xt@(x:xs) - Just (x, xs ++ [f xt]))

foo sum [0,1]  =  [0,1,1,2,3,5,8,13,21,34,...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell data types and Storable class

2008-06-18 Thread Henning Thielemann


On Wed, 18 Jun 2008, Galchin, Vasili wrote:


Hello,

I am reading the FFI spec. Something is unclear to me. Let's assume we
have

data A = {b:B, ...}

   and

data B ={ .}

both of which belong to class Storable. In the A instance of Storable I want
to do a poke and peek of b into and out-of, respectively, B. How do I
write the poke and peek function of b in the instance Storable A?


You will write a Storable instance for B and then just use the class 
methods 'poke' and 'peek' in the instance for A.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread PR Stanley


It seems to me that if a PHP developer sees the Haskell community as 
a resource for advice on programming language implementation, we 
should take this as a compliment to the Haskell community.  Repaying 
that compliment with your language sucks rocks




 strikes me as unwise.

I'm familiar with a lot of arguments for why PHP is a 
poorly-designed language, and have found them sufficiently 
persuasive that I haven't bothered to learn PHP.  But I don't see 
any point to repeating those arguments on this list.


Paul: So, you've never bothered to learn PHP. Well, I happen 
to know the language very well and therefore feel I am in a good 
position to express my views about it. Unlike you, I don't base my 
judgment on rumours and hearsay. It is true that PHP fails to capture 
the spirit of the classical concept of a function. Type checking in 
PHP is equally poor. These are not just my opinions. Are we not to 
say anything critical about a programming language even if it happens 
to be substantively relevant  lestwe should offend someone? God, if 
you want to stick up for your mates here at least come up with  a 
convincing cover.

Paul


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Luke Palmer
On Tue, Jun 17, 2008 at 4:45 PM, Karoly Negyesi [EMAIL PROTECTED] wrote:
 Hi,

 The PHP community is discussing the adding of closures and lambdas to
 the language, see the proposal at http://wiki.php.net/rfc/closures

 If someone with knowledge of both languages could take a quick look it
 would be great.

 Thanks a lot

 Karoly Negyesi

 Ps. I am not a member of the PHP internals team, I am just a PHP
 developer but I am very very interested in getting these in my
 favourite language.

Whew.  Well I suspect you weren't expecting that kind of reaction.  Or
maybe you were... I used to be a Perl developer, and it didn't take
long before I got a level 12 resistence to flame...

Anyway, the proposal looks mostly okay.  I don't know that much PHP,
but I find the lexical keyword to be a nuisance.  What are the
semantics if the lexical keyword is omitted?(i.e. does the
variable become function-local, global, what?)  If it is consistent
with the rest of the language, it'll do.

There is a much more important point with closures:  their
implementation cannot be half-assed!  I'm not claiming that the patch
is--I have not reviewed it--but there is nothing worse than coming up
with a design that relies on a language feature you only later find
out has been nerfed in some way.  Story of my life in C#.  And nerfed
closures are especially bad, because it's so hard to predict the code
path.

What I mean by this is the following must all be supported:

* A closure must only keep alive the varables it references, not the
whole pad on which they are allocated (Python messed up here)
* A closure must be able to call itself recursively (via a
higher-order function typically)  (Squeak messed up here IIRC)
* Multiple references to the same body of code with different bindings
must be able to exist at the same time (duh, that's kinda what makes
it a closure)
* Closures must be nestable.

Looking over the Zend internal perspective section, it looks like
that implementation will mostly work.  There are a couple of red
flags, though:

* I would recommend only saving $this in the op_array structure if the
closure actually references $this -- if that is possible to deduce at
the time.  Otherwise you might run into unexpected poor memory
performances in certain cases.  (This kind of thing can make an
*asymptotic* difference in memory performance; i.e. bringing the
memory usage of an algorithm from O(1) to O(n), for example)
* I'm worried that nested closures do not work properly with this
implementation sketch.  Here's a test case:

$f = function ($y) {
return function ($z) {
return $y + $z;
}
 };
$f(1)(2) # should give 3

And congratulations, PHP, for adopting a most essential and powerful feature!

Luke
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Something like scan1

2008-06-18 Thread Achim Schneider
Henning Thielemann [EMAIL PROTECTED] wrote:

 
 On Wed, 18 Jun 2008, Achim Schneider wrote:
 
  Is there a generalisation of scan1, such that eg.
 
  foo (+) [0,1] (1,2) = [0,1,1,2,3,5,8,13,...]
 
  ?
 
 What is the (1,2) for? 
 
Specifying the relative indexes an element depends on. Ideally, it
should be generalised for n-ary functions.

 I could think of
 foo f = List.unfoldr (\ xt@(x:xs) - Just (x, xs ++ [f xt]))
 
 foo sum [0,1]  =  [0,1,1,2,3,5,8,13,21,34,...

I should elaborate:

foo (+) [0,1,4] (1,2) = _|_, as 4 isn't 0+1
foo (+) [0,1] (2,3) = [0,1,_|_,1,_|_,_|_]
foo (+) [0,1,1,2,3,5] (1,2) = [0,1,1,2,3,5,8,13,...]
foo (+) [1] (1,1) = [1,2,4,8,16,32,...]


If you allow for inverse functions, you could even say

foo (+-) [0,...,3,..] (1,2) = [0,0,0,...,0,0,1,1,2,3,5,...]


It seems like I'm searching for some primitive that lets me combine
lists and currying. Think of passing a matrix, with each column (or row,
if you prefer) separately uniquely typed, into a function.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Miguel Mitrofanov


On 18 Jun 2008, at 18:19, Seth Gordon wrote:

It seems to me that if a PHP developer sees the Haskell community as  
a resource for advice on programming language implementation, we  
should take this as a compliment to the Haskell community.  Repaying  
that compliment with your language sucks rocks strikes me as unwise.


Not necessarily. It can be that they'd implement closures in PHP, make  
a dog's dinner of it (as they always do), and then we would be blamed  
for giving them wrong advises.


Anyway, it seems that PR Stanley was forced to use PHP, no wonder he's  
a little mad at it.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread PR Stanley



It seems to me that if a PHP developer sees the Haskell community as
a resource for advice on programming language implementation, we
should take this as a compliment to the Haskell community.  Repaying
that compliment with your language sucks rocks strikes me as unwise.


Not necessarily. It can be that they'd implement closures in PHP, make
a dog's dinner of it (as they always do), and then we would be blamed
for giving them bad advice.

Anyway, it seems that PR Stanley was forced to use PHP, no wonder he's
a little mad at it.


Paul: How did you know? :-)
You know, the funny thing is that all these so-called civilised 
people can find time and energy to have a go at me but can't be 
bothered to help the chap with the original query.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Something like scan1

2008-06-18 Thread Henning Thielemann


On Wed, 18 Jun 2008, Achim Schneider wrote:


Henning Thielemann [EMAIL PROTECTED] wrote:


On Wed, 18 Jun 2008, Achim Schneider wrote:


Is there a generalisation of scan1, such that eg.

foo (+) [0,1] (1,2) = [0,1,1,2,3,5,8,13,...]

?


What is the (1,2) for?


Specifying the relative indexes an element depends on. Ideally, it
should be generalised for n-ary functions.


foo f prefix (n,m) =
   let k = length prefix
   xs = prefix ++ zipWith f (xss!!(k-n)) (xss!!(k-m))
   xss = List.tails xs
   in  xs

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Jonathan Cast
On Wed, 2008-06-18 at 16:00 +0100, PR Stanley wrote:
 It seems to me that if a PHP developer sees the Haskell community as
 a resource for advice on programming language implementation, we
 should take this as a compliment to the Haskell community.  Repaying
 that compliment with your language sucks rocks strikes me as unwise.
 
 Not necessarily. It can be that they'd implement closures in PHP, make
 a dog's dinner of it (as they always do), and then we would be blamed
 for giving them bad advice.
 
 Anyway, it seems that PR Stanley was forced to use PHP, no wonder he's
 a little mad at it.
 
 Paul: How did you know? :-)
 You know, the funny thing is that all these so-called civilised 
 people can find time and energy to have a go at me but can't be 
 bothered to help the chap with the original query.

I could, and I think you're full of it, too.

So there.

jcc


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] blas bindings, why are they so much slower the C?

2008-06-18 Thread Bryan O'Sullivan
On Tue, Jun 17, 2008 at 9:00 PM, Anatoly Yakovenko
[EMAIL PROTECTED] wrote:
 here is the C:

 #include cblas.h
 #include stdlib.h

 int main() {
   int size = 1024;
   int ii = 0;
   double* v1 = malloc(sizeof(double) * (size));
   double* v2 = malloc(sizeof(double) * (size));
   for(ii = 0; ii  size*size; ++ii) {
  double _dd = cblas_ddot(0, v1, size, v2, size);
   }
   free(v1);
   free(v2);
 }

Your C compiler sees that you're not using the result of cblas_ddot,
so it doesn't even bother to call it. That loop never gets run. All
your program does at runtime is call malloc and free twice, which is
very fast :-)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bit streams

2008-06-18 Thread Bryan O'Sullivan
On Tue, Jun 17, 2008 at 1:05 PM, Andrew Coppin
[EMAIL PROTECTED] wrote:

 Before I sit down and spend 3 months designing my own library from scratch,
 does anybody know of an existing library that allows you to do what Binary
 does, but with single-bit precision?

The binary-strict library includes this functionality. It also has
several other useful pieces of functionality. It's rather a shame the
binary and binary-strict developers haven't merged their efforts :-(
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Problem building GHC 6.8.3

2008-06-18 Thread Bryan O'Sullivan
On Wed, Jun 18, 2008 at 5:28 AM, Daniel Fischer
[EMAIL PROTECTED] wrote:
 Sorry, probably stupid questions for knowledgeable folks

Not stupid at all, but possibly the wrong mailing list.
glasgow-haskell-users would usually be a better place to ask.

 Setup: Haddock's internal GHC version must match the configured GHC version

You're using Haddock 2.0 or newer. It's not actually possible to build
GHC with it; you must use Haddock 0.9.

Many other packages apparently break with Haddock 2, but GHC is
certainly rather visible :-)  It is possible to have Haddock 0.9 and
2.0 installed simultaneously under different names or in different
locations, but you'll have to patch GHC's sources in order to specify
which Haddock to use. It's a small patch; look on Trac for it.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread PR Stanley



 It seems to me that if a PHP developer sees the Haskell community as
 a resource for advice on programming language implementation, we
 should take this as a compliment to the Haskell community.  Repaying
 that compliment with your language sucks rocks strikes me as unwise.
 
 Not necessarily. It can be that they'd implement closures in PHP, make
 a dog's dinner of it (as they always do), and then we would be blamed
 for giving them bad advice.
 
 Anyway, it seems that PR Stanley was forced to use PHP, no wonder he's
 a little mad at it.

 Paul: How did you know? :-)
 You know, the funny thing is that all these so-called civilised
 people can find time and energy to have a go at me but can't be
 bothered to help the chap with the original query.

I could, and I think you're full of it, too.

So there.


Paul: I rest my case! :-)
you cowardly hypocrit!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Iain Barnett

On 18 Jun 2008, at 9:46 am, Jules Bean wrote:

This is exactly the sort of message that haskell-cafe does not  
normally contain. Let's not start now.




Reactions/arguments like the ones on this thread are perfect for  
Haskell - recursive and exponential.


:)

Could we have closure too? :-) Sorry, couldn't resist that one!


Iain
frequent firestarter and purveyor of bad puns

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Bit Streams

2008-06-18 Thread Don Stewart
dominic.steinitz:
 OK, so today I tried to write my first program using the Binary library. 
 And I've hit a snag: It appears the library will only handle data that 
 is byte-aligned. So if I try to write three Bool values, it uses three 
 bytes, not three bits.
 
 Before I sit down and spend 3 months designing my own library from 
 scratch, does anybody know of an existing library that allows you to do 
 what Binary does, but with single-bit precision? [I presume Binary is 
 byte-aligned for efficiency...]
 
 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict

The bitsyntax library perhaps? or a StateT over Binary for carrying
arround the bit packet to write.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] blas bindings, why are they so much slower the C?

2008-06-18 Thread Anatoly Yakovenko
 #include cblas.h
 #include stdlib.h

 int main() {
   int size = 1024;
   int ii = 0;
   double* v1 = malloc(sizeof(double) * (size));
   double* v2 = malloc(sizeof(double) * (size));
   for(ii = 0; ii  size*size; ++ii) {
  double _dd = cblas_ddot(0, v1, size, v2, size);
   }
   free(v1);
   free(v2);
 }

 Your C compiler sees that you're not using the result of cblas_ddot,
 so it doesn't even bother to call it. That loop never gets run. All
 your program does at runtime is call malloc and free twice, which is
 very fast :-)

C doesn't work like that :).  functions always get called.  but i did
find a problem with my C code, i am incorrectly calling the dot
production function:

#include cblas.h
#include stdlib.h
#include stdio.h
#include string.h

int main() {
   int size = 1024;
   int ii = 0;
   double dd = 0.0;
   double* v1 = malloc(sizeof(double) * (size));
   double* v2 = malloc(sizeof(double) * (size));
   for(ii = 0; ii  size; ++ii) {
  v1[ii] = 0.1;
  v2[ii] = 0.1;
   }
   for(ii = 0; ii  size*size; ++ii) {
  dd += cblas_ddot(size, v1, 0, v2, 0);
   }
   free(v1);
   free(v2);
   printf(%f\n, dd);
   return 0;
}

time ./testdot
10737418.240187

real0m2.200s
user0m2.190s
sys 0m0.010s

So C is about twice as fast.  I can live with that.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Evan Laforge
 * A closure must only keep alive the varables it references, not the
 whole pad on which they are allocated (Python messed up here)

Getting off subject, but I didn't know this about python.  I'm not
saying you're incorrect, but my experimentation shows:

% cat t.py
class A(object):
def __init__(self, name): self.name = name
def __del__(self): print self.name, 'gone'

def f():
x = A('x')
y = A('y')
def g():
print x.name, 'alive'
return g

% python
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type help, copyright, credits or license for more information.
import t
g = t.f()
y gone
g()
x alive
g.func_closure
#- (cell at 0xefb50: A object at 0xefb90,)
del g

x gone
%

So it looks to me like 'y' is not preserved by the closure returned by
'f', and you can see that in its func_closure which keeps the
reference to one A object, but not two.

Python closures do have a unique quirk, which is that variables
bound in a nested function are read-only.  This is something that a
schemer might take issue with, but a haskeller probably wouldn't
notice :)  And for the longest time python had its two space
namespace thing going on, so it wasn't even really lexically scoped,
but that's many years ago now.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Jim Burton



PR Stanley wrote:
 
 [...]
 
 Paul: I rest my case! :-)
 you cowardly hypocrit!
 
Please take your own advice now, and rest your case. Like it or not (I think
most people do like it), haskell-cafe has norms of behaviour that make it
different to many pl mailing lists. Your sarky comments would have gone
unnoticed if they had been accompanied with something constructive. Name
calling is out.

Jim


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

-- 
View this message in context: 
http://www.nabble.com/Lambda-and-closures-in-PHPcould-someone-please-comment--tp17918732p17986275.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Bit Streams

2008-06-18 Thread Adam Langley
On Wed, Jun 18, 2008 at 12:46 AM, Dominic Steinitz
[EMAIL PROTECTED] wrote:
 OK, so today I tried to write my first program using the Binary library.
 And I've hit a snag: It appears the library will only handle data that
 is byte-aligned. So if I try to write three Bool values, it uses three
 bytes, not three bits.

There's a BitGet[1] and BitPut in the Hackage version of
binary-strict. However, these versions work on strict ByteStrings.
Putting, for one, is pretty inefficient. In the darcs version[2] of
binary-strict, there's a fully lazy BitPut[3].

There was a request for a lazy BitGet, but I never wrote it. Most of
the time, bit fields are small and you can use the lazy Get from
binary to extract a ByteString and parse that with strict BitGet.
However, the BitPut should be just fine (including doing things like
writing ByteStrings by shifting each byte etc).

If it's missing anything obvious, ping me and I'll see what I can do.

Cheers,


[1] 
http://darcs.imperialviolet.org/darcsweb.cgi?r=binary-strict;a=headblob;f=/src/Data/Binary/Strict/BitGet.hs
[2] http://darcs.imperialviolet.org/binary-strict/
[3] 
http://darcs.imperialviolet.org/darcsweb.cgi?r=binary-strict;a=headblob;f=/src/Data/Binary/BitPut.hs

-- 
Adam Langley [EMAIL PROTECTED] http://www.imperialviolet.org
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Hans van Thiel

On Wed, 2008-06-18 at 09:46 +0100, Jules Bean wrote:
 PR Stanley wrote:
  With respect, do you not think it'd be wiser for the community 
 
 [snip]
 
 *disgusted*
 
 This is exactly the sort of message that haskell-cafe does not normally 
 contain. Let's not start now.
 
 This is a civilized mailing list. Either comment on the nice gentlemen's 
 PHP closure proposal from a language point of view, or don't say anything.
 
 Jules
Hear, hear...

Hans van Thiel
 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] blas bindings, why are they so much slower the C?

2008-06-18 Thread Adam Langley
On Wed, Jun 18, 2008 at 9:16 AM, Anatoly Yakovenko
[EMAIL PROTECTED] wrote:
 C doesn't work like that :)

Yes it can. You would have to check the disassembly to be sure, but C
compilers can, and do, perform dead code elimination.


AGL

-- 
Adam Langley [EMAIL PROTECTED] http://www.imperialviolet.org
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread PR Stanley



PR Stanley wrote:

 [...]

 Paul: I rest my case! :-)
 you cowardly hypocrit!


Paul: Why did you remove Jonathan Cast's message? Afraid somebody 
might understand why I responded the way I did?




Please take your own advice now, and rest your case. Like it or not (I think
most people do like it), haskell-cafe has norms of behaviour that make it
different to many pl mailing lists. Your sarky comments would have gone
unnoticed if they had been accompanied with something constructive. Name
calling is out.
Paul: and who the bloody hell are you to tell me what's in or out? If 
you want the matter to rest then shut up yourself. I'm getting sick 
of you hypocrites who allow yourselves the audacity to attack me, 
totally gratuitously, yet when I try to defend myself you take the 
moral high ground. Tell me, why did you remove Jonathan Cast's 
message? Is he too big for you? Why don't you tell all the other 
people who have been busy attacking me to modify their language? Are 
you afraid of upsetting the Haskell Cafe Mafia?

Well, guess what, you damn thugs, I 'aint taking this lying down.
You come back with more and I'll give you even more!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread PR Stanley



 PR Stanley wrote:
  With respect, do you not think it'd be wiser for the community

 [snip]

 *disgusted*

 This is exactly the sort of message that haskell-cafe does not normally
 contain. Let's not start now.

 This is a civilized mailing list. Either comment on the nice gentlemen's
 PHP closure proposal from a language point of view, or don't say anything.

 Jules
Hear, hear...
Paul: You can shut up too, you bloody troll!  


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] blas bindings, why are they so much slower the C?

2008-06-18 Thread Jules Bean

Anatoly Yakovenko wrote:

#include cblas.h
#include stdlib.h

int main() {
  int size = 1024;
  int ii = 0;
  double* v1 = malloc(sizeof(double) * (size));
  double* v2 = malloc(sizeof(double) * (size));
  for(ii = 0; ii  size*size; ++ii) {
 double _dd = cblas_ddot(0, v1, size, v2, size);
  }
  free(v1);
  free(v2);
}

Your C compiler sees that you're not using the result of cblas_ddot,
so it doesn't even bother to call it. That loop never gets run. All
your program does at runtime is call malloc and free twice, which is
very fast :-)


C doesn't work like that :). 


C compilers can do what they like ;)

GCC in particular is pretty good at removing dead code, including entire 
loops. However it shouldn't eliminate the call to cblas_ddot unless it 
thinks cblas_ddot has no side effects at all, which would be surprising 
unless it's inlined somehow.


Jules
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] blas bindings, why are they so much slower the C?

2008-06-18 Thread David Roundy
On Wed, Jun 18, 2008 at 09:16:24AM -0700, Anatoly Yakovenko wrote:
  #include cblas.h
  #include stdlib.h
 
  int main() {
int size = 1024;
int ii = 0;
double* v1 = malloc(sizeof(double) * (size));
double* v2 = malloc(sizeof(double) * (size));
for(ii = 0; ii  size*size; ++ii) {
   double _dd = cblas_ddot(0, v1, size, v2, size);
}
free(v1);
free(v2);
  }
 
  Your C compiler sees that you're not using the result of cblas_ddot,
  so it doesn't even bother to call it. That loop never gets run. All
  your program does at runtime is call malloc and free twice, which is
  very fast :-)
 
 C doesn't work like that :).  functions always get called.  but i did
 find a problem with my C code, i am incorrectly calling the dot
 production function:

See a recent article in lwn on pure and const functions to see how gcc
is able to perform dead code elimination and CSE, provided its given
annotations on the relevant functions.  I'd certainly hope that your
blas library is properly annotated!

 #include cblas.h
 #include stdlib.h
 #include stdio.h
 #include string.h
 
 int main() {
int size = 1024;
int ii = 0;
double dd = 0.0;
double* v1 = malloc(sizeof(double) * (size));
double* v2 = malloc(sizeof(double) * (size));
for(ii = 0; ii  size; ++ii) {
   v1[ii] = 0.1;
   v2[ii] = 0.1;
}
for(ii = 0; ii  size*size; ++ii) {
   dd += cblas_ddot(size, v1, 0, v2, 0);
}
free(v1);
free(v2);
printf(%f\n, dd);
return 0;
 }
 
 time ./testdot
 10737418.240187
 
 real0m2.200s
 user0m2.190s
 sys 0m0.010s
 
 So C is about twice as fast.  I can live with that.

I suspect that it is your initialization that is the difference.  For
one thing, you've initialized the arrays to different values, and in
your C code you've fused what are two separate loops in your Haskell
code.  So you've not only given the C compiler an easier loop to run
(since you're initializing the array to a constant rather than to a
sequence of numbers), but you've also manually optimized that
initialization.  In fact, this fusion could be precisely the factor of
two.  Why not see what happens in Haskell if you create just one
vector and dot it with itself? (of course, that'll also make the blas
call faster, so you'll need to be careful in your interpretation of
your results.)

David
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] blas bindings, why are they so much slower the C?

2008-06-18 Thread David Roundy
On Wed, Jun 18, 2008 at 06:03:42PM +0100, Jules Bean wrote:
 Anatoly Yakovenko wrote:
 #include cblas.h
 #include stdlib.h
 
 int main() {
   int size = 1024;
   int ii = 0;
   double* v1 = malloc(sizeof(double) * (size));
   double* v2 = malloc(sizeof(double) * (size));
   for(ii = 0; ii  size*size; ++ii) {
  double _dd = cblas_ddot(0, v1, size, v2, size);
   }
   free(v1);
   free(v2);
 }
 Your C compiler sees that you're not using the result of cblas_ddot,
 so it doesn't even bother to call it. That loop never gets run. All
 your program does at runtime is call malloc and free twice, which is
 very fast :-)
 
 C doesn't work like that :). 
 
 C compilers can do what they like ;)
 
 GCC in particular is pretty good at removing dead code, including entire 
 loops. However it shouldn't eliminate the call to cblas_ddot unless it 
 thinks cblas_ddot has no side effects at all, which would be surprising 
 unless it's inlined somehow.

Or unless it's been annotated as pure, which it should be.

David
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Jim Burton


PR Stanley wrote:
 
 
PR Stanley wrote:
 
  [...]
 
  Paul: I rest my case! :-)
  you cowardly hypocrit!
 
 Paul: Why did you remove Jonathan Cast's message? Afraid somebody 
 might understand why I responded the way I did?
 
 
Please take your own advice now, and rest your case. Like it or not (I
think
most people do like it), haskell-cafe has norms of behaviour that make it
different to many pl mailing lists. Your sarky comments would have gone
unnoticed if they had been accompanied with something constructive. Name
calling is out.
 Paul: and who the bloody hell are you to tell me what's in or out? If 
 you want the matter to rest then shut up yourself. I'm getting sick 
 of you hypocrites who allow yourselves the audacity to attack me, 
 totally gratuitously, yet when I try to defend myself you take the 
 moral high ground. Tell me, why did you remove Jonathan Cast's 
 message? Is he too big for you? Why don't you tell all the other 
 people who have been busy attacking me to modify their language? Are 
 you afraid of upsetting the Haskell Cafe Mafia?
 Well, guess what, you damn thugs, I 'aint taking this lying down.
 You come back with more and I'll give you even more!
 
I snipped Jonathan's message just because I was commenting on the tone of
your response. Sorry if you think I presented your reply out of context, but
my point is that I don't think there is any need for this in any context
here. I do have a right to say that, even as someone who hardly ever posts
but prefers to read the list...it's owned by everybody. This isn't the same
thing as censorship and you'll notice I said norms, not rules of behaviour.
No one's going to stop you making yourself look silly if you insist on doing
it. As for Jonathan being too big for me, erm, who is he again? :-)


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

-- 
View this message in context: 
http://www.nabble.com/Lambda-and-closures-in-PHPcould-someone-please-comment--tp17918732p17987734.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread PR Stanley

At 18:17 18/06/2008, you wrote:



PR Stanley wrote:


PR Stanley wrote:
 
  [...]
 
  Paul: I rest my case! :-)
  you cowardly hypocrit!

 Paul: Why did you remove Jonathan Cast's message? Afraid somebody
 might understand why I responded the way I did?

 
Please take your own advice now, and rest your case. Like it or not (I
think
most people do like it), haskell-cafe has norms of behaviour that make it
different to many pl mailing lists. Your sarky comments would have gone
unnoticed if they had been accompanied with something constructive. Name
calling is out.
 Paul: and who the bloody hell are you to tell me what's in or out? If
 you want the matter to rest then shut up yourself. I'm getting sick
 of you hypocrites who allow yourselves the audacity to attack me,
 totally gratuitously, yet when I try to defend myself you take the
 moral high ground. Tell me, why did you remove Jonathan Cast's
 message? Is he too big for you? Why don't you tell all the other
 people who have been busy attacking me to modify their language? Are
 you afraid of upsetting the Haskell Cafe Mafia?
 Well, guess what, you damn thugs, I 'aint taking this lying down.
 You come back with more and I'll give you even more!

I snipped Jonathan's message just because I was commenting on the tone of
your response. Sorry if you think I presented your reply out of context, but
my point is that I don't think there is any need for this in any context
here. I do have a right to say that, even as someone who hardly ever posts
but prefers to read the list...it's owned by everybody. This isn't the same
thing as censorship and you'll notice I said norms, not rules of behaviour.
No one's going to stop you making yourself look silly if you insist on doing
it. As for Jonathan being too big for me, erm, who is he again? :-)

Paul: So, now I am silly! I'd still prefer that to a coward and a hypocrite

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Bit Streams

2008-06-18 Thread Andrew Coppin

Dominic Steinitz wrote:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict
  


Ooo... looks interesting. Pity I can't look at any documentation for it. 
(Is that *really* Haddoc failing with a parse error on a pragma? Surely 
not...) I'll take a look at this.


Thanks.
Andrew.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Bit Streams

2008-06-18 Thread Don Stewart
agl:
 On Wed, Jun 18, 2008 at 12:46 AM, Dominic Steinitz
 [EMAIL PROTECTED] wrote:
  OK, so today I tried to write my first program using the Binary library.
  And I've hit a snag: It appears the library will only handle data that
  is byte-aligned. So if I try to write three Bool values, it uses three
  bytes, not three bits.
 
 There's a BitGet[1] and BitPut in the Hackage version of
 binary-strict. However, these versions work on strict ByteStrings.
 Putting, for one, is pretty inefficient. In the darcs version[2] of
 binary-strict, there's a fully lazy BitPut[3].
 
 There was a request for a lazy BitGet, but I never wrote it. Most of
 the time, bit fields are small and you can use the lazy Get from
 binary to extract a ByteString and parse that with strict BitGet.
 However, the BitPut should be just fine (including doing things like
 writing ByteStrings by shifting each byte etc).
 
 If it's missing anything obvious, ping me and I'll see what I can do.
 
 Cheers,
 
 
 [1] 
 http://darcs.imperialviolet.org/darcsweb.cgi?r=binary-strict;a=headblob;f=/src/Data/Binary/Strict/BitGet.hs
 [2] http://darcs.imperialviolet.org/binary-strict/
 [3] 
 http://darcs.imperialviolet.org/darcsweb.cgi?r=binary-strict;a=headblob;f=/src/Data/Binary/BitPut.hs

Adam,

Would you recommend binary-strict over bitsyntax now?
Or are none yet entirely satisfactory

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Alex Sandro Queiroz e Silva

Hallo,

PR Stanley wrote:
Now, if you, Jules, Alex or some other  wannabe Hitler have a problem 
with my freedom of expression then your best solution is to saddle up 
and get the hell out yourselves. This is the wrong place for setting up 
your tinpot dictatorship, Doctor!
I am grateful for the help I've been getting from the list and my 
understanding of FP has vastly improved since my membership of this list 
but I refuse to tolerate bullies who use the list as a way of lifting 
themselves out of their own shitty lives. Now I am angry!




 Wow, Godwin's in record time. Please don't confuse freedom of 
speech with name-calling, or distasteful, non-constructive comments 
about someone else's programming language.

 Stop making yourself look like a fool.

-alex
http://www.ventonegro.org/

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Bit Streams

2008-06-18 Thread Adam Langley
On Wed, Jun 18, 2008 at 10:52 AM, Don Stewart [EMAIL PROTECTED] wrote:
 Would you recommend binary-strict over bitsyntax now?
 Or are none yet entirely satisfactory

Probably, yes. Bitsyntax was, after all, the first Haskell code I ever
wrote :) It works, but I think the monad style of binary-strict is
better.


AGL

-- 
Adam Langley [EMAIL PROTECTED] http://www.imperialviolet.org
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Bit Streams

2008-06-18 Thread Evan Laforge
On Wed, Jun 18, 2008 at 10:43 AM, Andrew Coppin
[EMAIL PROTECTED] wrote:
 Dominic Steinitz wrote:

 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict


 Ooo... looks interesting. Pity I can't look at any documentation for it. (Is
 that *really* Haddoc failing with a parse error on a pragma? Surely not...)
 I'll take a look at this.

Yeah, I just ran into that myself, and solved it by removing the
haddock comments for those types.

I think Haddock is a bit oversensitive when it comes to parsing.  It
would be nice if it would at least try to continue when it failed to
parse something.  Of course, that might be easier said than done!

While I'm on the subject, what is the future for binary-strict?  I
recently wanted it since I wanted to catch parse errors, but didn't
wind up using it because I would have had to rewrite a whole bunch of
Binary instances to be separate Binary.Put Binary.Strict.Get
instances, and I'm lazy.  So I did 'length (show result) `seq` return
result which doesn't win any beauty contests but seems to work.

Inclusion in the official Data.Binary would be nice, especially if it
could be a drop-in replacement, say by changing the Data.Binary
instance definitions to Strict.Binary or something.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Bit Streams

2008-06-18 Thread Bryan O'Sullivan
On Wed, Jun 18, 2008 at 11:00 AM, Adam Langley [EMAIL PROTECTED] wrote:
 On Wed, Jun 18, 2008 at 10:52 AM, Don Stewart [EMAIL PROTECTED] wrote:
 Would you recommend binary-strict over bitsyntax now?
 Or are none yet entirely satisfactory

 Probably, yes. Bitsyntax was, after all, the first Haskell code I ever
 wrote :) It works, but I think the monad style of binary-strict is
 better.

If you provide Applicative and Alternative instances for your getter
monads (perhaps you already do?), that will get us very close to the
kind of notational succinctness that Erlang's bit-level pattern
matching gives, using entirely general Haskell mechanisms, and without
the fuglitude of TH. That, I think, would be just lovely.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Fast sorting with Bytestring

2008-06-18 Thread Georg Sauthoff
Hi,

I played a bit around with the nice bytestring package. At some point I
implemented a simple sorting program, because I needed line-sorting a file
with a custom line-compare function. I was a bit surprised, that the
resulting code is very fast. A lot of faster than sorting via GNU sort
(with the standard line-compare function).

Then I got suspicious and tested standard GNU sort against a trivial
standard sort implementation in Haskell using bytestring. The Haskell
implementation looks like:

 module Main
 where

 import qualified Data.ByteString.Lazy.Char8 as B
 import Data.List


 main = do
  c - B.getContents
  let l = B.lines c
  let r = sort l
  B.putStr $ B.unlines r

Sorting a file of '[]'-strings I get:

time ./sort  brackets  /dev/null  # ~  0.01 s
time sort  brackets  /dev/null# ~ 14s

Ok, strane ... Well, let's test with some 'normal' text:

time ./sort  bible  /dev/null   # ~  0.4   s
time sort  bible  /dev/null # ~  0.56  s

Ok, not that different. But with Haskell you often expect to get very
slow code compared to an implementation in C.

And I am surprised, that the Haskell is fast _and_ nice to read - because
for example the ultra fast 'wc -l' Haskell implementation from the
Haskell-Wiki uses some insider-knowledge about bytestring, and looks to
a beginner not that intuitive, I guess.

./sort is the shown Haskell implementation. I used ghc 6.8.2, installed
bytestring 0.9.1.0 as a user-local package (don't now I this superseeds
the global bytestring package), compiled via ghc -O2. The tests are run at a
Pentium M 1.3 GHz computer. As GNU sort I tested the version from
coreutils 6.9.

You can get the test files from:
http://www.techfak.uni-bielefeld.de/~gsauthof/stuff/brackets.gz
http://www.techfak.uni-bielefeld.de/~gsauthof/stuff/bible.gz
(obviously, you have to gunzip them after downloading ...)

Of course, the naive Haskell implementation doesn't care about locales
(i.e. collating locale sequences), but this shouldn't explain the
observed differences sorting the brackets file.

Best regards
Georg Sauthoff
-- 
Fortune : 'Real programmers don't comment their code.
   It was hard to write, it should be hard to understand.' ;)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Fast sorting with Bytestring

2008-06-18 Thread Stefan O'Rear
On Wed, Jun 18, 2008 at 08:19:10PM +0200, Georg Sauthoff wrote:
 Hi,
 
 I played a bit around with the nice bytestring package. At some point I
 implemented a simple sorting program, because I needed line-sorting a file
 with a custom line-compare function. I was a bit surprised, that the
 resulting code is very fast. A lot of faster than sorting via GNU sort
 (with the standard line-compare function).
 
 Then I got suspicious and tested standard GNU sort against a trivial
 standard sort implementation in Haskell using bytestring. The Haskell
 implementation looks like:
 
[snip]
 Ok, strane ... Well, let's test with some 'normal' text:
 
 time ./sort  bible  /dev/null   # ~  0.4   s
 time sort  bible  /dev/null # ~  0.56  s
 
 Ok, not that different. But with Haskell you often expect to get very
 slow code compared to an implementation in C.
 
 And I am surprised, that the Haskell is fast _and_ nice to read - because
 for example the ultra fast 'wc -l' Haskell implementation from the
 Haskell-Wiki uses some insider-knowledge about bytestring, and looks to
 a beginner not that intuitive, I guess.
 
 ./sort is the shown Haskell implementation. I used ghc 6.8.2, installed
 bytestring 0.9.1.0 as a user-local package (don't now I this superseeds
 the global bytestring package), compiled via ghc -O2. The tests are run at a
 Pentium M 1.3 GHz computer. As GNU sort I tested the version from
 coreutils 6.9.
 
 You can get the test files from:
 http://www.techfak.uni-bielefeld.de/~gsauthof/stuff/brackets.gz
 http://www.techfak.uni-bielefeld.de/~gsauthof/stuff/bible.gz
 (obviously, you have to gunzip them after downloading ...)
 
 Of course, the naive Haskell implementation doesn't care about locales
 (i.e. collating locale sequences), but this shouldn't explain the
 observed differences sorting the brackets file.

GNU 'sort' uses an external sort algorithm.  You can, with 200M of
memory, give it a 50G input file, and it will work.  This might explain
the difference..

Stefan


signature.asc
Description: Digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Fast sorting with Bytestring

2008-06-18 Thread Georg Sauthoff
On Wed, Jun 18, 2008 at 11:23:00AM -0700, Stefan O'Rear wrote:
 GNU 'sort' uses an external sort algorithm.  You can, with 200M of
 memory, give it a 50G input file, and it will work.  This might explain
 the difference..

But the input files are both  10 mb ...

If I create a 'big_bible' file like 'cat bible bible | dd
of=big_bible count=1 bs=SIZE_OF_BRACKETS' then the timings are:

time sort  big_bible  /dev/null #  ~ 1.2 s
time ./sort  big_bible  /dev/null   #  ~ 0.8 s

I.e. the difference here is like a low constant factor, and not like a factor
of 1000 with the brackets.

Best regards
Georg Sauthoff
-- 
Fortune : 'Real programmers don't comment their code.
   It was hard to write, it should be hard to understand.' ;)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Fast sorting with Bytestring

2008-06-18 Thread Ketil Malde
Stefan O'Rear [EMAIL PROTECTED] writes:

 Ok, strane ... Well, let's test with some 'normal' text:
 
 time ./sort  bible  /dev/null   # ~  0.4   s
 time sort  bible  /dev/null # ~  0.56  s

 Ok, not that different. But with Haskell you often expect to get very
 slow code compared to an implementation in C.

 GNU 'sort' uses an external sort algorithm.  You can, with 200M of
 memory, give it a 50G input file, and it will work.  This might explain
 the difference..

GNU sort also handles locale-based comparison, which I suspect
explains more of the difference.  Try with LC_ALL=C.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] type constructor confusion

2008-06-18 Thread Stephen Howard

hello list,

loading the code below into ghci gives me this error:

HttpMessage.hs:36:20: Not in scope: type constructor or class `HttpRequest'

The troublesome line is the definition of the cookie function at the end 
of the code.  I've made HttpRequest and HttpResponse constructors of 
HttpMessage as I've sketched out an action that might return either 
one.  Given that I thought what I was doing below was defining these as 
type constructors (maybe I have my vocabulary mixed up) I don't know why 
ghci is returning this error.



module HttpMessage ( HttpMessage(..), HttpRequestMethod(..), cookie ) where

import Data.Map as M

data HttpHeaders = HttpHeaders !(M.Map String String )
data HttpMessage =
   HttpRequest {
   headers:: HttpHeaders,
   body   :: String,
   request_method :: HttpRequestMethod,
   uri:: URI,
   http_version   :: Float,
   cookies:: !(M.Map String String)
   }
   | HttpResponse {
   headers:: HttpHeaders,
   body   :: String,
   status :: HttpStatus
   }

data HttpRequestMethod = Get | Head | Post | Put | Delete | Unsupported 
String

data HttpStatus = OK | NotFound | NotAuthorized | ServerError

data URI = URI {
   protocol :: String,
   domain   :: String,
   port :: String,
   path :: String,
   query:: !(M.Map String String),
   anchor   :: String
}

cookie :: String - HttpRequest - Maybe String
cookie n request = M.lookup n (cookies request)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] type constructor confusion

2008-06-18 Thread Brandon S. Allbery KF8NH


On Jun 18, 2008, at 15:31 , Stephen Howard wrote:

HttpMessage.hs:36:20: Not in scope: type constructor or class  
`HttpRequest'


The troublesome line is the definition of the cookie function at  
the end of the code.  I've made


Right.  HttpRequest is a data constructor associated with the type  
constructor HttpMessage.
(Data constructors are effectively functions; you used it in the  
context of a type, not a function name.)


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: working with Random.randoms

2008-06-18 Thread Stephen Howard

Thanks for the replies.  This was my solution:

module RandomTest ( random_test ) where

import Random

random_test :: Int - IO String
random_test n = do
   g - newStdGen
   return $ take n (randomRs printable_ascii g)
 where printable_ascii = ('!','~')

The struggling with the type system was supposed to be 
tongue-in-cheek.  I trust it, it just takes some time to get used to 
it.  And I appreciate Dan's comments about separating the pure code from 
the non-pure, but in this case the code was succinct enough that one 
more layer of functions seemed to do more harm than good when it came to 
legibility.


- Stephen

Jon Fairbairn wrote:

Stephen Howard [EMAIL PROTECTED] writes:

  

I am a newcomer doing my obligatory struggling with
Haskell's type system, 



That's your mistake. Don't struggle with the type system,
the type system is your friend; when it tells you you are
doing something wrong, it's usually right.

  

and I've got a nut I've not been able to crack.  Given:

import Random

random_test :: Int - String
random_test n = do
   g - getStdGen
   take n (randoms g)::String



My immediate reaction on seeing this is that do is for
manipulating monads, but the only monad you've indicated in
the type is [] (from String = [Char]), and that's probably
an accident.

In GHCi:

Prelude :t Random.getStdGen
Random.getStdGen :: IO System.Random.StdGen

What this says is that getStdGen isn't a function, which is
to say it doesn't always return the same value (ie it isn't
pure -- it wouldn't be much use if it were!). In effect it
uses the real world to get a new value, and such things are
kept safely in the IO monad. In C, everything is in the IO
monad; there's no way of telling from the type whether
something is pure or not¹. In Haskell (apart from some
ugliness that's supposed to stay hidden) you have to
distinguish between pure and impure, and the type checker
keeps track of all this for you.

  

And yet, when I run these lines in GHCI by hand,



The top level of GHCi is IO (which shouldn't come as a
surprise!)

  

things seem to work (though the string is the same set of
random characters each time, another bit that I need to
solve



That's a somewhat obscure aspect of GHCi, I think, to do
with not reverting top-level expressions.  If you do this:

Prelude :set +r
Prelude g - Random.getStdGen -- what's the type?
1954047482 7573
Prelude g - Random.getStdGen -- what's the type?
1626678354 7697
Prelude 


you see that you get a different StdGen each time.

  

I'm guessing that randoms is returning an IO type but I'm
not sure how to go about extracting the String to return to
the calling action.  Changing the type signature to Int -
IO  String only gives me a different error.



If you do any IO, you've done some IO! So you need to lift
out the StdGen and pass that to the functions that you want
to use it.

main :: IO()
   do gen - getStdGen
  the_list - real_programme gen
  print the_list

You should be able to deduce from the fact that the first
argument of real_programme here is of type StdGen (not IO
anything) and its result type is [something] that
real_programme is pure, and gen has only one value
throughout. So if you want more than one random list out of
it, you either need to use Random.split or pass more than
one gen in.


[1] Were you truly perverse, you could define your own
libraries in Haskell so that YourInt = IO Int; YourDouble =
IO Double etc, and make appropriate classes in place of Num
c (hiding the proper ones), so that

+ :: YourInt - YourInt - YourInt

and so on (you'd have to define your own Bool and if, too,
but Haskell can do that). Then the type checker would
overlook all sorts of mistakes that it could otherwise have
caught.


  

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Fast sorting with Bytestring

2008-06-18 Thread Georg Sauthoff
On Wed, Jun 18, 2008 at 08:56:43PM +0200, Ketil Malde wrote:
 Stefan O'Rear [EMAIL PROTECTED] writes:
  GNU 'sort' uses an external sort algorithm.  You can, with 200M of
  memory, give it a 50G input file, and it will work.  This might explain
  the difference..
 
 GNU sort also handles locale-based comparison, which I suspect
 explains more of the difference.  Try with LC_ALL=C.

Well, for input 'bible' with locale en_US.utf8 GNU sort is ~ 6 times
slower than with locale C. But for input 'brackets' it is ~ 433 times
slower ...

Best regards
Georg Sauthoff
-- 
Fortune : 'Real programmers don't comment their code.
   It was hard to write, it should be hard to understand.' ;)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Meaning of ribbonsPerLine at Text.PrettyPrint.HughesPJ ?

2008-06-18 Thread Alfonso Acosta
Hi,

Can anyone give a good explanation of what ribbonsPerLine means?

Maybe it would be better to simply ask for the meaning of ribbon in
this context. The documentation is totally meaningless to me:
reibbonsPerLine: Ratio of ribbon length to line length.

I asked at #haskell and frankly, I was surprised by the answer:

fons: can anyone tell me what the heck does ribbonsPerLine mean in
Text.PrettyPrint.HughesPJ?
fons:  renderStyle style{lineLength=10, ribbonsPerLine=1} $ sep [text
foo ,text bar]
lambdabot:  foo bar
fons:  renderStyle style{lineLength=10, ribbonsPerLine=2} $ sep [text
foo ,text bar]
lambdabot:  foo\nbar
fons: ok, somehow it affects the line width ...
byorgey: fons: I can't explain it, all I know is that you must set it
to 1 or else it does bizarre things
fons: hahah, ok
fons: byorgey: that's funny considering its default value is 1.5
byorgey: if you set it to 1 then lineLength means what you think it should
byorgey: fons: EXACTLY

Cheers,

Fons
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Haskell Weekly News: Issue 73 - June 18, 2008

2008-06-18 Thread Brent Yorgey
---
Haskell Weekly News
http://sequence.complete.org/hwn/20080618
Issue 73 - June 18, 2008
---

   Welcome to issue 73 of HWN, a newsletter covering developments in the
   [1]Haskell community.

   The Google Summer of Code is in full swing, preparations are underway
   for ICFP and the eleventh ICFP Programming Contest, and cabal-install
   is oh-so-sexy. It's an exciting time to be a part of the Haskell
   community!

Community News

   Andy Gill has completed his move from Portland, OR to Kansas.

   Luke Palmer (luqui) has [2]begun work for [3]Anygma, Peter
   Verswyvelen's startup using Haskell (among other languages) to
   ``generate easy-to-use tools for creating audio-visual 2D/3D content.''

   Congrats to Andy and Luke on their new beginnings!

Announcements

   Final CFP: 2008 Haskell Symposium. Andy Gill [4]announced the final
   call for papers for the [5]2008 Haskell Symposium. The deadline is the
   23rd of this month; please submit a paper!

   cabal-install. Duncan Coutts [6]announced the release of
   [7]cabal-install-0.5, along with the release of Cabal-1.4 to support
   it. It features an improved command line interface, smarter upgrading,
   and is made of win. If you are still stuck in the dark ages of
   runhaskell Setup configure blah blah, then the imperative monkeys have
   already won.

   ICFP programming contest. Tim Chevalier [8]announced the eleventh
   annual [9]ICFP programming contest, to be held from Friday, July 11,
   2008 to Monday, July 14, 2008. Are you ready?

   c.h.o trac. Ian Lynagh [10]announced that it is now possible for
   projects on [11]community.haskell.org to [12]create themselves a trac,
   providing a bug tracking system and wiki.

   random-access-list. Stephan Friedrichs [13]announced an
   [14]implementation of Chris Okasaki's random-access lists, providing
   typical list operations (cons, head, tail) in O(1) and indexed
   random-access in O(log n).

   GHC version 6.8.3. Ian Lynagh [15]announced a [16]new patchlevel
   release of [17]GHC, containing a number of bugfixes relative to 6.8.2.

   Printf-TH. Marc Weber [18]announced that he has taken over maintenance
   of the [19]Printf-TH library, which implements a printf function via
   [20]Template Haskell, in order to guarantee that wrong argument types
   or the wrong number of arguments will result in compile time errors.

   Mueval. Gwern Branwen [21]announced the release of the [22]mueval
   package, providing a standalone executable for evaluating Haskell
   expressions based on the GHC API.

   Topkata. Christoph Bauer [23]announced the release of [24]Topkata, a
   simple OpenGL game written in Haskell. The goal is to guide a ball
   through a labyrinth to the opposite corner.

   Haddock Trac. David Waern [25]announced a new [26]bug-tracker and wiki
   for the [27]Haddock project.

   Fortress talk. Jeff Polakow [28]announced that a [29]talk on
   [30]Fortress, a new OO/functional language from Sun, will take place on
   Wednesday, June 25 at 6:30pm in Manhattan, New York, USA.

   ieee-0.2. Patrick Perry [31]announced the release of [32]ieee, a
   library that provides approximate comparison of floating point numbers
   based, NaN-aware minimum and maximum, and a type class for approximate
   comparisons.

Google Summer of Code

   Hoogle 4. Neil Mitchell (ndm) is [33]working on Hoogle 4, recently
   adding support for generating Hoogle databases to [34]Haddock, using
   the GHC API. This week he plans to work on database creation and text
   searches.

   DPH physics engine. Roman Cheplyaka (Feuerbach) is [35]working on a
   physics engine using [36]Data Parallel Haskell, recently adding
   rotations, represented by quaternions. Next he plans to handle
   collisions properly with respect to rotation, and to add documentation.

   Generic tries. Jamie Brandon is writing a library for efficient maps
   using generalized tries. He has come up with a preliminary API and is
   [37]asking for feedback.

   Cabal dependency framework. Andrea Vezzosi (Saizan) is working on a
   make-like dependency analysis framework for Cabal, recently refining
   the core model, that has built its first sources in the testing
   environment. The next step will be dealing with preprocessor chaining.

   Language.C. Benedikt Huber (visq) is working on Language.C, a
   standalone parser/pretty printer library for C99. The test suite is
   finished, the parser and pretty printer support most GNU extensions,
   and all failing tests of gcc.dg are documented.

   GHC API. Thomas Schilling (nominolo) is working on improvements to the
   GHC API.

   GHC plugins. Maximilian Conroy Bolingbroke is working on dynamically
   loaded plugins for GHC.

Discussion

   Low-level array performance. Dan Doel began a [38]discussion about the
   [39]fannkuch benchmark and the current

[Haskell-cafe] Using cabal-install

2008-06-18 Thread Daniel Fischer
Is there a tutorial/user's guide for cabal-install somewhere?
My limited google skills haven't found one and I really need it, because there 
MUST be a better way to get a package and its dependencies built and the 
haddock documentation generated, installed and hyperlinked than manually 
unpacking each .tar.gz and running cabal haddock there.

Thanks,
Daniel
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Meaning of ribbonsPerLine at Text.PrettyPrint.HughesPJ ?

2008-06-18 Thread Evan Laforge
 byorgey: fons: I can't explain it, all I know is that you must set it
 to 1 or else it does bizarre things
 fons: hahah, ok
 fons: byorgey: that's funny considering its default value is 1.5
 byorgey: if you set it to 1 then lineLength means what you think it should
 byorgey: fons: EXACTLY

Excellent, thanks for solving a nagging problem I couldn't be bothered
to track down.  I was wondering why my pretty printing was a little
messed up and slightly too wide.

And isn't 100 columns a bit non-standard for a default?  I thought 80
columns had more traction?  I know that's what my terminals are at...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using cabal-install

2008-06-18 Thread Don Stewart

http://blog.well-typed.com/2008/06/new-cabal-and-cabal-install-releases/

Basically, build and install cabal-install, then let have it.

daniel.is.fischer:
 Is there a tutorial/user's guide for cabal-install somewhere?
 My limited google skills haven't found one and I really need it, because 
 there 
 MUST be a better way to get a package and its dependencies built and the 
 haddock documentation generated, installed and hyperlinked than manually 
 unpacking each .tar.gz and running cabal haddock there.
 
 Thanks,
 Daniel
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Problem building GHC 6.8.3

2008-06-18 Thread David Waern
2008/6/18 Bryan O'Sullivan [EMAIL PROTECTED]:
 On Wed, Jun 18, 2008 at 5:28 AM, Daniel Fischer
 [EMAIL PROTECTED] wrote:
 Sorry, probably stupid questions for knowledgeable folks

 Not stupid at all, but possibly the wrong mailing list.
 glasgow-haskell-users would usually be a better place to ask.

 Setup: Haddock's internal GHC version must match the configured GHC version

 You're using Haddock 2.0 or newer. It's not actually possible to build
 GHC with it; you must use Haddock 0.9.

We're discussing how to fix this problem in future releases of GHC and
Haddock. In the meantime, it is actually possible to build GHC with
Haddock 2.1.0 by first building GHC without docs, then installing
Haddock with this GHC, and then building the GHC documentation.

David
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using cabal-install

2008-06-18 Thread Daniel Fischer
Am Mittwoch, 18. Juni 2008 22:57 schrieb Don Stewart:
 http://blog.well-typed.com/2008/06/new-cabal-and-cabal-install-releases/

 Basically, build and install cabal-install, then let have it.

I have cabal-install installed, and I'm thankful for it.
My problem is, when I do
cabal install foo
it downloads foo and its dependencies, builds and installs, but it doesn't 
generate the documentation.
How do I get it to build, install and link the documentation for all packages 
automatically, too?


 daniel.is.fischer:
  Is there a tutorial/user's guide for cabal-install somewhere?
  My limited google skills haven't found one and I really need it, because
  there MUST be a better way to get a package and its dependencies built
  and the haddock documentation generated, installed and hyperlinked than
  manually unpacking each .tar.gz and running cabal haddock there.
 
  Thanks,
  Daniel

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bit streams

2008-06-18 Thread Jeremy Shaw
Malcolm Wallace wrote:

 The original Binary library, circa 1998, was based on bit-streams rather
 than bytes.  You might be able to dig up a copy and bring it back to
 life.

This derivative (by Hal Daume III) works with GHC 6.8.2 (I haven't tried 6.8.3):

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/NewBinary

Not sure how to compares to the original version. It does appear to
still support bit-oriented I/O though.

j.

(Note: I just fixed the cabal stuff to work with 6.8.2 minutes ago, so if have 
tried it before, it should work now).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using cabal-install

2008-06-18 Thread Duncan Coutts

On Wed, 2008-06-18 at 22:44 +0200, Daniel Fischer wrote:
 Is there a tutorial/user's guide for cabal-install somewhere?
 My limited google skills haven't found one and I really need it, because 
 there 
 MUST be a better way to get a package and its dependencies built and the 
 haddock documentation generated, installed and hyperlinked than manually 
 unpacking each .tar.gz and running cabal haddock there.

The feature you are looking for is not implemented yet.

cabal-install should be able to generate haddock docs
http://hackage.haskell.org/trac/hackage/ticket/206

Go add your comments to that ticket and tell us how you think it should
work. I mean what command would you expect to run to have it work and
what would it do exactly?

A closely related feature and one it probably overlaps with is this
one: 

allow installing just specific bits, like just docs
http://hackage.haskell.org/trac/hackage/ticket/225

so we should also think about what the user interface / mode of
interaction of this feature should be.

The issue is that previously we had separate commands for each phase so
it was obvious where to put various phase-specific flags. Now with
cabal-install's install command it does all the phases in one go.
Currently it takes just the flags that the configure command takes (plus
one or two others). So do we just make the install command take the
union of the flags of the other phases? And how to say that we want
optional phases like docs and tests.

That's basically the issue, how do we expect to interact with it? If it
can be relatively consistent and memorable then that's all the better.

We also want all flags that you can pass on the command line to be able
to be set as defaults in the ~/.cabal/config file. Currently there's
just a subset but we want to have it cover everything.


In general, adding yourself to the cc list of a ticket counts as a vote
for the importance of that ticket and commenting on why it's important
even more so (eg how painful and time consuming the alternative is).

Duncan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Meaning of ribbonsPerLine at Text.PrettyPrint.HughesPJ ?

2008-06-18 Thread Duncan Coutts

On Wed, 2008-06-18 at 13:55 -0700, Evan Laforge wrote:
  byorgey: fons: I can't explain it, all I know is that you must set it
  to 1 or else it does bizarre things
  fons: hahah, ok
  fons: byorgey: that's funny considering its default value is 1.5
  byorgey: if you set it to 1 then lineLength means what you think it should
  byorgey: fons: EXACTLY
 
 Excellent, thanks for solving a nagging problem I couldn't be bothered
 to track down.  I was wondering why my pretty printing was a little
 messed up and slightly too wide.
 
 And isn't 100 columns a bit non-standard for a default?  I thought 80
 columns had more traction?  I know that's what my terminals are at...

Yeah. I'd vote for 80. That's what we use in pretty printing messages in
Cabal.

Duncan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] First Call for Papers: DSL WC

2008-06-18 Thread Emir Pasalic

IFIP Working Conference on Domain Specific Languages (DSL WC)
July 15-17, 2009, Oxford

CALL FOR PAPERS

Domain-specific languages are emerging as a fundamental component of  
software engineering practice. DSLs are often introduced when new  
domains such as web-scripting or markup come into existence, but it is  
also common to see DSLs being introduced and adopted for traditional  
domains such as parsing and data description. Developing software  
using DSLs has many benefits. DSLs are often designed based on  
existing notations that are already in use by experts in a given  
domain. As such, successful DSLs often reduce or eliminate the effort  
needed to transform the concept or innovation produced by the domain  
expert into an executable artifact or even a deliverable software  
product. DSL implementations can capture and mechanize a significant  
portion of the repetitive and mechanical tasks that a domain expert  
traditionally needed to perform in order to produce an executable.  
DSLs can in many cases capture and make widely available special  
expertise that only top specialists in a given domain might have. By  
capturing expert knowledge and reducing repetitive tasks, DSLs often  
also lead to software that is significantly more portable, more  
reliable and more understandable than it would otherwise be.


DSLs can be viewed as having a dual role to general-purpose languages:  
whereas general purpose languages try to do everything as well as  
possible, DSLs are designed to find a domain where they can solve some  
class of problems -- no matter how small -- in the best possible way.  
Widely known examples of DSLs include Matlab, Verilog, SQL, LINQ,  
JavaScript, PERL, HTML, Open GL, Tcl/Tk, Macromedia Director,  
Mathematica/Maple, AutoLisp/AutoCAD, XSLT, RPM, Make, lex/yacc, LaTeX,  
PostScript, Excel, among many others. But while these tools have been  
widely successful, they still fall short of realizing the full idea  
behind them. The goal of this conference is to explore the extent to  
which incorporating modern principles of language design and software  
engineering can benefit existing and future domain-specific languages.


The ultimate goal of using DSLs is to improve programmer productivity  
and software quality. Often, this is achieved by reducing the cost of  
initial software development as well as maintenance costs. These  
improvements - programs being easier to write and maintain -  
materialize as a result of domain-specific guarantees, analyses,  
testing techniques, verification techniques, and optimizations.


   * Paper Criteria
Papers are sought addressing the research problems, fundamental  
principles, and practical techniques of DSLs, including but not  
limited to:
  - Foundations, including semantics, formal methods, type  
theory, and complexity theory
  - Language design, ranging from concrete syntax to semantic and  
typing issues
  - Software engineering, including domain analysis, software  
design, and round-trip engineering
  - Software processes, including metrics for software and  
language evaluation
  - Implementation techniques, including parsing, compiling, and  
program generation

  - Program analysis and automated transformation
  - Reverse engineering, re-engineering, design discovery,  
automated refactoring

  - Hardware/software codesign
  - Programming environments, including visual languages,  
debuggers, and testing infrastructure

  - Teaching DSLs and the use of DSLs in teaching
  - Case studies, including engineering, bioinformatics, hardware  
specification languages, parallel computing languages, real-time and  
embedded systems, and networked and distributed domains


Papers will be judged on the depth of their insight and the extent to  
which they translate specific experience into general lessons for  
domain-specific language designers and implementers, and software  
engineers. Papers can range from the practical to the theoretical;  
where appropriate, they should refer to actual languages, tools, and  
techniques, provide pointers to full definitions and implementations,  
and include empirical data on results.


   * Important Dates
  - December 14th, 2008: Abstract submission due. Firm, will not  
have any extensions
  - December 21st, 2008: Paper submission deadline. Firm, will  
not have any extensions

  - February 23rd, 2009: Author notification of decisions
  - March 22nd, 2009: Camera ready manuscripts due

   * Program Committee
  - Jon Bentley, Avayalabs
  - Martin Erwig, Oregon State University
  - Jeff Gray, University of Alabama at Birmingham
  - Robert Grimm, New York University
  - Jim Grundy, Intel Strategic CAD Labs
  - Tom Henzinger, EPFL
  - Sam Kamin, UIUC
  - Dick Kieburtz, Portland State University
  - Ralf Lämmel, University of Koblenz
  - Julia Lawall, University of Copenhagen
  - 

Re: [Haskell-cafe] Re: Bit Streams

2008-06-18 Thread Dominic Steinitz
Don Stewart wrote:
 dominic.steinitz:
 OK, so today I tried to write my first program using the Binary library. 
 And I've hit a snag: It appears the library will only handle data that 
 is byte-aligned. So if I try to write three Bool values, it uses three 
 bytes, not three bits.

 Before I sit down and spend 3 months designing my own library from 
 scratch, does anybody know of an existing library that allows you to do 
 what Binary does, but with single-bit precision? [I presume Binary is 
 byte-aligned for efficiency...]

 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict
 
 The bitsyntax library perhaps? or a StateT over Binary for carrying
 arround the bit packet to write.
 
 -- Don
 
 
The vagaries of gmane have made it appear that I asked the question. In
fact, Andrew Coppin asked the question and I responded with a pointer to
 the library Adam Langley pulled together.

Dominic.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Richard A. O'Keefe


On 18 Jun 2008, at 4:36 pm, Karoly Negyesi wrote:
(a) I would *never* want to use an implementation of closures like  
that.

Could you elaborate on a) ?


It wasn't me who wrote it, but consider
- non-local variables are *not* captured unless you explicitly
  hoist them into the lambda expression using the 'lexical' keyword.
- references to non-local variables that are not so hoisted are
  not syntax errors, they just quietly do something else.
- ordinary functions do not act as if defined by lambda expressions;
  'lexical' is required in lambdas and forbidden in functions.
- ordinary functions do not act as if defined by lambda expressions;
  the latter can outlive their lexical scope, the former can't.
- what you get is a reference to a variable (as you do in Scheme)
  but loop variables really are variables, not names for values,
  so lambdas created in different iterations of the same loop point
  so the same loop variable, and do not remember the value it had
  when they were created.  The proposal explains how to work around  
this.


All of this boils down to something in which you *can* with care do
the things you expect to do with closures, but the language gently
leads you to the edge of the Pit and the compiler just smiles quietly
as you fall over.






___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] blas bindings, why are they so much slower the C?

2008-06-18 Thread Richard A. O'Keefe


On 19 Jun 2008, at 4:16 am, Anatoly Yakovenko wrote:

C doesn't work like that :).  functions always get called.


Not true.  A C compiler must produce the same *effect* as if
the function had been called, but if by some means the compiler
knows that the function has no effect, it is entitled to skip
the call.  In particular, the C compiler I normally use offers
these pragmas, amongst others:

#pragma does_not_write_global_data (funcname [, funcname])
#pragma no_side_effect(funcname[, funcname])

So with a declaration like

extern double cblas_ddot(
int,
double const *, int,
double const *, int);
#pragma no_side_effect (cblas_ddot)



the compiler would be completely within its rights to discard
any call to cblas_ddot() whose result was not used.  (As it
happens, it didn't, but it would have been allowed to.)
If using gcc,

extern double cblas_ddot( ... as before ...)
__attribute__ ((const));

seems to have the same effect, certainly the test case I tried
did in fact completely eliminate a call to cblas_ddot() when
so declared.

Since the malloc() results pointed to uninitialised memory,
the C compiler was entitled to do anything it pleased anyway.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] type constructor confusion

2008-06-18 Thread Stephen Howard

Thanks Brandon, forgot to send my reply to the list:

Ok, so I am confusing things.  Good to know.  So my question is how do I 
fulfill this scenario?


- I have an action that might return either an HttpResponse or an 
HttpRequest, depending on if the IO in the action determined more work 
needed doing.  It's here, though I doubt it's correct yet:


requestHandler :: HttpRequest - IO HttpResponse
requestHandler request = do
  session - sessionHandler request
  ret - uriHandler request
  case ret of
  HttpResponse - ret
  HttpRequest  - resourceHandler session ret

uriHandler :: HttpRequest - IO HttpMessage
sessionHandler :: HttpRequest - IO HttpSession

I've given the uriHandler a signature of IO HttpMessage because the 
HttpMessage might be either an HttpResponse or an HttpRequest, and I 
don't know how I should be specifying that.  Ideas?


- Stephen

Brandon S. Allbery KF8NH wrote:


On Jun 18, 2008, at 15:31 , Stephen Howard wrote:

HttpMessage.hs:36:20: Not in scope: type constructor or class 
`HttpRequest'


The troublesome line is the definition of the cookie function at the 
end of the code.  I've made


Right.  HttpRequest is a data constructor associated with the type 
constructor HttpMessage.
(Data constructors are effectively functions; you used it in the 
context of a type, not a function name.)



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell's type system

2008-06-18 Thread Ryan Ingram
On 6/18/08, Edsko de Vries [EMAIL PROTECTED] wrote:
 Regarding type classes, I'm not 100% what the logical equivalent is,
 although one can regard a type such as

  forall a. Eq a = a - a

 as requiring a proof (evidence) that equality on a is decidable. Where
 this sits formally as a logic I'm not sure though.

You can take the minimalist view and treat a typeclass parameter as an
explicitly passed dictionary; that is:
   (Eq a = a - a)
is isomorphic to
   (a - a - Bool, a - a - Bool) - a - a

In fact, this is basically what GHC does.

You then treat an instance declaration:
   instance Eq Int where
  (==) = eqInt#
  (/=) = neqInt#
as just a constant
   Eq_Int = (eqInt#, neqInt#)

  -- ryan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] type constructor confusion

2008-06-18 Thread Ryan Ingram
It sounds like you need to split up your types a bit more.

data HttpRequest = HttpRequest ...

data HttpResponse = HttpResponse ...

data HttpMessage = MsgRequest HttpRequest | MsgResponse HttpResponse
-- alternatively
-- type HttpMessage = Either HttpRequest HttpResponse

Now you can have functions that take/return just an HttpRequest or
just an HttpResponse, as well as functions that use either one via
HttpMessage.  In the latter case, you do need to pattern match to
decide which one you have.

  -- ryan


On 6/18/08, Stephen Howard [EMAIL PROTECTED] wrote:
 Thanks Brandon, forgot to send my reply to the list:

 Ok, so I am confusing things.  Good to know.  So my question is how do I
 fulfill this scenario?

 - I have an action that might return either an HttpResponse or an
 HttpRequest, depending on if the IO in the action determined more work
 needed doing.  It's here, though I doubt it's correct yet:

 requestHandler :: HttpRequest - IO HttpResponse
 requestHandler request = do
  session - sessionHandler request
  ret - uriHandler request
  case ret of
  HttpResponse - ret
  HttpRequest  - resourceHandler session ret

 uriHandler :: HttpRequest - IO HttpMessage
 sessionHandler :: HttpRequest - IO HttpSession

 I've given the uriHandler a signature of IO HttpMessage because the
 HttpMessage might be either an HttpResponse or an HttpRequest, and I don't
 know how I should be specifying that.  Ideas?

 - Stephen

 Brandon S. Allbery KF8NH wrote:
 
  On Jun 18, 2008, at 15:31 , Stephen Howard wrote:
 
 
   HttpMessage.hs:36:20: Not in scope: type constructor or class
 `HttpRequest'
  
   The troublesome line is the definition of the cookie function at the end
 of the code.  I've made
  
 
  Right.  HttpRequest is a data constructor associated with the type
 constructor HttpMessage.
  (Data constructors are effectively functions; you used it in the context
 of a type, not a function name.)
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Gtk2Hs and GCs

2008-06-18 Thread Tim Newsham

I don't see a way to fetch an existing standard GC from a widget.
In other Gtk bindings I usually do this by fetching the widget's
style and then grabbing one of the gc's (such as fg_gc[STATE_NORMAL]).
In Gtk2Hs docs:
http://www.haskell.org/gtk2hs/docs/gtk2hs-docs-0.9.12/Graphics-UI-Gtk-General-Style.html
it looks like you can only get Colors, not the whole GC.
I can't seem to find any other way short of making a whole new GC
(as is done in Gtk2Hs/demos/graphic/Drawing.hs).  Am I missing
something?  Is there a reason the GC's arent retrievable?

Tim Newsham
http://www.thenewsh.com/~newsham/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] message passing style like in Haskell?

2008-06-18 Thread jinjing
Hi guys,

This is my second attempt to learn Haskell :)

Any way here's the code:

module Dot where
import Prelude hiding ( (.) )

(.) :: a - (a - b) - b
a . f = f a

infixl 9 .


So for example, 99 questions: Problem 10
(*) Run-length encoding of a list.



comparing:

encode xs = map (\x - (length x,head x)) (group xs)

to

encode xs = xs.group.map token where token x = (x.length, x.head)




I found starting with data and working my way to a solution seems to be
easier to think with, or maybe it's just me ...

What is your thought?

Jinjing
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe