[Haskell-cafe] Questions about slow GC with STArray

2009-04-06 Thread FFT
I've been following with interest the recent discussions on reddit
about the extremely slow hash tables in Haskell compared to F# and
OCaml, and as I understood it, this performance problem is caused by
GC not liking mutable arrays
http://hackage.haskell.org/trac/ghc/ticket/650

It appears from the discussion there that this is more than a simple
bug, but a fundamental difficulty (slow writes vs slow GC trade-off).
What I'm wondering though is how can this be unique to GHC: all arrays
in OCaml and probably F# are mutable (and usually unboxed). How is
this problem addressed there? Why is this supposed to be specific to
boxed arrays only: wouldn't GC have to scan the whole mutable array
whether it's boxed or unboxed?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation

2009-04-06 Thread Ketil Malde
Brandon S. Allbery KF8NH allb...@ece.cmu.edu writes:

 I wonder when we'll get a good haskell virtual package on Debian?

 What would this package do?

 Install ghc + all the little pieces of libghc6-cruft needed to get a
 sane working environment?

Sounds easy to do (after all, it's just an empty package with a bunch
of dependencies, right?), but I'm unsure exactly what pieces you want
included. 

This is the current ghc6 package:

  Provides: ghc, haskell-compiler, libghc6-array-dev, libghc6-base-dev, 
libghc6-bytestring-dev, libghc6-cabal-dev, libghc6-containers-dev, 
libghc6-directory-dev, libghc6-filepath-dev, libghc6-haskell98-dev, 
libghc6-hpc-dev, libghc6-old-locale-dev, libghc6-old-time-dev, 
libghc6-packedstring-dev, libghc6-pretty-dev, libghc6-process-dev, 
libghc6-random-dev, libghc6-readline-dev, libghc6-rts-dev, 
libghc6-template-haskell-dev, libghc6-unix-dev

In Ubuntu 8.10, there are 90 separate libghc6.*dev packages, which
ones do you think should be added to a GHC meta package?

-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] minor typo in The Haskell 98 Report

2009-04-06 Thread Benjamin L . Russell
Today, as I was reading through The Haskell 98 Report (see
http://www.haskell.org/onlinereport/), I came across a minor typo, but
it seems that the only way to fix such typos is to report them on one
of the Haskell mailing lists; viz.:

The original committees ceased to exist when the original Haskell 98 Reports 
were published, so every change was instead proposed to the entire Haskell 
mailing list.

Therefore, please allow me to report this typo, though minor, here, as
follows:

The Haskell 98 Report - Preface (see
http://www.haskell.org/onlinereport/preface-jfp.html), under the
heading Haskell 98: language and libraries, fourth paragraph, second
line:

If these program were to be portable, a set of libraries would have to be 
standardised too.

should be as follows:

If these programs were to be portable, a set of libraries would have to be 
standardised too.

(I.e., the word program should be plural.)

Is this the proper place to report any forthcoming similar typos?

-- Benjamin L. Russell
-- 
Benjamin L. Russell  /   DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile:  +011 81 80-3603-6725
Furuike ya, kawazu tobikomu mizu no oto. 
-- Matsuo Basho^ 

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


[Haskell-cafe] Re: [Haskell] [OT] Plural forms of the word octopus [Was: Re: Marketing Haskell]

2009-04-06 Thread ajb

[Shifted to haskell-cafe.]

G'day all.

Quoting Benjamin L.Russell dekudekup...@yahoo.com:


According to the Merriam-Webster Online Dictionary, it is topoi (see
http://www.merriam-webster.com/dictionary/topos).


Topoi form a certain class of category.  You can study topous, you can
prove theorems about topois and you can discover properties of topon.

(That last one is an omega, so it's pronounced more like top-own.)


Where did you find octoposi?


In my ancient copy of Liddell and Scott.  Here's the online entry:

http://tinyurl.com/ck8gst

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


Re: [Haskell-cafe] minor typo in The Haskell 98 Report

2009-04-06 Thread Malcolm Wallace


On 6 Apr 2009, at 08:56, Benjamin L.Russell wrote:


Today, as I was reading through The Haskell 98 Report (see
http://www.haskell.org/onlinereport/), I came across a minor typo, but
it seems that the only way to fix such typos is to report them on one
of the Haskell mailing lists;


Thanks for the bug report.  As noted on the page
http://haskell.org/haskellwiki/Language_and_library_specification

The report still has minor bugs. There are tracked at the Haskell 98  
bugs page. Report any new bugs to Malcolm Wallace.  (There are links  
for the bugs page, and for my email address.)


Regards,
Malcolm

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


Re: [Haskell-cafe] Questions about slow GC with STArray

2009-04-06 Thread Bulat Ziganshin
Hello FFT,

Monday, April 6, 2009, 11:07:33 AM, you wrote:

 this problem addressed there? Why is this supposed to be specific to
 boxed arrays only: wouldn't GC have to scan the whole mutable array
 whether it's boxed or unboxed?

you need to scan only boxes: if array just contains plain cpu-level
numbers, there is nothing to scan

one way to solve this problem is to make one `modified` bit per each 256
elements rather than entire array so GC will have to scan only
modified chunks

-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


Re: [Haskell-cafe] Questions about slow GC with STArray

2009-04-06 Thread FFT
On Mon, Apr 6, 2009 at 1:10 AM, Bulat Ziganshin
bulat.zigans...@gmail.com wrote:

 you need to scan only boxes: if array just contains plain cpu-level
 numbers, there is nothing to scan

Are those the only legal contents of STUArray?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Unary Minus

2009-04-06 Thread Paul Keir
If I use :info (-) I get information on the binary minus. Is unary minus
also a function?

Thanks,

Paul

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


Re: [Haskell-cafe] Questions about slow GC with STArray

2009-04-06 Thread Dan Doel
On Monday 06 April 2009 4:10:43 am Bulat Ziganshin wrote:
 one way to solve this problem is to make one `modified` bit per each 256
 elements rather than entire array so GC will have to scan only
 modified chunks

For reference, I constructed a benchmark that takes advantage of GHC's tagging 
of whole arrays to approximate this:

http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3316

Since each array has a dirty bit, making a type that stores an array of arrays 
that add up to the desired size is similar to having a dirty bit for chunks 
the size of the sub-array. The test then fills a 10 million element array.

However, something about the benchmark makes it perform poorly for both small 
chunks and large chunks. -sstderr reports that lots of copying occurs for 
small chunk sizes, and I haven't bothered to figure out why this is the case. 
You can, however, see that marking dirty chunks in this fashion would be 
profitable. The un-chunked array takes around a minute here, while with chunks 
of 10,000 (which seems to be about the optimal value with the above copying 
tradeoff), it takes about 6 seconds, and that's still with 60+% GC time.

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


Re: [Haskell-cafe] Unary Minus

2009-04-06 Thread Wouter Swierstra
If I use :info (-) I get information on the binary minus. Is unary  
minus also a function?


You can define it yourself or use negate from the Prelude.

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


Re: [Haskell-cafe] Unary Minus

2009-04-06 Thread Martijn van Steenbergen

Paul Keir wrote:
If I use :info (-) I get information on the binary minus. Is unary minus 
also a function?


No, as far as I know the unary minus is part of the number literals. You 
can use negate if you want it as a function.


Hope this helps,

Martijn.

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


Re[2]: [Haskell-cafe] Questions about slow GC with STArray

2009-04-06 Thread Bulat Ziganshin
Hello Dan,

Monday, April 6, 2009, 12:35:14 PM, you wrote:

 the size of the sub-array. The test then fills a 10 million element array.

 However, something about the benchmark makes it perform poorly for both small
 chunks and large chunks. -sstderr reports that lots of copying occurs for
 small chunk sizes, and I haven't bothered to figure out why this is the case.
 You can, however, see that marking dirty chunks in this fashion would be
 profitable. The un-chunked array takes around a minute here, while with chunks
 of 10,000 (which seems to be about the optimal value with the above copying
 tradeoff), it takes about 6 seconds, and that's still with 60+% GC time.

i don't think that 60% GC time is bad for *this* benchmark. array
filling is very trivial operation, after all. important part is 10x GC
times reduce, apply these numbers to original benchmark

-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


Re[2]: [Haskell-cafe] Questions about slow GC with STArray

2009-04-06 Thread Bulat Ziganshin
Hello FFT,

Monday, April 6, 2009, 12:32:53 PM, you wrote:

 you need to scan only boxes: if array just contains plain cpu-level
 numbers, there is nothing to scan

 Are those the only legal contents of STUArray?

numbers, chars, vanilla pointers. UArray just mimics C arrays, after all


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


Re: [Haskell-cafe] high probability of installation problems andquality of the glorious implementation

2009-04-06 Thread Claus Reinke

I want the Zen package:  Make me one with everything.


But would you find that on hackage?-) If an author had contemplated
the perfect package, they wouldn't have put it on hackage, they wouldn't
have a hackage account, they wouldn't have written the package, they
might not even exist - you would just get the idea.

Claus

(inspired by the ZenBot entry in the list of programs that play on
the computer Go server: http://senseis.xmp.net/?ComputerGoServer )


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


[Haskell-cafe] Re: Unary Minus

2009-04-06 Thread Benjamin L . Russell
On Mon, 6 Apr 2009 12:13:09 +0200, Roel van Dijk
vandijk.r...@gmail.com wrote:

On Mon, Apr 6, 2009 at 12:04 PM, Benjamin L.Russell
dekudekup...@yahoo.com wrote:
 Interesting. ?How is this hack implemented?

This seems to be the relevant grammar:
  lexp6 - - exp7
  lpat6 - - (integer | float)(negative literal)

The '6's and the '7' are superscripts.
Perhaps the hack is in the precedence of the expression in which an
unary minus is allowed.

Yes, I see it now.  It's under 9.5  Context-Free Syntax, instead of
being under 9.2  Lexical Syntax, so it's a syntactic rule, rather
than a lexical rule.

According to the rule, a left-expression of precedence level 6
consists of '-' followed by an expression of precedence level 7, and
a left-pattern of precedence level 6 consists of '-' followed by
(an integer or a float), and by definition, this is a negative
literal.  Integers and floats, in turn, are part of the lexical
syntax.

-- Benjamin L. Russell
-- 
Benjamin L. Russell  /   DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile:  +011 81 80-3603-6725
Furuike ya, kawazu tobikomu mizu no oto. 
-- Matsuo Basho^ 

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


[Haskell-cafe] Re: Unary Minus

2009-04-06 Thread Benjamin L . Russell
On Mon, 6 Apr 2009 12:13:09 +0200, Roel van Dijk
vandijk.r...@gmail.com wrote:

On Mon, Apr 6, 2009 at 12:04 PM, Benjamin L.Russell
dekudekup...@yahoo.com wrote:
 Interesting. ?How is this hack implemented?

This seems to be the relevant grammar:
  lexp6 - - exp7
  lpat6 - - (integer | float)(negative literal)

The '6's and the '7' are superscripts.
Perhaps the hack is in the precedence of the expression in which an
unary minus is allowed.

What's interesting are the following definitions of the functions '-'
(binary minus) and negate given in 8  Standard Prelude (see
http://www.haskell.org/onlinereport/standard-prelude.html#$tNum):

class  (Eq a, Show a) = Num a  where
(+), (-), (*):: a - a - a
negate   :: a - a
abs, signum  :: a - a
fromInteger  :: Integer - a

-- Minimal complete definition:
--  All, except negate or (-)
x - y=  x + negate y
negate x =  0 - x

The type of negate, a - a, where a is a Num, is precisely what is
needed for a unary minus.

-- Benjamin L. Russell
-- 
Benjamin L. Russell  /   DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile:  +011 81 80-3603-6725
Furuike ya, kawazu tobikomu mizu no oto. 
-- Matsuo Basho^ 

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


Re: [Haskell-cafe] Unary Minus

2009-04-06 Thread Lennart Augustsson
Unary minus is a hack in the syntax for allowing the function negate
to be written as prefix -.

On Mon, Apr 6, 2009 at 10:36 AM, Martijn van Steenbergen
mart...@van.steenbergen.nl wrote:
 Paul Keir wrote:

 If I use :info (-) I get information on the binary minus. Is unary minus
 also a function?

 No, as far as I know the unary minus is part of the number literals. You can
 use negate if you want it as a function.

 Hope this helps,

 Martijn.

 ___
 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: Unary Minus

2009-04-06 Thread Roel van Dijk
On Mon, Apr 6, 2009 at 12:04 PM, Benjamin L.Russell
dekudekup...@yahoo.com wrote:
 Interesting.  How is this hack implemented?

This seems to be the relevant grammar:
  lexp6 - - exp7
  lpat6 - - (integer | float)(negative literal)

The '6's and the '7' are superscripts.
Perhaps the hack is in the precedence of the expression in which an
unary minus is allowed.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] EclipseFP proposal for Google Summer of Code

2009-04-06 Thread Neil Mitchell
Hi Thomas,

 I send this e-mail because of possible scheduling issues: I will be
 away starting on April 15. So, if you want to ask me things, have
 suggestions for improvement, or want to do an interview or something,
 this can only be done *before* that date.

I am pretty sure all the questions from Haskell will be asked in the
next few days, so I wouldn't worry - although usually there aren't
any.

 P.S. I hope it's okay that I post this to the haskell-cafe list as
 well; since haskell.org has no GSoC-specific mailing list, it seems to
 be the most appropriate place that I could find.

We discuss SoC stuff on haskell-cafe so it's fine.

Thanks

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


Re[4]: [Haskell-cafe] Questions about slow GC with STArray

2009-04-06 Thread Bulat Ziganshin
Hello FFT,

Monday, April 6, 2009, 12:56:51 PM, you wrote:

 Are those the only legal contents of STUArray?

 numbers, chars, vanilla pointers. UArray just mimics C arrays, after all


 I haven't gotten to learning about them in detail yet, but my hope was
 that STUArray was like vectorT  in C++, and STArray was like
 vectorT*. Both are fairly general.

well, that's good comparison for some degree, but the catch is that
Haskell doesn't have unboxed types at all. therefore, [ST]UArray is
something that you can't implement in pure Haskell, it's just like
providing API to some C arrays. they are implemented via special
operations in GHC runtime that are limited to support only
numbers/chars/pointers. so you can't have UArray of Complex numbers
(although you can use two array of Doubles of course)

UArray is rather old thing, nowadays you may use StorableArray or one
of many newer array/vector libraries. unfortunately, they tend to
don't support ST monad, so you will need to write a little wrappers
using unsafeIOtoST operation

 So if I need a array of complex numbers in Haskell, will I need an
 extra level of indirection compared to C? And in addition to that some
 serious issues with GC speed if those arrays need to be mutable?

[1] http://haskell.org/haskellwiki/Library/ArrayRef
[2] http://www.haskell.org/haskellwiki/Storable_Vector

recent cafe threads
http://www.haskell.org/pipermail/haskell-cafe/2008-July/045229.html
http://www.haskell.org/pipermail/haskell-cafe/2009-March/057240.html

-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


Re: Re[2]: [Haskell-cafe] Questions about slow GC with STArray

2009-04-06 Thread FFT
On Mon, Apr 6, 2009 at 1:49 AM, Bulat Ziganshin
bulat.zigans...@gmail.com wrote:

 Are those the only legal contents of STUArray?

 numbers, chars, vanilla pointers. UArray just mimics C arrays, after all


I haven't gotten to learning about them in detail yet, but my hope was
that STUArray was like vectorT  in C++, and STArray was like
vectorT*. Both are fairly general.

So if I need a array of complex numbers in Haskell, will I need an
extra level of indirection compared to C? And in addition to that some
serious issues with GC speed if those arrays need to be mutable?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Unary Minus

2009-04-06 Thread Benjamin L . Russell
Interesting.  How is this hack implemented?

I just checked the BNF grammar for the lexical syntax of Haskell in
The Haskell 98 Language Report (see the BNF grammer given under 9.2
Lexical Syntax under 9  Syntax Reference at
http://www.haskell.org/onlinereport/syntax-iso.html), but had
difficulty in deriving a unary minus.

Could somebody please enlighten me on how to derive the expression
-1 (a unary minus followed the the ascDigit 1) from the
above-mentioned BNF grammar?  Or is a unary minus not part of this
grammar?

-- Benjamin L. Russell

On Mon, 6 Apr 2009 11:14:52 +0200, Lennart Augustsson
lenn...@augustsson.net wrote:

Unary minus is a hack in the syntax for allowing the function negate
to be written as prefix -.

On Mon, Apr 6, 2009 at 10:36 AM, Martijn van Steenbergen
mart...@van.steenbergen.nl wrote:
 Paul Keir wrote:

 If I use :info (-) I get information on the binary minus. Is unary minus
 also a function?

 No, as far as I know the unary minus is part of the number literals. You can
 use negate if you want it as a function.

 Hope this helps,

 Martijn.

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

-- 
Benjamin L. Russell  /   DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile:  +011 81 80-3603-6725
Furuike ya, kawazu tobikomu mizu no oto. 
-- Matsuo Basho^ 

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


[Haskell-cafe] Paper: Translating donotation to SQL, Leijden, Meijer

2009-04-06 Thread GüŸnther Schmidt

Hi all,

is the paper Translating donotation to SQL, Leijden, Meijer (1999) 
available anywhere?


Günther

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


[Haskell-cafe] replicateM should be called mreplicate?

2009-04-06 Thread Sjoerd Visscher

Considering these naming conventions:
http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html#3

• A postfix 'M' always stands for a function in the Kleisli category:  
The monad type constructor m is added to function results (modulo  
currying) and nowhere else. So, for example,


  filter  ::  (a -   Bool) - [a] -   [a]
  filterM :: (Monad m) = (a - m Bool) - [a] - m [a]

• A postfix '_' changes the result type from (m a) to (m ()). Thus,  
for example:


  sequence  :: Monad m = [m a] - m [a]
  sequence_ :: Monad m = [m a] - m ()

• A prefix 'm' generalizes an existing function to a monadic form.  
Thus, for example:


  sum  :: Num a   = [a]   - a
  msum :: MonadPlus m = [m a] - m a

replicateM has the following type:

  replicateM :: Monad m = Int - m a - m [a]

Am I missing something or should this have been called mreplicate?

greetings,
--
Sjoerd Visscher
sjo...@w3future.com___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Combining sequences

2009-04-06 Thread michael rice
I downloaded it and it appears more complicated than just adding files to a 
directory. There's a setup and a build, and no assurances it will work with 
Hugs.

I think I'll wait for more information.

Michael

--- On Mon, 4/6/09, Thomas Hartman tphya...@gmail.com wrote:

From: Thomas Hartman tphya...@gmail.com
Subject: Re: [Haskell-cafe] Combining sequences
To: michael rice nowg...@yahoo.com
Cc: Henning Thielemann lemm...@henning-thielemann.de, 
haskell-cafe@haskell.org
Date: Monday, April 6, 2009, 12:26 AM

It's not in hugs, nor in ghc.

It's just in hackage. However, by the looks of it, you should probably
be able to use it in hugs. I didn't actually check this, but the cabal
file didn't name any fancy extensions, so it looks pretty
cross-compiler.

You can just go to

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utility-ht-0.0.4

wget 
http://hackage.haskell.org/packages/archive/utility-ht/0.0.4/utility-ht-0.0.4.tar.gz

untar

and put them with the rest of the files your hugs compiler uses for
package import. (I don't actually know how package installation works
in hugs... isn't it just put the files into a dir?)

thomas.

2009/4/5 michael rice nowg...@yahoo.com:
 Thanks. It looks like mergeBy will do the job, but is it available in Hugs?

 Michael


 --- On Sun, 4/5/09, Henning Thielemann lemm...@henning-thielemann.de
 wrote:

 From: Henning Thielemann lemm...@henning-thielemann.de
 Subject: Re: [Haskell-cafe] Combining sequences
 To: michael rice nowg...@yahoo.com
 Cc: haskell-cafe@haskell.org
 Date: Sunday, April 5, 2009, 9:09 PM


 On Sat, 4 Apr 2009, michael rice wrote:

 Is there a simple way to combine two sequences that are in ascending order
 into a single
 sequence that's also in ascending order? An example would be the squares
 [1,4,9,16,25..]
 combined with the cubes [1,8,27,64,125..] to form [1,1,4,8,9,16,25,27..].

 http://hackage.haskell.org/packages/archive/utility-ht/0.0.4/doc/html/Data-List-HT.html#v%3AmergeBy


 ___
 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: Haskell EDSL to generate SQL?

2009-04-06 Thread Jeremy Shaw
At Sun, 05 Apr 2009 14:32:21 +0200,
GüŸnther Schmidt wrote:

 What is the best resource to look for more detail examples?

No idea. I have not used it in years. And, last I checked, it is far
from perfect. For example, I believe that field names must be unique
across all tables.

Also, there was a project, coddfish that may be of interest.

http://wiki.di.uminho.pt/twiki/bin/view/Research/PURe/CoddFish

I think it provides a more direct mapping to SQL.

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


[Haskell-cafe] Infix tuple comma query (,)

2009-04-06 Thread Paul Keir
module Main where

 

data (:%^) a b = a :%^ bderiving (Show)

 

main = do

  print $ 18 :%^ (Just 99)

  print $ (,) 9 10

  print $ 9 , 10

 

The last line in the code above causes a compile error.

Why does infix use of the comma (tuple constructor?) function fail
without brackets?

 

Thanks,

Paul

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


Re: [Haskell-cafe] Combining sequences

2009-04-06 Thread Daniel Fischer
Am Montag 06 April 2009 17:12:42 schrieb michael rice:
 I downloaded it and it appears more complicated than just adding files to a
 directory. There's a setup and a build, and no assurances it will work with
 Hugs.

 I think I'll wait for more information.

 Michael

Try installing it with Cabal:

./Setup.lhs configure --hugs

if that doesn't say otherwise, chances are that it will work, so try

./Setup.lhs build
sudo ./Setup.lhs install

If it doesn't work, you can copy the code from Data.List.HT
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Infix tuple comma query (,)

2009-04-06 Thread Daniel Fischer
Am Montag 06 April 2009 17:53:24 schrieb Paul Keir:
 module Main where



 data (:%^) a b = a :%^ bderiving (Show)



 main = do

   print $ 18 :%^ (Just 99)

   print $ (,) 9 10

   print $ 9 , 10



 The last line in the code above causes a compile error.

 Why does infix use of the comma (tuple constructor?) function fail
 without brackets?


Tuples are special baked-in syntax. The parentheses are part of the tuple 
constructor(s).
It may be confusing you that you can use it prefix as well as aroundfix.



 Thanks,

 Paul

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


[Haskell-cafe] ANN: SVGFonts 0.1

2009-04-06 Thread Tillmann Vogt

I hereby publish my first library in Haskell.

SVGFonts 0.1

It parses the pretty unknown SVG Font format to produce outlines of 
characters. The big advantage of this format is that it is XML, which 
means easy parsing and manipulating. Because I haven't found any 
svg-files on the Internet the typical way is to convert a more popular 
format (i.e. .ttf) into SVG Font via fontforge.


This library may be useful if you want to have a direct access to 
specific algorithms which is of course harder when using a binding (i.e. 
Jeff Heards FTGL binding). The speed is improvable (see TO DO list) and 
since since this is my first library there might some errors which I am 
not aware of (please tell me). I also wonder why the library doesn't 
appear under graphics on hackage, although there is   Category: Graphics 
in my cabal file.


Depending on which library I like more, I will maybe integrate SVGFonts 
into LambdaCube or Fieldtrip


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


Re: [Haskell-cafe] ANN: SVGFonts 0.1

2009-04-06 Thread John Van Enk
This sounds very cool. Is is just a program, or is there a library sitting
behind it? From your .cabal file, it seems to be just a binary program.

Is this correct?

http://hackage.haskell.org/packages/archive/SVGFonts/0.1/SVGFonts.cabal

On Mon, Apr 6, 2009 at 1:22 PM, Tillmann Vogt
tillmann.v...@rwth-aachen.dewrote:

 I hereby publish my first library in Haskell.

 SVGFonts 0.1

 It parses the pretty unknown SVG Font format to produce outlines of
 characters. The big advantage of this format is that it is XML, which means
 easy parsing and manipulating. Because I haven't found any svg-files on the
 Internet the typical way is to convert a more popular format (i.e. .ttf)
 into SVG Font via fontforge.

 This library may be useful if you want to have a direct access to specific
 algorithms which is of course harder when using a binding (i.e. Jeff Heards
 FTGL binding). The speed is improvable (see TO DO list) and since since this
 is my first library there might some errors which I am not aware of (please
 tell me). I also wonder why the library doesn't appear under graphics on
 hackage, although there is   Category: Graphics in my cabal file.

 Depending on which library I like more, I will maybe integrate SVGFonts
 into LambdaCube or Fieldtrip

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




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


Re: [Haskell-cafe] replicateM should be called mreplicate?

2009-04-06 Thread David Menendez
On Mon, Apr 6, 2009 at 10:02 AM, Sjoerd Visscher sjo...@w3future.com wrote:
 Considering these naming conventions:
 http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html#3

 • A postfix 'M' always stands for a function in the Kleisli category: The
 monad type constructor m is added to function results (modulo currying) and
 nowhere else. So, for example,

  filter  ::              (a -   Bool) - [a] -   [a]
  filterM :: (Monad m) = (a - m Bool) - [a] - m [a]

 • A postfix '_' changes the result type from (m a) to (m ()). Thus, for
 example:

  sequence  :: Monad m = [m a] - m [a]
  sequence_ :: Monad m = [m a] - m ()

 • A prefix 'm' generalizes an existing function to a monadic form. Thus, for
 example:

  sum  :: Num a       = [a]   - a
  msum :: MonadPlus m = [m a] - m a

 replicateM has the following type:

  replicateM :: Monad m = Int - m a - m [a]

 Am I missing something or should this have been called mreplicate?

Not necessarily. If you use replicateM in the identity monad, you get
replicate. Similarly with filterM and filter, or foldM and foldl.

In contrast, msum and sum are essentially mconcat specialized to the
monoids (mplus, mzero) and ((+), 0), respectively.

Of course, this suggests that mfix should be fixM, so perhaps a better
distinction is that mplus and mfix need to be defined per-monad,
whereas filterM and replicateM are generic.

-- 
Dave Menendez d...@zednenem.com
http://www.eyrie.org/~zednenem/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] community.haskell.org unreachable?

2009-04-06 Thread Andrew Wagner
Works for me. The admin address referenced there is support [AT]
community.haskell.org

On Mon, Apr 6, 2009 at 1:32 PM, Claus Reinke claus.rei...@talk21.comwrote:

 I seem to be having problems reaching anything on that server.
 Does anyone know what is going on, or who to contact? It would
 help if the haskellwiki page

 http://www.haskell.org/haskellwiki/Haskell.org_domain

 would mention the admin address directly, instead of referring to

 http://community.haskell.org/admin/
 which is also unreachable.

 Claus

 ___
 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] ANN: SVGFonts 0.1

2009-04-06 Thread Max Rabkin
On Mon, Apr 6, 2009 at 7:32 PM, Tillmann Vogt
tillmann.v...@rwth-aachen.de wrote:
 It is a real library made of pure Haskell. What is wrong with my .cabal
 file?

The issue is not about whether it is pure Haskell. You have simply
marked it up as an executable rather than a library.

Executable Fonts
  Main-is:test/Fonts.hs
  Build-Depends:  haskell98, base, OpenGL, GLUT, xml, parsec

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


Re: [Haskell-cafe] Making videos of your project

2009-04-06 Thread Claus Reinke

Btw, there seem to be many Haskells on YouTube - should we have
some way of marking clips related to our Haskell? I've used haskell.org
as a tag, but noone else has, yet - also, perhaps there should be a Haskell 
channel or something?


And just in case there are others on the same Windows adventure:-)


Is there anyone here with experience in screencasting of text-based
applications, who could offer advice on how to produce screencasts
on windows/xp? The basic screencasting (capture+annotation/editing)
is not the problem, eg, CamStudio seems ok, and Wink gives me
more control for mostly input-driven sessions (where I want
screenshots whenever something useful happens, not long videos of
my mousepointer wavering about the screen;-). Both can generate .swf.

..
I think making .swf is a mistake, but I'm not sure.


I should have believed you there!-) I did actually check that Youtube
listed .swf among its supported file types before making my screencast,
but when I had actually joined and uploaded, I discovered that it would
fail on conversion.. More detailed search in the user forums indicated
that this is a common problem, with no solution other than to convert
to another, video- rather than animation-based, format.

Problem is, .swf is very suited to this particular input-driven kind of
screencast (and renders just fine in my browser), eg, Wink has a 
non-video capture mode that only adds frames when something happens

(the only negative: while one can extend the time frames are shown, I've
not yet found a way to reduce the minimum time, so typing looks rather
unnaturally ssllooww). 

Any attempt to convert my just over 1Mb .swf files (one screencast, 
split and edited into 3 sections of 4 minutes or less) to something 
listed as supported (such as .avi, .mpeg2) resulted in huge files sizes 
(60Mb and upwards) that would be impractical to upload with my 
old narrowband connection (might just be that I don't have the right

compressing codecs for these formats?).

Fortunately, while trying to find some way of contacting YT staff, I
stumbled on other help pages that mentioned .wmv in their version
of supported file types. For that, one of the codecs on my machine
produces files that are only 10x the size of the original .swf, so I'm
slowly uploading them to YT, and the first two parts have now been
published without conversion failure.

I was sorely tempted just to upload the small .swfs to haskell.org, 
instead of the .wnk-.swf(1Mb)-.avi(60Mb)-.wmf(10Mb) plus
tedious upload route I had to follow with the free or preinstalled tools 
available to me. But community.haskell.org seems to be having

enough trouble right now, without hosting clips there..


I rendered it in 2 or 3 formats (at 640x480 etc, following the you tube
/ google video recommendations), and uploaded the one that looked best.
You-tube immediately(ish) makes a low quality version available
(320x240?), and a high quality version(480x360?), with more readable
text etc, is available a little later.


Testing with multiple formats/codecs/uploads is recommended,
though the conversion can be somewhat nightmarish (too many options
and tools, many of which look less than trustworthy, too complex, too
expensive, or all of the above; and too few roads to something that 
works). For 640x400 uploads, the near immediately available version 
seems readable enough (search for tag haskell.org or wait for the 
announcement;-).



I would recommend working in a 640x480 screen area. If you can't show
anything in that area, then people won't be able to see anything in your
video (at the size/quality youtube shows it, at least).


Sound advice, which I followed in the end. Just took some more
preparation to find a setup that would fit the screencast, rather than
my usual working habits. I also noticed that I had somehow managed 
to switch off my ClearType support, which explained the initially low

quality font rendering.

Thanks,
Claus

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


[Haskell-cafe] Ghc: -O harmful?

2009-04-06 Thread Petr Skovron

 Hello all,

 I have a haskell program that runs an order of magnitude slower
when compiled with optimisations turned on.  This happens on 6.8.2
as well as 6.10.1:


p...@r4at184:/tmp[1]% ghc --make -fforce-recomp -o out buga.hs   
[1 of 1] Compiling Main ( buga.hs, buga.o )
Linking out ...
p...@r4at184:/tmp% time ./out  3-med.in |/dev/null
./out  3-med.in | /dev/null  0,03s user 0,00s system 99% cpu 0,038 total

p...@r4at184:/tmp% ghc --make -fforce-recomp -o out buga.hs -O
[1 of 1] Compiling Main ( buga.hs, buga.o )
Linking out ...
p...@r4at184:/tmp% time ./out  3-med.in |/dev/null
./out  3-med.in | /dev/null  0,99s user 0,01s system 99% cpu 1,001 total

p...@r4at184:/tmp[1]% ghc --make -fforce-recomp -o out buga.hs -O2
[1 of 1] Compiling Main ( buga.hs, buga.o )
Linking out ...
p...@r4at184:/tmp% time ./out  3-med.in |/dev/null
./out  3-med.in | /dev/null  0,99s user 0,01s system 99% cpu 1,004 total

p...@r4at184:/tmp% ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.8.2


psxx:/tmp$ ghc --make -fforce-recomp -o out buga.hs   
[1 of 1] Compiling Main ( buga.hs, buga.o )
Linking out ...
psxx:/tmp$ time ./out  3-med.in |/dev/null
real0m0.028s
user0m0.011s
sys 0m0.007s

psxx:/tmp$ ghc --make -fforce-recomp -o out buga.hs -O
[1 of 1] Compiling Main ( buga.hs, buga.o )
Linking out ...
psxx:/tmp$ time ./out  3-med.in |/dev/null
real0m0.252s
user0m0.225s
sys 0m0.011s

psxx:/tmp$ ghc --make -fforce-recomp -o out buga.hs -O2
[1 of 1] Compiling Main ( buga.hs, buga.o )
Linking out ...
Vazeny pane, cekam na Vase rozkazy.
psxx:/tmp$ time ./out  3-med.in |/dev/null
real0m0.239s
user0m0.225s
sys 0m0.010s

psxx:/tmp$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.10.1


The GHC documentation states that

 -O2:
 Means: Apply every non-dangerous optimisation, even if it means
 significantly longer compile times.  The avoided dangerous
 optimisations are those that can make runtime or space worse if
 you're unlucky. They are normally turned on or off individually.

If I understand this correctly, the dangerous optimisations should not
be performed with -O.  Am I doing anything wrong?  Am I hitting a bug
in GHC optimiser? A known one?


 The program source:

--
p...@r4at184:/tmp$ cat buga.hs 
{-# LANGUAGE FlexibleContexts #-}

import Control.Monad
import Control.Monad.State

data Predpoc a = Nic | Kus { delka :: Int,
 levy :: Predpoc a,
 pravy :: Predpoc a }
  deriving Show

gList i = Kus 1 Nic Nic

gPredpoc kus1 kus2 =
  Kus (delka kus1 + delka kus2)
  kus1 kus2


pop :: MonadState [a] m = m a
pop = get = \(x:xs) - put xs  return x

mbuild :: MonadState [Int] m = Int - m (Predpoc Int)
mbuild 1 = gList `liftM` pop
mbuild n = liftM2 gPredpoc (mbuild n1) (mbuild n2)
  where n1 = n`div`2
n2 = n - n1

build n li = evalState (mbuild n) li

best :: Predpoc Int - Int - Int - Int
best kus i j
  | i == 1  j == delka kus
= delka kus
  | j = del1   = best (levy kus) i j
  | i  del1= best (pravy kus) (i-del1) (j-del1)
  | otherwise   = best (levy kus) i del1 +
  best (pravy kus) 1 (j-del1)
  where
del1 = delka (levy kus)

main = do
  n - read `liftM` getLine
  pole - liftM (build n . map read . words) getLine
  replicateM_ 100 $ do
getLine
print $ best pole 42 420
--

 The sample input file (30k) can be downloaded from
http://pikomat.mff.cuni.cz/petr/3-med.in

 I suspect that the main's variable pole (which is a large
binary tree of type Predpoc Int) may be built from scratch in each
iteration of the replicateM_ loop.

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


Re: [Haskell-cafe] ANN: SVGFonts 0.1

2009-04-06 Thread John Van Enk
What your cabal file describes is a single executable,

Executable Fonts
 main-is: tests/Fonts.hs

This just tells us to build the file tests/Fonts.hs into a single executable
named 'Fonts'. You probably want to retructure your project a bit into
something like this.

./LICENSE
./README
./Setup.hs
./src
./src/SVGFonts
./src/SVGFonts/KETTriangulation.hs
./src/SVGFonts/PointOfView.hs
./src/SVGFonts/ReadFont.hs
./SVGFonts.cabal
./test
./test/Fonts.hs
./test/GirlsareWeird.svg
./test/LinLibertineO.svg
./test/Scriptin.svg
./TODO
Here's what your cabal file should probably look like:

Name: SVGFonts
Version:  0.1
Description:  parse svg-font files and generate outlines of letters and
sentences
License:  GPL
License-file: LICENSE
Author:   Tillmann Vogt
Maintainer:   tillmann.v...@rwth-aachen.de
Build-Type:   Simple
Cabal-Version:=1.2
library
build-depends:
haskell98,
base,
OpenGL,
GLUT,
xml,
parsec
exposed-modules:
SVGFonts.KETTriangulation
SVGFonts.PointOfView
SVGFonts.ReadFont

That isn't exact, but it should be close.

/jve


On Mon, Apr 6, 2009 at 1:32 PM, Tillmann Vogt
tillmann.v...@rwth-aachen.dewrote:

 John Van Enk schrieb:

 This sounds very cool. Is is just a program, or is there a library sitting
 behind it? From your .cabal file, it seems to be just a binary program.

 Is this correct?

 http://hackage.haskell.org/packages/archive/SVGFonts/0.1/SVGFonts.cabal

 On Mon, Apr 6, 2009 at 1:22 PM, Tillmann Vogt
 tillmann.v...@rwth-aachen.dewrote:



 It is a real library made of pure Haskell. What is wrong with my .cabal
 file?




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


Re: [Haskell-cafe] replicateM should be called mreplicate?

2009-04-06 Thread Luke Palmer
On Mon, Apr 6, 2009 at 11:42 AM, David Menendez d...@zednenem.com wrote:

 Of course, this suggests that mfix should be fixM, so perhaps a better
 distinction is that mplus and mfix need to be defined per-monad,
 whereas filterM and replicateM are generic.


Don't you think that is an incidental distinction, not an essential one?  It
would be like naming our favorite operations mbind and joinM, just because
of the way we happened to write the monad class.

Luke




 --
 Dave Menendez d...@zednenem.com
 http://www.eyrie.org/~zednenem/ http://www.eyrie.org/%7Ezednenem/
 ___
 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] ANN: SVGFonts 0.1

2009-04-06 Thread Tillmann Vogt

John Van Enk schrieb:

This sounds very cool. Is is just a program, or is there a library sitting
behind it? From your .cabal file, it seems to be just a binary program.

Is this correct?

http://hackage.haskell.org/packages/archive/SVGFonts/0.1/SVGFonts.cabal

On Mon, Apr 6, 2009 at 1:22 PM, Tillmann Vogt
tillmann.v...@rwth-aachen.dewrote:




It is a real library made of pure Haskell. What is wrong with my .cabal 
file?

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


[Haskell-cafe] community.haskell.org unreachable?

2009-04-06 Thread Claus Reinke

I seem to be having problems reaching anything on that server.
Does anyone know what is going on, or who to contact? It would
help if the haskellwiki page

http://www.haskell.org/haskellwiki/Haskell.org_domain

would mention the admin address directly, instead of referring to

http://community.haskell.org/admin/ 


which is also unreachable.

Claus

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


[Haskell-cafe] cabal haddock and Paths_Xxx

2009-04-06 Thread Martijn van Steenbergen

Hello,

cabal generates a Paths_Xxx file for me which I import and use, but 
cabal haddock doesn't seem to like it much.


If I don't specify the generated module at all in my cabal file, cabal 
haddock generates visible documentation for the module, which is not 
what I want: the module should stay internal.


If I specify it in either Exposed-Modules or Other-Modules, 'cabal 
configure; cabal haddock' fails with:



cabal: can't find source for Paths_Xxx in ., dist/build/autogen


While 'cabal configure; cabal build; cabal haddock' fails with:


cabal: can't find source for module Paths_Xxx


Can I have the best of both, i.e. generate docs without problems and use 
the generated module?


Thanks,

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


Re: [Haskell-cafe] Ghc: -O harmful?

2009-04-06 Thread Don Stewart
-fno-state-hack?

xofon:
 
  Hello all,
 
  I have a haskell program that runs an order of magnitude slower
 when compiled with optimisations turned on.  This happens on 6.8.2
 as well as 6.10.1:
 
 
 p...@r4at184:/tmp[1]% ghc --make -fforce-recomp -o out buga.hs   
 [1 of 1] Compiling Main ( buga.hs, buga.o )
 Linking out ...
 p...@r4at184:/tmp% time ./out  3-med.in |/dev/null
 ./out  3-med.in | /dev/null  0,03s user 0,00s system 99% cpu 0,038 total
 
 p...@r4at184:/tmp% ghc --make -fforce-recomp -o out buga.hs -O
 [1 of 1] Compiling Main ( buga.hs, buga.o )
 Linking out ...
 p...@r4at184:/tmp% time ./out  3-med.in |/dev/null
 ./out  3-med.in | /dev/null  0,99s user 0,01s system 99% cpu 1,001 total
 
 p...@r4at184:/tmp[1]% ghc --make -fforce-recomp -o out buga.hs -O2
 [1 of 1] Compiling Main ( buga.hs, buga.o )
 Linking out ...
 p...@r4at184:/tmp% time ./out  3-med.in |/dev/null
 ./out  3-med.in | /dev/null  0,99s user 0,01s system 99% cpu 1,004 total
 
 p...@r4at184:/tmp% ghc --version
 The Glorious Glasgow Haskell Compilation System, version 6.8.2
 
 
 psxx:/tmp$ ghc --make -fforce-recomp -o out buga.hs   
 [1 of 1] Compiling Main ( buga.hs, buga.o )
 Linking out ...
 psxx:/tmp$ time ./out  3-med.in |/dev/null
 real  0m0.028s
 user  0m0.011s
 sys   0m0.007s
 
 psxx:/tmp$ ghc --make -fforce-recomp -o out buga.hs -O
 [1 of 1] Compiling Main ( buga.hs, buga.o )
 Linking out ...
 psxx:/tmp$ time ./out  3-med.in |/dev/null
 real  0m0.252s
 user  0m0.225s
 sys   0m0.011s
 
 psxx:/tmp$ ghc --make -fforce-recomp -o out buga.hs -O2
 [1 of 1] Compiling Main ( buga.hs, buga.o )
 Linking out ...
 Vazeny pane, cekam na Vase rozkazy.
 psxx:/tmp$ time ./out  3-med.in |/dev/null
 real  0m0.239s
 user  0m0.225s
 sys   0m0.010s
 
 psxx:/tmp$ ghc --version
 The Glorious Glasgow Haskell Compilation System, version 6.10.1
 
 
 The GHC documentation states that
 
  -O2:
  Means: Apply every non-dangerous optimisation, even if it means
  significantly longer compile times.  The avoided dangerous
  optimisations are those that can make runtime or space worse if
  you're unlucky. They are normally turned on or off individually.
 
 If I understand this correctly, the dangerous optimisations should not
 be performed with -O.  Am I doing anything wrong?  Am I hitting a bug
 in GHC optimiser? A known one?
 
 
  The program source:
 
 --
 p...@r4at184:/tmp$ cat buga.hs 
 {-# LANGUAGE FlexibleContexts #-}
 
 import Control.Monad
 import Control.Monad.State
 
 data Predpoc a = Nic | Kus { delka :: Int,
  levy :: Predpoc a,
  pravy :: Predpoc a }
   deriving Show
 
 gList i = Kus 1 Nic Nic
 
 gPredpoc kus1 kus2 =
   Kus (delka kus1 + delka kus2)
   kus1 kus2
 
 
 pop :: MonadState [a] m = m a
 pop = get = \(x:xs) - put xs  return x
 
 mbuild :: MonadState [Int] m = Int - m (Predpoc Int)
 mbuild 1 = gList `liftM` pop
 mbuild n = liftM2 gPredpoc (mbuild n1) (mbuild n2)
   where n1 = n`div`2
 n2 = n - n1
 
 build n li = evalState (mbuild n) li
 
 best :: Predpoc Int - Int - Int - Int
 best kus i j
   | i == 1  j == delka kus
 = delka kus
   | j = del1   = best (levy kus) i j
   | i  del1= best (pravy kus) (i-del1) (j-del1)
   | otherwise   = best (levy kus) i del1 +
   best (pravy kus) 1 (j-del1)
   where
 del1 = delka (levy kus)
 
 main = do
   n - read `liftM` getLine
   pole - liftM (build n . map read . words) getLine
   replicateM_ 100 $ do
 getLine
 print $ best pole 42 420
 --
 
  The sample input file (30k) can be downloaded from
 http://pikomat.mff.cuni.cz/petr/3-med.in
 
  I suspect that the main's variable pole (which is a large
 binary tree of type Predpoc Int) may be built from scratch in each
 iteration of the replicateM_ loop.
 
  Petr
 ___
 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] community.haskell.org unreachable?

2009-04-06 Thread Claus Reinke

Works for me. The admin address referenced there is support [AT]
community.haskell.org


Thanks. Yes, it is working again for me too, now, but had been
quite persistently unreachable before, while www.haskell.org
was reachable, so I'd be surprised if the the problem was at
this end of the connection.

If I read the bandwith graph correctly, there was a peak followed
by several hours of silence, matched by odd memory usage (though
I don't see what the load average is trying to tell us?): 


http://community.haskell.org/mrtg/daily.html

Claus


On Mon, Apr 6, 2009 at 1:32 PM, Claus Reinke claus.rei...@talk21.comwrote:


I seem to be having problems reaching anything on that server.
Does anyone know what is going on, or who to contact? It would
help if the haskellwiki page

http://www.haskell.org/haskellwiki/Haskell.org_domain

would mention the admin address directly, instead of referring to

http://community.haskell.org/admin/
which is also unreachable.

Claus

___
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 mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] strange performance issue with takusen 0.8.3

2009-04-06 Thread Marko Schütz
Dear All,

I have an application where some simple data extracted from some
source files is inserted into a PostgreSQL database. The application
uses Takusen and is compiled with GHC 6.8.3. Some (59 in the test
data) of the selects take on average 460ms each for a total time for
this sample run of 30s. I prepare one select statement at the
beginning of the run into which I then bind the specific values for
every one of the selects. It does not seem to make a difference
whether I do this or whether I just use a new statement for every
select.

For comparison, I have collected the SQL statements in a file with
PREPARE ... and DEALLOCATE for _every_ select and then run this file
through psql. This takes 2s!

During the run of the GHC-compiled executable the cpu load goes up. In
top I see %CPU of above 72%.

Any ideas that might enlighten are welcome.

Best regards,

Marko

pgpcwfuYc2MfV.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Numeric Prelude and identifiers (Was: fad 1.0 -- Forward AutomaticDifferentiation library)

2009-04-06 Thread Kalman Noel
Henning Thielemann schrieb:
 On Sun, 5 Apr 2009, Kalman Noel wrote:
  I'm wondering, too, if the Numeric Prelude could be organized more
 cleanly if we had a fancier module system - does someone have
 sufficient experience with, say, ML-style module systems to tell?
 
 Are you complaining about the organisation or about the identifiers? If
 you mean the former, then what organisation do you propose?

I'm not complaining, and I'm not sure what I mean :) I may like a scheme
where functions operating on a type or type class live in a module
seperate from the type (class) definition, so you could import a
specific module to get only, say, (Ring, (*), one, ...).  But that would
be too tedious in the Haskell hierarchical module system, which is why I
was asking about others.

 If you mean
 the latter ... Many proposals about extended import facilities I saw
 were complicated and could simply be avoided using the naming style I use.

I'm ready to believe you that the naming style you chose is optimal
within the hierarchical module system.

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


Re: [Haskell-cafe] Combining sequences

2009-04-06 Thread nowgate
Hi Daniel,

Thanks, but apparently no go.

This isn't critical, as I already have a function that will combine two 
sequences.

Michael

=


Michael
[mich...@localhost untitled folder]$ cd utility-ht-0.0.4
[mich...@localhost utility-ht-0.0.4]$ ls
LICENSE  Setup.lhs  src  utility-ht.cabal
[mich...@localhost utility-ht-0.0.4]$ ./Setup.lhs configure --hugs
/usr/bin/env: runhaskell: No such file or directory  --OOPS!
[mich...@localhost utility-ht-0.0.4]$ su
Password: 
[r...@localhost utility-ht-0.0.4]# ./Setup.lhs configure --hugs
/usr/bin/env: runhaskell: No such file or directory
[r...@localhost utility-ht-0.0.4]# 


--- On Mon, 4/6/09, Daniel Fischer daniel.is.fisc...@web.de wrote:

From: Daniel Fischer daniel.is.fisc...@web.de
Subject: Re: [Haskell-cafe] Combining sequences
To: haskell-cafe@haskell.org
Cc: michael rice nowg...@yahoo.com
Date:
 Monday, April 6, 2009, 12:04 PM

Am Montag 06 April 2009 17:12:42 schrieb michael rice:
 I downloaded it and it appears more complicated than just adding files to a
 directory. There's a setup and a build, and no assurances it will work with
 Hugs.

 I think I'll wait for more information.

 Michael

Try installing it with Cabal:

./Setup.lhs configure --hugs

if that doesn't say otherwise, chances are that it will work, so try

./Setup.lhs build
sudo ./Setup.lhs install

If it doesn't work, you can copy the code from Data.List.HT



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


[Haskell-cafe] Re: Linking hmatrix without LAPACK

2009-04-06 Thread Duane Johnson

Hi Alberto!

Thanks for your informative reply.  I looked in to the versions of  
liblapack on my system... it turns out there is indeed a  
liblapack.dylib that (apparently) comes with Mac OS X.  How to tell  
ghc to link to that instead is still in question.


I can run simple matrix operations in ghci as you suggest (in fact,  
runTests 20 succeeds wonderfully); however, I created the following  
simple module (test.hs) and it fails:



module Main where
  import Numeric.LinearAlgebra.Tests

  main = do
runTests 20


I tried plain --make, as well as the -dynamic flag, and then I  
tried the -L shell argument to point to the /usr/lib dir where the  
liblapack.dylib library is located:




$ ghc --make test.hs -o test
[1 of 1] Compiling Main ( test.hs, test.o )
Linking test ...
ld: in /opt/local/lib/liblapack.a(
), not a valid archive member
collect2: ld returned 1 exit status

$ ghc --make -dynamic test.hs -o test
Linking test ...
ld: library not found for -lHShmatrix-0.5.0.1-ghc6.10.1
collect2: ld returned 1 exit status

$ ghc --make -L/usr/lib test.hs -o test
Linking test ...
Undefined symbols:
  _zgemm_, referenced from:
  _multiplyC in libHShmatrix-0.5.0.1.a(lapack-aux.o)
  _zgesv_, referenced from:
  _linearSolveC_l in libHShmatrix-0.5.0.1.a(lapack-aux.o)
  _zpotrf_, referenced from:
  _chol_l_H in libHShmatrix-0.5.0.1.a(lapack-aux.o)
  _dpotrf_, referenced from:
  _chol_l_S in libHShmatrix-0.5.0.1.a(lapack-aux.o)
  _dgemm_, referenced from:
  _multiplyR in libHShmatrix-0.5.0.1.a(lapack-aux.o)
  _dgesv_, referenced from:
  _linearSolveR_l in libHShmatrix-0.5.0.1.a(lapack-aux.o)
  _zgetrf_, referenced from:
  _lu_l_C in libHShmatrix-0.5.0.1.a(lapack-aux.o)
  _zgetrs_, referenced from:
  _luS_l_C in libHShmatrix-0.5.0.1.a(lapack-aux.o)
  _dgetrf_, referenced from:
  _lu_l_R in libHShmatrix-0.5.0.1.a(lapack-aux.o)
  _dgetrs_, referenced from:
  _luS_l_R in libHShmatrix-0.5.0.1.a(lapack-aux.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status



I attempted to install hmatrix with the -faccelerate option, but  
when using ghc --make for the above test code, I received the same  
error messages noted previously.  Is there a way to tell if the - 
faccelerate was acknowledged and that the alternate library was used?


One more clue: I took a look at the directions found on the page at  
mit.edu/harold... it turns out I had installed atlas/lapack  
unnecessarily.  That explains the mysterious not a valid archive  
member message.  Nevertheless, I am still befuddled by the Undefined  
symbols above.  ghc --make is still unable to figure out where the  
liblapack.dylib file is in spite of ghci's success.


Any suggestions from here?

Regards,
Duane Johnson

P.S. I'm CC'ing the Haskell Cafe so that our journey so far can be  
archived.




On Apr 6, 2009, at 12:22 PM, Alberto Ruiz wrote:


Hi Duane,

I have seen your messages to Haskell Cafe but I am still thinking  
about the problem... :)


Can you run simple matrix operations in ghci?

$ ghci
Prelude import Numeric.LinearAlgebra
Prelude Numeric.LinearAlgebra let m = (22) [1..4 :: Double]

(...Loading packages...)

Prelude Numeric.LinearAlgebra m  m
(22)
[  7.0, 10.0
, 15.0, 22.0 ]

If so, some version of blas/lapack can be found in your system, it  
is strange that ghc --make doesn't find them.


Perhaps the problem is that dynamic libraries like liblapack.so are  
required instead of static ones like liblapack.a. (In ubuntu they  
are in the devel packages for blas/lapack.)


I am not familiar with Mac OS, but if you can use the accelerate  
framework in your system you may try the -faccelerate configuration  
option for hmatrix:


cabal install hmatrix -faccelerate

See also the following page (steps 3-8). It explains how to install  
hmatrix on Mac OS (required for other project).


http://mit.edu/harold/Public/easyVisionNotes.html

Please let me know if any of these methods works for you.

Thanks for your message,

Alberto



Duane Johnson wrote:

Hi Alberto,
I've been very happy with hmatrix as I've used it in ghci, and I  
should first thank you for making such an excellent package.  I've  
had trouble when linking it using ghc --make on Mac OS  
(Leopard).  Below are two messages I sent to the Haskell Cafe  
mailing list.  Do you have any insight into either question:

1. How to link without atlas/lapack
2. What the not a valid archive member message means?
Thank you!
Duane Johnson
Brigham Young University
Provo, UT
Begin forwarded message:

From: Don Stewart d...@galois.com
Date: April 5, 2009 11:48:38 PM MDT
To: Duane Johnson duane.john...@gmail.com
Subject: Re: [Haskell-cafe] Re: Linking hmatrix without LAPACK

It would be best to contact the author of hmatrix directly.


duane.johnson:
On a related note, I've installed Atlas, and I get the following  
error

when linking:


Linking SilkwormGame ...
ld: in /opt/local/lib/liblapack.a(), not a valid archive member
collect2: ld 

Re: [Haskell-cafe] Combining sequences

2009-04-06 Thread Henning Thielemann


On Mon, 6 Apr 2009, nowg...@yahoo.com wrote:


Michael
[mich...@localhost untitled folder]$ cd utility-ht-0.0.4
[mich...@localhost utility-ht-0.0.4]$ ls
LICENSE  Setup.lhs  src  utility-ht.cabal
[mich...@localhost utility-ht-0.0.4]$ ./Setup.lhs configure --hugs
/usr/bin/env: runhaskell: No such file or directory  --OOPS!
[mich...@localhost utility-ht-0.0.4]$ su
Password:
[r...@localhost utility-ht-0.0.4]# ./Setup.lhs configure --hugs
/usr/bin/env: runhaskell: No such file or directory
[r...@localhost utility-ht-0.0.4]#


$ runhugs Setup.lhs configure --hugs

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


[Haskell-cafe] ghc --make unable to find dynamic library, but ghci can

2009-04-06 Thread Duane Johnson

Hi Haskellers,

This is related to my previous message, Linking hmatrix without  
LAPACK.  Apparently, ghc --make is not finding the lapack.dylib  
library where ghci is (dylib is Mac OS X specific) .  For example, the  
following test module does NOT work when compiled with ghc --make:




module Main where
 import Numeric.LinearAlgebra.Tests

 main = do
   runTests 20



But the following runs fine in ghci:



$ ghci
GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help
[...loading packages...]
Prelude :m Numeric.LinearAlgebra.Tests
Prelude Numeric.LinearAlgebra.Tests runTests 20
[...loading packages...]
-- mult
OK, passed 100 tests.
OK, passed 100 tests.
[...more tests pass...]



Can anyone point me in the right direction?

Thank you,
Duane Johnson
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Combining sequences

2009-04-06 Thread Henning Thielemann


On Sun, 5 Apr 2009, michael rice wrote:


Thanks. It looks like mergeBy will do the job, but is it available in Hugs?


The package is Haskell98 and needs no further package, thus it should work 
with almost every Haskell system.

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


Re: [Haskell-cafe] Ghc: -O harmful?

2009-04-06 Thread Daniel Fischer
Am Montag 06 April 2009 20:37:46 schrieb Don Stewart:
 -fno-state-hack?

That, or

{-# LANGUAGE BangPatterns #-}

main = do
  n - read `liftM` getLine
  !pole - liftM (build n . map read . words) getLine
  replicateM_ 100 $ do
    getLine
    print $ best pole 42 420

if the state-hack is beneficial in other places of the programme.
The bang on pole tells GHC to calculate it only once, not inline it.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Monad transformer to consume a list

2009-04-06 Thread Stephan Friedrichs
Hello,

is there a monad transformer to consume an input list? I've got external
events streaming into the monad that are consumed on demand and I'm
not sure if there's something better than a StateT.

//Stephan

-- 

Früher hieß es ja: Ich denke, also bin ich.
Heute weiß man: Es geht auch so.

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


Re: [Haskell-cafe] Monad transformer to consume a list

2009-04-06 Thread Henning Thielemann


On Mon, 6 Apr 2009, Stephan Friedrichs wrote:


Hello,

is there a monad transformer to consume an input list? I've got external
events streaming into the monad that are consumed on demand and I'm
not sure if there's something better than a StateT.


I wondered that, too. I wondered whether there is something inverse to 
Writer, and Reader is appearently not the answer. Now I think, that State 
is indeed the way to go to consume a list. Even better is StateT List 
Maybe:


next :: StateT [a] Maybe a
next = StateT Data.List.HT.viewL   -- see utility-ht package
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] GHC accepts libraries compiled with Visual Studio?

2009-04-06 Thread Peter Verswyvelen
To my surprise GHC seems to accept .lib files (produced by e.g. Visual
Studio on Windows) directly; I don't need to convert these to .a files using
e.g. reimp
That's really cool. Is this by design or did I miss something? The manual
does not seem to mention this.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Strange type error with associated type synonyms

2009-04-06 Thread Peter Berry
 {-# LANGUAGE TypeFamilies, TypeSynonymInstances, ScopedTypeVariables #-}

The following is a class of memo tries indexed by d:

 class Fun d where
 type Memo d :: * - *
 abst :: (d - a) - Memo d a
 appl :: Memo d a - (d - a)
 -- Law: abst . appl = id
 -- Law: appl . abst = id (denotationally)

Any such type Memo d is naturally a functor:

 memo_fmap f x = abst (f . appl x)

The type of memo_fmap (as given by ghci) is (Fun d) = (a - c) -
Memo d a - Memo d c. (Obviously this would also be the type of fmap
for Memo d, so we could declare a Functor instance in principle.) If
we add this signature:

 memo_fmap' :: Fun d = (a - b) - Memo d a - Memo d b
 memo_fmap' f x = abst (f . appl x)

it doesn't type check:

TypeSynonymTest.hs:14:17:
Couldn't match expected type `Memo d1 b'
   against inferred type `Memo d b'
In the expression: abst (f . appl x)
In the definition of `memo_fmap'':
memo_fmap' f x = abst (f . appl x)

TypeSynonymTest.hs:14:32:
Couldn't match expected type `Memo d a'
   against inferred type `Memo d1 a'
In the first argument of `appl', namely `x'
In the second argument of `(.)', namely `appl x'
In the first argument of `abst', namely `(f . appl x)'
Failed, modules loaded: none.

As I understand it, the type checker's thought process should be along
these lines:

1) the type signature dictates that x has type Memo d a.
2) appl has type Memo d1 a - d1 - a for some d1.
3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1

But for some reason, step 3 fails. If we annotate appl with the
correct type (using scoped type variables), it type checks:

 -- thanks to mmorrow on #haskell for this
 memo_fmap'' :: forall a b d. Fun d = (a - b) - Memo d a - Memo d b
 memo_fmap'' f x = abst (f . (appl :: Memo d a - d - a) x)

My ghc is 6.8.2, but apparently this happens in 6.10 as well.

-- 
Peter Berry pwbe...@gmail.com
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Numeric Prelude and identifiers

2009-04-06 Thread Henning Thielemann


On Mon, 6 Apr 2009, Kalman Noel wrote:


I'm not complaining, and I'm not sure what I mean :) I may like a scheme
where functions operating on a type or type class live in a module
seperate from the type (class) definition, so you could import a
specific module to get only, say, (Ring, (*), one, ...).  But that would
be too tedious in the Haskell hierarchical module system, which is why I
was asking about others.


It was precisely my goal to bundle the type with the functions that 
operate on it. Why do you want to separate them?

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


[Haskell-cafe] Volunteer

2009-04-06 Thread Xiao-Yong Jin
Hi,

I learned that no one is doing generic unix source tarball,
right now, and thought I might help to get it start.  I have
decent skills on Makefile, but knows very little about
auto-tools.  I can only spent a few hours every week on it,
because I don't have too much spare time as a PhD student.
But I still want to help, since it is quite important for
Haskell to distribute as widely as possible.

So, how should I start?  I learned that ghc supports quite a
lot of platforms in its tier2 support list through community
supporters.  I'm not sure what is the most convenient way to
combine these into a generic source tarball.  And what do we
use to bootstrap ghc?  Some pre-compiled binary?

I'm not sure how I should start.  Any insight?

Best,
Xiao-Yong

P.S.  I tried to send to haskell-platform, but got rejected.  What's
going on?

-- begin error message --
... while talking to community.haskell.org.:
 DATA
 550 Unrouteable address
550 5.1.1 haskell-platf...@projects.haskell.org... User unknown
 503 valid RCPT command must precede DATA
-- end error message --
-- 
c/*__o/*
\ * (__
*/\  

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


[Haskell-cafe] Re: Linking hmatrix without LAPACK

2009-04-06 Thread Duane Johnson

FYI, the following solution worked on Mac OS X (Leopard):


ghc -o SilkwormGame --make -framework Accelerate Main.hs


The key addition is -framework Accelerate.  Thus, on Mac OS X, it is  
only necessary to install the gls library via macports.  Atlas/ 
LAPACK/BLAS etc. come with the operating system framework above.


Also, I had to replace a DYLD_LIBRARY_PATH assignment in my .profile  
with DYLD_FALLBACK_LIBRARY_PATH:



export DYLD_LIBRARY_PATH=/opt/local/lib:/usr/local/cuda/lib



becomes:


export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib:/usr/local/cuda/lib


The above change permitted me to use Apple's libraries by default, and  
my macports libraries as fallbacks.  In particular, when I installed  
the atlas package via macports, it seems to have updated a key  
libjpeg.dylib file, thus causing other headaches.  Using the  
fallback method above, the problems went away.


Regards,
Duane Johnson

On Apr 6, 2009, at 1:51 PM, Duane Johnson wrote:


Hi Alberto!

Thanks for your informative reply.  I looked in to the versions of  
liblapack on my system... it turns out there is indeed a  
liblapack.dylib that (apparently) comes with Mac OS X.  How to tell  
ghc to link to that instead is still in question.


I can run simple matrix operations in ghci as you suggest (in fact,  
runTests 20 succeeds wonderfully); however, I created the  
following simple module (test.hs) and it fails:



module Main where
 import Numeric.LinearAlgebra.Tests

 main = do
   runTests 20


I tried plain --make, as well as the -dynamic flag, and then I  
tried the -L shell argument to point to the /usr/lib dir where the  
liblapack.dylib library is located:




$ ghc --make test.hs -o test
[1 of 1] Compiling Main ( test.hs, test.o )
Linking test ...
ld: in /opt/local/lib/liblapack.a(
), not a valid archive member
collect2: ld returned 1 exit status

$ ghc --make -dynamic test.hs -o test
Linking test ...
ld: library not found for -lHShmatrix-0.5.0.1-ghc6.10.1
collect2: ld returned 1 exit status

$ ghc --make -L/usr/lib test.hs -o test
Linking test ...
Undefined symbols:
 _zgemm_, referenced from:
 _multiplyC in libHShmatrix-0.5.0.1.a(lapack-aux.o)
 _zgesv_, referenced from:
 _linearSolveC_l in libHShmatrix-0.5.0.1.a(lapack-aux.o)
 _zpotrf_, referenced from:
 _chol_l_H in libHShmatrix-0.5.0.1.a(lapack-aux.o)
 _dpotrf_, referenced from:
 _chol_l_S in libHShmatrix-0.5.0.1.a(lapack-aux.o)
 _dgemm_, referenced from:
 _multiplyR in libHShmatrix-0.5.0.1.a(lapack-aux.o)
 _dgesv_, referenced from:
 _linearSolveR_l in libHShmatrix-0.5.0.1.a(lapack-aux.o)
 _zgetrf_, referenced from:
 _lu_l_C in libHShmatrix-0.5.0.1.a(lapack-aux.o)
 _zgetrs_, referenced from:
 _luS_l_C in libHShmatrix-0.5.0.1.a(lapack-aux.o)
 _dgetrf_, referenced from:
 _lu_l_R in libHShmatrix-0.5.0.1.a(lapack-aux.o)
 _dgetrs_, referenced from:
 _luS_l_R in libHShmatrix-0.5.0.1.a(lapack-aux.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status



I attempted to install hmatrix with the -faccelerate option, but  
when using ghc --make for the above test code, I received the same  
error messages noted previously.  Is there a way to tell if the - 
faccelerate was acknowledged and that the alternate library was used?


One more clue: I took a look at the directions found on the page at  
mit.edu/harold... it turns out I had installed atlas/lapack  
unnecessarily.  That explains the mysterious not a valid archive  
member message.  Nevertheless, I am still befuddled by the  
Undefined symbols above.  ghc --make is still unable to figure out  
where the liblapack.dylib file is in spite of ghci's success.


Any suggestions from here?

Regards,
Duane Johnson

P.S. I'm CC'ing the Haskell Cafe so that our journey so far can be  
archived.




On Apr 6, 2009, at 12:22 PM, Alberto Ruiz wrote:


Hi Duane,

I have seen your messages to Haskell Cafe but I am still thinking  
about the problem... :)


Can you run simple matrix operations in ghci?

$ ghci
Prelude import Numeric.LinearAlgebra
Prelude Numeric.LinearAlgebra let m = (22) [1..4 :: Double]

(...Loading packages...)

Prelude Numeric.LinearAlgebra m  m
(22)
[  7.0, 10.0
, 15.0, 22.0 ]

If so, some version of blas/lapack can be found in your system, it  
is strange that ghc --make doesn't find them.


Perhaps the problem is that dynamic libraries like liblapack.so are  
required instead of static ones like liblapack.a. (In ubuntu they  
are in the devel packages for blas/lapack.)


I am not familiar with Mac OS, but if you can use the accelerate  
framework in your system you may try the -faccelerate  
configuration option for hmatrix:


cabal install hmatrix -faccelerate

See also the following page (steps 3-8). It explains how to install  
hmatrix on Mac OS (required for other project).


http://mit.edu/harold/Public/easyVisionNotes.html

Please let me know if any of these methods works for you.

Thanks for your message,

Alberto



Duane Johnson wrote:

Hi 

Re: [Haskell-cafe] GHC accepts libraries compiled with Visual Studio?

2009-04-06 Thread Jeff Heard
I've noticed this before.  I in fact have really only tried FTGL with
VC compiled lib files...

On Mon, Apr 6, 2009 at 5:34 PM, Peter Verswyvelen bugf...@gmail.com wrote:
 To my surprise GHC seems to accept .lib files (produced by e.g. Visual
 Studio on Windows) directly; I don't need to convert these to .a files using
 e.g. reimp
 That's really cool. Is this by design or did I miss something? The manual
 does not seem to mention this.



 ___
 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] Configuring cabal dependencies at install-time

2009-04-06 Thread Jeff Heard
Is there a way to do something like autoconf and configure
dependencies at install time?  Building buster, I keep adding
dependencies and I'd like to keep that down to a minimum without the
annoyance of littering Hackage with dozens of packages.  For instance,
today I developed an HTTP behaviour and that of course requires
network and http, which were previously not required.  I'm about to
put together a haxr XML-RPC behaviour as well, and that of course
would add that much more to the dependency list.  HaXml, haxr, and
haxr-th most likely.

so... any way to do that short of making a bunch of separate packages
with one or two modules apiece?  Otherwise I'm thinking of breaking
things up into buster, buster-ui, buster-network, buster-console, and
buster-graphics to start and adding more as I continue along.

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


Re: [Haskell-cafe] Infix tuple comma query (,)

2009-04-06 Thread Ryan Ingram
The prefix notation for
 \a b c - (a,b,c)
is (,,)

Without the parentheses, it's not immediately clear whether
 foo $ a,b
means
 foo (a,b)
or
 foo (\c - (a,b,c))
or some other, bigger tuple size.

Anyways, it's just syntax :)

  -- ryan


On Mon, Apr 6, 2009 at 9:08 AM, Daniel Fischer daniel.is.fisc...@web.de wrote:
 Am Montag 06 April 2009 17:53:24 schrieb Paul Keir:
 module Main where



 data (:%^) a b = a :%^ b    deriving (Show)



 main = do

   print $ 18 :%^ (Just 99)

   print $ (,) 9 10

   print $ 9 , 10



 The last line in the code above causes a compile error.

 Why does infix use of the comma (tuple constructor?) function fail
 without brackets?


 Tuples are special baked-in syntax. The parentheses are part of the tuple
 constructor(s).
 It may be confusing you that you can use it prefix as well as aroundfix.



 Thanks,

 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] Volunteer

2009-04-06 Thread Marko Schütz
Dear Xiao-Yong,

thank you very much for your willingness to help. 

I would suggest you look into some of the builds for various platforms
as you mentioned. One infrastructure I find particularly interesting
is pkgsrc (www.pkgsrc.org) which can be used to effortlessly build
numerous packages from source on various OSs and platforms. The
approach taken there for building GHC is to provide pre-compiled C
sources of an early GHC version, that is then used to bootstrap a more
recent version.

Unfortunately, the GHC package in pkgsrc is currently limited to i386
only. As far as I understand this limitation is only due to the fact
that the maintainer only generated the intermediate C sources for i386
and I would think a similar approach should work with other
platforms. Take all this with a lot of salt: I have only looked
into these matters cursorily, but it's where I would start looking
deeper... 

Good luck and best regards,

Marko

At Mon, 06 Apr 2009 17:43:09 -0400,
Xiao-Yong Jin wrote:
 
 Hi,
 
 I learned that no one is doing generic unix source tarball,
 right now, and thought I might help to get it start.  I have
 decent skills on Makefile, but knows very little about
 auto-tools.  I can only spent a few hours every week on it,
 because I don't have too much spare time as a PhD student.
 But I still want to help, since it is quite important for
 Haskell to distribute as widely as possible.
 
 So, how should I start?  I learned that ghc supports quite a
 lot of platforms in its tier2 support list through community
 supporters.  I'm not sure what is the most convenient way to
 combine these into a generic source tarball.  And what do we
 use to bootstrap ghc?  Some pre-compiled binary?
 
 I'm not sure how I should start.  Any insight?
 
 Best,
 Xiao-Yong
 
 P.S.  I tried to send to haskell-platform, but got rejected.  What's
 going on?
 
 -- begin error message --
 ... while talking to community.haskell.org.:
  DATA
  550 Unrouteable address
 550 5.1.1 haskell-platf...@projects.haskell.org... User unknown
  503 valid RCPT command must precede DATA
 -- end error message --
 -- 
 c/*__o/*
 \ * (__
 */\  
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


pgpIgMzLuK3Ao.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-06 Thread Ryan Ingram
On Mon, Apr 6, 2009 at 2:36 PM, Peter Berry pwbe...@gmail.com wrote:
 As I understand it, the type checker's thought process should be along
 these lines:

 1) the type signature dictates that x has type Memo d a.
 2) appl has type Memo d1 a - d1 - a for some d1.
 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1

This isn't true, though, and for similar reasons why you can't declare
a generic instance Fun d = Functor (Memo d).  Type synonyms are not
injective; you can have two instances that point at the same type:

data Unit1 = Unit1
data Unit2 = Unit2

newtype Identity x = Id x

unit_abst x f = Id (f x)
unit_appl (Id v) _ = v

instance Fun Unit1 where
   type Memo Unit1 = Identity
   abst = unit_abst Unit1
   appl = unit_appl
instance Fun Unit2 where
   type Memo Unit2 = Identity
   abst = unit_abst Unit2
   appl = unit_appl

Now, Memo Unit1 a = Identity a = Memo Unit2 a, but that does not give
us that Unit1 = Unit2.

In fact, memo_fmap' is ambiguous; what should this application do?
   memo_fmap' id (Id ())

Should it look at the instance for Unit1, or Unit2, or some other
instance we haven't given yet?

You can use a data family instead, and then you get the property you
want; if you make Memo a data family, then Memo d1 = Memo d2 does
indeed give you d1 = d2.

You can still use other types in your instances, just use newtype
instance Memo Unit1 a = MemoUnit1 (Identity a) and add the
appropriate newtype wrappers and unwrappers.

 But for some reason, step 3 fails. If we annotate appl with the
 correct type (using scoped type variables), it type checks:

 -- thanks to mmorrow on #haskell for this
 memo_fmap'' :: forall a b d. Fun d = (a - b) - Memo d a - Memo d b
 memo_fmap'' f x = abst (f . (appl :: Memo d a - d - a) x)

Right, because now you have constrained appl ahead of time, passing in
the correct type, instead of hoping the compiler can guess how you
meant to use appl.

I don't know if this function is callable, though; at the very least
you need to annotate its call site to get the proper instance passed
through.

This is somewhat solvable with a proxy element to fix the instance of Fun:

data Proxy d = Proxy
memo_fmap_nonamb :: Fun d = Proxy d - (a - b) - Memo d a - Memo d b
memo_fmap_nonamb _ f x = abst (f . appl x)

I don't know if this version compiles without the type annotation; my
guess is that it might!  But even if it doesn't, once you add the
proper annotation it is at least callable:

test = memo_fmap_nonamb (Proxy :: Proxy Unit1) id (Id ())

I think, for this problem, data families are a better solution.  They
also let you write the generic Functor instance.

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


Re: [Haskell-cafe] Strange type error with associated type synonyms

2009-04-06 Thread Manuel M T Chakravarty

Peter Berry:
{-# LANGUAGE TypeFamilies, TypeSynonymInstances,  
ScopedTypeVariables #-}


The following is a class of memo tries indexed by d:


class Fun d where
   type Memo d :: * - *
   abst :: (d - a) - Memo d a
   appl :: Memo d a - (d - a)
   -- Law: abst . appl = id
   -- Law: appl . abst = id (denotationally)


Any such type Memo d is naturally a functor:


memo_fmap f x = abst (f . appl x)


The type of memo_fmap (as given by ghci) is (Fun d) = (a - c) -
Memo d a - Memo d c. (Obviously this would also be the type of fmap
for Memo d, so we could declare a Functor instance in principle.) If
we add this signature:


memo_fmap' :: Fun d = (a - b) - Memo d a - Memo d b
memo_fmap' f x = abst (f . appl x)


it doesn't type check:

TypeSynonymTest.hs:14:17:
   Couldn't match expected type `Memo d1 b'
  against inferred type `Memo d b'
   In the expression: abst (f . appl x)
   In the definition of `memo_fmap'':
   memo_fmap' f x = abst (f . appl x)

TypeSynonymTest.hs:14:32:
   Couldn't match expected type `Memo d a'
  against inferred type `Memo d1 a'
   In the first argument of `appl', namely `x'
   In the second argument of `(.)', namely `appl x'
   In the first argument of `abst', namely `(f . appl x)'
Failed, modules loaded: none.

As I understand it, the type checker's thought process should be along
these lines:

1) the type signature dictates that x has type Memo d a.
2) appl has type Memo d1 a - d1 - a for some d1.
3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1

But for some reason, step 3 fails.


Step 3 is invalid - cf, http://www.haskell.org/pipermail/haskell-cafe/2009-April/059196.html 
.


More generally, the signature of memo_fmap is ambiguous, and hence,  
correctly rejected.  We need to improve the error message, though.   
Here is a previous discussion of the subject:


  http://www.mail-archive.com/haskell-cafe@haskell.org/msg39673.html

Manuel

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


Re: [Haskell-cafe] Lazy vs correct IO [Was: A round of golf]

2009-04-06 Thread Jason Dusek
  Is the choice of whether or not to open/close with each chunk
  read something that we can reasonably hide from the I/O API's
  user? There is at least one way in which is semantically
  distinct -- that old trick of opening a tempfile and then
  unlinking it to hide it.

  It may be the sort of thing that you do on demand, too -- we
  have a file handle pool and as we run out of handles we switch
  to opening/closing. For a single really long read,
  opening/closing every 4k is just churn; if your doing
  thousands of long reads at once, though, it can't be helped.

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


[Haskell-cafe] automatically inserting type declarations

2009-04-06 Thread FFT
I remember hearing about a Haskell mode for Vim, Emacs, Yi or
VisualHaskell that inserts type declarations automatically (it's
lazier to just check the type than to write it manually), but I can't
remember any details. What editor mode / IDE was it?

What do most people use with GHC on Linux? I'm more used to Vim than
to Emacs. Yi sounds like something I might like. Is it stable enough
to solve more problems than it would create? (I hate buggy and broken
stuff)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Infix tuple comma query (,)

2009-04-06 Thread Alexander Dunlap
On Mon, Apr 6, 2009 at 8:53 AM, Paul Keir pk...@dcs.gla.ac.uk wrote:
 module Main where



 data (:%^) a b = a :%^ b    deriving (Show)



 main = do

   print $ 18 :%^ (Just 99)

   print $ (,) 9 10

   print $ 9 , 10



 The last line in the code above causes a compile error.

 Why does infix use of the comma (tuple constructor?) function fail without
 brackets?



 Thanks,

 Paul


When I want a lighter syntax for pairs (when doing a long list of
them, e.g.), I often define

() :: a - b - (a,b)
a  b = (a,b)

and then you can indeed write

print $ 1  2

(assuming you get precedence right).

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


[Haskell-cafe] Generating arbitrary function in QuickCheck

2009-04-06 Thread Yusaku Hashimoto

Hi,

today, I want to ask about QuickCheck.

I have known recently that arbitrary works on functions as well. I
played on this for a while, and met a strange behavior.

I tried to write property for sortBy.

import Test.QuickCheck
import Data.List

instance Show (a - b) where show _ = function
instance Arbitrary Ordering where
arbitrary = elements [LT,EQ,GT]

mySortBy :: (Ord a) = (a - a - Ordering) - [a] - [a]
mySortBy = sortBy

prop_mysortby_sorted :: (Int - Int - Ordering) - [Int] -  
Property

prop_mysortby_sorted cmp ls = null ls
  `trivial` all eq_or_lt (zipWith  
cmp sorted (tail sorted))

where sorted = mySortBy cmp ls
  eq_or_lt ord = ord == EQ || ord == LT

I had thought Arbitrary instance for Ord and property for sortBy both
fine. But checking fails:

ghci quickCheck prop_mysortby_sorted
Falsifiable, after 2 tests:
function
[2,3]

I guess arbitrary for (Int - Int - Ordering) generates a non-sense
function like this:

-- let (arb_compare :: Int - Int - Ordering) generated function.
arb_compare 0 1 = GT
arb_compare 1 0 = GT
arb_compare _ _ = EQ

Then, I want to ask two questions.

1. Is my guessing in function generated by arbitrary right?
2. If so, How do I generate right function?

Thanks,
Yusaku Hashimoto

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


Re: [Haskell-cafe] Generating arbitrary function in QuickCheck

2009-04-06 Thread Eugene Kirpichov
Since the argument to sortBy must impose a linear ordering on its
arguments, and any linear ordering may as well be generated by
assigning an integer to each element of type 'a', and your sorting
function is polymorphic, from the free theorem for the sorting
function we may deduce that it suffices to test your function on
integer lists with a casual comparison function (Data.Ord.compare),
and there is no need to generate a random comparison function.

2009/4/7 Yusaku Hashimoto nonow...@gmail.com:
 Hi,

 today, I want to ask about QuickCheck.

 I have known recently that arbitrary works on functions as well. I
 played on this for a while, and met a strange behavior.

 I tried to write property for sortBy.

    import Test.QuickCheck
    import Data.List

    instance Show (a - b) where show _ = function
    instance Arbitrary Ordering where
        arbitrary = elements [LT,EQ,GT]

    mySortBy :: (Ord a) = (a - a - Ordering) - [a] - [a]
    mySortBy = sortBy

    prop_mysortby_sorted :: (Int - Int - Ordering) - [Int] - Property
    prop_mysortby_sorted cmp ls = null ls
                                  `trivial` all eq_or_lt (zipWith cmp sorted
 (tail sorted))
        where sorted = mySortBy cmp ls
              eq_or_lt ord = ord == EQ || ord == LT

 I had thought Arbitrary instance for Ord and property for sortBy both
 fine. But checking fails:

    ghci quickCheck prop_mysortby_sorted
    Falsifiable, after 2 tests:
    function
    [2,3]

 I guess arbitrary for (Int - Int - Ordering) generates a non-sense
 function like this:

    -- let (arb_compare :: Int - Int - Ordering) generated function.
    arb_compare 0 1 = GT
    arb_compare 1 0 = GT
    arb_compare _ _ = EQ

 Then, I want to ask two questions.

 1. Is my guessing in function generated by arbitrary right?
 2. If so, How do I generate right function?

 Thanks,
 Yusaku Hashimoto

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




-- 
Eugene Kirpichov
Web IR developer, market.yandex.ru
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Generating arbitrary function in QuickCheck

2009-04-06 Thread Jason Dagit
On Mon, Apr 6, 2009 at 10:09 PM, Eugene Kirpichov ekirpic...@gmail.com wrote:
 Since the argument to sortBy must impose a linear ordering on its
 arguments, and any linear ordering may as well be generated by
 assigning an integer to each element of type 'a', and your sorting
 function is polymorphic, from the free theorem for the sorting
 function we may deduce that it suffices to test your function on
 integer lists with a casual comparison function (Data.Ord.compare),
 and there is no need to generate a random comparison function.

Interesting.  How is this free theorem stated for the sorting
function?  Intuitively I understand that if the type is polymorphic,
then it seems reasonable to just pick one type and go with it.

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


Re: [Haskell-cafe] replicateM should be called mreplicate?

2009-04-06 Thread David Menendez
On Mon, Apr 6, 2009 at 1:46 PM, Luke Palmer lrpal...@gmail.com wrote:
 On Mon, Apr 6, 2009 at 11:42 AM, David Menendez d...@zednenem.com wrote:

 Of course, this suggests that mfix should be fixM, so perhaps a better
 distinction is that mplus and mfix need to be defined per-monad,
 whereas filterM and replicateM are generic.

 Don't you think that is an incidental distinction, not an essential one?  It
 would be like naming our favorite operations mbind and joinM, just because
 of the way we happened to write the monad class.

Fair enough. I only added that comment when I noticed that my
explanation for picking replicateM over mreplicate also applied to
mfix.

Looking through Control.Monad, I see that all the *M functions require
Monad, whereas the m* functions require MonadPlus (or MonadFix). I
wonder to what extent that pattern holds in other libraries?

-- 
Dave Menendez d...@zednenem.com
http://www.eyrie.org/~zednenem/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe