Re: [Haskell-cafe] Programming Chalenges: The 3n+1 problem

2011-04-15 Thread David Virebayre
2011/4/14 Sebastian Fischer fisc...@nii.ac.jp


 The advantage of this complicated definition is that you get a
 memoized version of the `fibonacci` function simply by using `fixmemo`
 instead of `fix`:


Wow. I think something about 'fix' just made sense thanks to your post,
though I had read a few blog posts about it.

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


Re: [Haskell-cafe] Programming Chalenges: The 3n+1 problem

2011-04-15 Thread Sebastian Fischer
On Thu, Apr 14, 2011 at 8:02 PM, Luke Palmer lrpal...@gmail.com wrote:

 For this problem, it is too slow to memoize everything; you have to use a
 bounded memo table.  That's why I use a combinator-based memo approach as
 opposed to the type-directed approach used in eg. MemoTrie.  The memo table
 you need is something like

 switch (10^6) integral id


I think because of the definition of `Data.Function.fix`

 fix f = let x = f x in x

which uses sharing, the definition

fibonacci = fix (switch (10^6) integral id . fib)

chaches results even of independent global calls. If `fix` would be defined
as

fix f = f (fix f)

it would only cache the recursive calls of each individual call.

Do you agree?

Here is a fixpoint combinator that is parameterized by a memo combinator:

fixmemo :: Memo a - ((a - b) - (a - b)) - (a - b)
fixmemo memo f = fix (memo . f)

If I use

fixmemo (switch (=10^6) integral id) collatz

the computation of the maximum Collatz length between 1 and 10^6 takes
around 16 seconds (rather than 4 seconds without memoization). But when
using

fixmemo (arrayRange (1,10^6)) collatz

memoization actually pays off and run time goes down to around 3 seconds. I
uploaded the program underlying my experiments to github (spoiler alert):

https://gist.github.com/921469

I knew that memocombinators are more flexible than a type-based MemoTrie but
it is nice to see that they also lead to more efficient implementations and
allow to define the other array-based implementation from this thread in a
modular way.

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


[Haskell-cafe] build fails due to sem_close...

2011-04-15 Thread Jiri Skala
Hi all,
I've got error listed below when I've tried to build ghc-7.0.2 on ppc64
arch. I 've tested patch from Debian (-pthread option) but this didn't
fix the issue.

Any idea what's wrong?

Thanks for any tip/help.

Jiri


used packages:

glibc: 2.12.90, 2.13.90 (tested for both)
gcc: 4.6.0


I use these options for ppc64 arch in build.mk

%ifarch ppc64
GhcUnregisterised=YES
GhcWithNativeCodeGen=NO
SplitObjs=NO
GhcWithInterpreter=NO
GhcNotThreaded=YES
SRC_HC_OPTS+=-optc-mminimal-toc
SRC_CC_OPTS+=-mminimal-toc -Wa,--noexecstack
%endif


error log:

configure: Building in-tree ghc-pwd
/usr/bin/ld: 
/usr/lib64/ghc-7.0.2/unix-2.4.2.0/libHSunix-2.4.2.0.a(Semaphore.o): undefined 
reference to symbol 'sem_close@@GLIBC_2.3'
/usr/bin/ld: note: 'sem_close@@GLIBC_2.3' is defined in
DSO /lib64/libpthread.so.0 so try adding it to the linker command line
/lib64/libpthread.so.0: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
configure: error: Building ghc-pwd failed



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


Re: [Haskell-cafe] build fails due to sem_close...

2011-04-15 Thread Joachim Breitner
Hi,

Am Freitag, den 15.04.2011, 13:31 +0200 schrieb Jiri Skala:
 Hi all,
 I've got error listed below when I've tried to build ghc-7.0.2 on ppc64
 arch. I 've tested patch from Debian (-pthread option) but this didn't
 fix the issue.
 
 Any idea what's wrong?
 
 Thanks for any tip/help.

it should help :-). Have you run autoconf after changing configure.in,
and have you rebuilt unix afterwards? We have:

# ghc-pkg field unix extra-libraries
extra-libraries: rt util dl pthread

Greetings,
Joachim

-- 
Joachim nomeata Breitner
  mail: m...@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C
  JID: nome...@joachim-breitner.de | http://www.joachim-breitner.de/
  Debian Developer: nome...@debian.org


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Cairo and Haskell

2011-04-15 Thread Paulo J. Matos

Hi,

I would like to use Haskell to generate automatically a poster.
I guess that would be using Cairo so I can have a 2d canvas to draw in 
and maybe even preview before exporting to PDF.


However, I can't find any documentation on Cairo with Haskell or any 
code examples related to what I want to do.


Any suggestions?

Cheers,

--
PMatos


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


Re: [Haskell-cafe] Cairo and Haskell

2011-04-15 Thread Robert Wills
Have a look at

http://hackage.haskell.org/package/diagrams

and

http://hackage.haskell.org/package/Hieroglyph


On Fri, Apr 15, 2011 at 2:54 PM, Paulo J. Matos pocma...@gmail.com wrote:
 Hi,

 I would like to use Haskell to generate automatically a poster.
 I guess that would be using Cairo so I can have a 2d canvas to draw in and
 maybe even preview before exporting to PDF.

 However, I can't find any documentation on Cairo with Haskell or any code
 examples related to what I want to do.

 Any suggestions?

 Cheers,

 --
 PMatos


 ___
 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] Cairo and Haskell

2011-04-15 Thread Chris Smith
Haskell has Cairo bindings as part of gtk2hs.  The package on Hackage is
called 'cairo'.  You can certainly preview on the screen, but I'm less sure
about exporting to PDF, since the bindings were intended for GUI
programming.  At least PNG output is possible, though; PDF may be, as well.

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


Re: [Haskell-cafe] Cairo and Haskell

2011-04-15 Thread Chris Smith
To answer my own email, yes, PDF support is there.
On Apr 15, 2011 8:17 AM, Chris Smith cdsm...@gmail.com wrote:
 Haskell has Cairo bindings as part of gtk2hs. The package on Hackage is
 called 'cairo'. You can certainly preview on the screen, but I'm less sure
 about exporting to PDF, since the bindings were intended for GUI
 programming. At least PNG output is possible, though; PDF may be, as well.

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


[Haskell-cafe] timsort

2011-04-15 Thread Ben
hello --

has anyone every implemented (and benchmarked) timsort in haskell?

http://bugs.python.org/file4451/timsort.txt

it is a stable mergesort-like algorithm, seems like a good fit for haskell.

best, ben

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


Re: [Haskell-cafe] Cairo and Haskell

2011-04-15 Thread John Obbele
On Fri, Apr 15, 2011 at 08:19:02AM -0600, Chris Smith wrote:
 On Apr 15, 2011 8:17 AM, Chris Smith cdsm...@gmail.com wrote:
  Haskell has Cairo bindings as part of gtk2hs. The package on Hackage is
  called 'cairo'. You can certainly preview on the screen, but I'm less sure
  about exporting to PDF, since the bindings were intended for GUI
  programming. At least PNG output is possible, though; PDF may be, as well.

 To answer my own email, yes, PDF support is there.

You can also take a look at the demo programs in the cairo
package:

bash $ mkdir /tmp/uncabal  cd /tmp/uncabal
bash $ cabal unpack cairo
bash $ cd /tmp/uncabal/cairo-*/demo
bash $ runghc StarAndRing.hs

The gtk2hs bindings are generaly pretty dumb and just mimic the
original C behaviour. So the best source of documentation is
the original cairo website:
http://cairographics.org/documentation/

regards,
/john

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


Re: [Haskell-cafe] timsort

2011-04-15 Thread Daniel Fischer
On Friday 15 April 2011 16:42:22, Ben wrote:
 hello --
 
 has anyone every implemented (and benchmarked) timsort in haskell?
 
 http://bugs.python.org/file4451/timsort.txt
 
 it is a stable mergesort-like algorithm, seems like a good fit for
 haskell.
 
 best, ben

From a short look, it seems similar to the algorithm used in Data.List.sort 
(except for the minrun stuff, which I think is not much of a concern for 
linked lists).

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


Re: [Haskell-cafe] Cairo and Haskell

2011-04-15 Thread Paulo J. Matos

Thanks I will take a look at those.

On 15/04/11 15:12, Robert Wills wrote:

Have a look at

http://hackage.haskell.org/package/diagrams

and

http://hackage.haskell.org/package/Hieroglyph





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


Re: [Haskell-cafe] Cairo and Haskell

2011-04-15 Thread Paulo J. Matos

On 15/04/11 15:19, Chris Smith wrote:

To answer my own email, yes, PDF support is there.



Great, I assume it would also allow me to preview it on a GTK canvas, right?

--
PMatos


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


Re: [Haskell-cafe] Cairo and Haskell

2011-04-15 Thread Paulo J. Matos

On 15/04/11 16:13, John Obbele wrote:


bash $ mkdir /tmp/uncabal  cd /tmp/uncabal
bash $ cabal unpack cairo
bash $ cd /tmp/uncabal/cairo-*/demo
bash $ runghc StarAndRing.hs

The gtk2hs bindings are generaly pretty dumb and just mimic the
original C behaviour. So the best source of documentation is
the original cairo website:
 http://cairographics.org/documentation/


Awesome, just tried it and it worked! Will start off based on that! :)

--
PMatos


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


[Haskell-cafe] ANN: bindings to xfconf-4.8.0.0

2011-04-15 Thread John Obbele
Hi all,

I'm very happy to announce my first hackageDB package: xfconf[0], a
Haskell binding to the XFCE xfconfd configuration dæmon.

It's mainly a pet project I have done to learn Haskell using the
FFI and QuickCheck but if someone can find it useful or
instructive I would be happy.

This package allows easy access to your favorite XFCE desktop settings
(wallpaper, colors, police, etc.) and easier synchronisations between
the configuration backend and your own Gtk+2 widget properties (a
feature missing in gconf but now part of gsettings).

A practical use of this binding can be found in hThemes[1], a
quickdirty front-end to switch between pre-defined desktop themes (eg.
switching from a light-white theme for daytime to a dark-black one for
your nightly hack sessions).

[0.a]: http://hackage.haskell.org/package/xfconf
[0.b]: http://patch-tag.com/r/obbele/xfconf/home
[1]:   http://patch-tag.com/r/obbele/hThemes/home


Thanks to Andy Stewart and Axel Simon for their help in integrating
xfconf to the gtk2hs stack.

Any comments on this first work are welcomed ,-)

regards,
/John

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


[Haskell-cafe] Haskell Platform 2011.2.0.1 now available

2011-04-15 Thread Don Stewart
We're pleased to announce the 2011.2.0.1 release of the Haskell Platform:
a single, standard Haskell distribution for everyone.

Download the Haskell Platform 2011.2.0.1:

http://haskell.org/platform/

This release adds support for GHC 7.0.3, and significant improvements for
Mac OS X users.

The specification, along with installers (including Windows, Mac and
Unix installers for a full Haskell environment) are available.

The Haskell Platform is a single, standard Haskell distribution for
every system, in the form of a blessed library and tool suite for
Haskell distilled from the thousands of libraries on Hackage, along with
installers for a wide variety of systems. It saves developers work
picking and choosing the best Haskell libraries and tools to use for a
task.

When you install the Haskell Platform, you get the latest stable
compiler, an expanded set of core libraries, additional development
tools, and cabal-install – so you can download anything else you need
from Hackage.

This release ships with GHC 7.0.3.

What you get is specified here:

http://hackage.haskell.org/platform/contents.html

Thanks!

-- The Platform Infrastructure Team

P.S. a big thanks to Mark Lentczner and Mikhail Glushenkov who built the Mac
and Windows installers!

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


Re: [Haskell-cafe] Haskell Platform 2011.2.0.1 now available

2011-04-15 Thread Conal Elliott

 This release adds support for GHC 7.0.3, and significant improvements for
 Mac OS X users.


Enticing! What are these significant improvements for Mac OS X users?

  - Conal

On Fri, Apr 15, 2011 at 3:44 PM, Don Stewart don...@gmail.com wrote:

 We're pleased to announce the 2011.2.0.1 release of the Haskell Platform:
 a single, standard Haskell distribution for everyone.

 Download the Haskell Platform 2011.2.0.1:

http://haskell.org/platform/

 This release adds support for GHC 7.0.3, and significant improvements for
 Mac OS X users.

 The specification, along with installers (including Windows, Mac and
 Unix installers for a full Haskell environment) are available.

 The Haskell Platform is a single, standard Haskell distribution for
 every system, in the form of a blessed library and tool suite for
 Haskell distilled from the thousands of libraries on Hackage, along with
 installers for a wide variety of systems. It saves developers work
 picking and choosing the best Haskell libraries and tools to use for a
 task.

 When you install the Haskell Platform, you get the latest stable
 compiler, an expanded set of core libraries, additional development
 tools, and cabal-install – so you can download anything else you need
 from Hackage.

 This release ships with GHC 7.0.3.

 What you get is specified here:

http://hackage.haskell.org/platform/contents.html

 Thanks!

 -- The Platform Infrastructure Team

 P.S. a big thanks to Mark Lentczner and Mikhail Glushenkov who built the
 Mac
 and Windows installers!

 ___
 Libraries mailing list
 librar...@haskell.org
 http://www.haskell.org/mailman/listinfo/libraries

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


[Haskell-cafe] 64 bit generic link warning on every compile

2011-04-15 Thread Andrew Pennebaker
 GHC 7 compiles fine, but there's an additional warning during linking.

$ system_profiler SPSoftwareDataType | grep System Version
  System Version: Mac OS X 10.6.7 (10J869)
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.2
$ cat hello.hs
#!/usr/bin/env runhaskell

module Main where

main :: IO ()
main = putStrLn Hello World
$ ghc --make hello.hs
[1 of 1] Compiling Main ( hello.hs, hello.o )
Linking hello ...
ld: warning: -read_only_relocs cannot be used with x86_64
$ ./hello
Hello World

Cheers,

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


Re: [Haskell-cafe] Haskell Platform 2011.2.0.1 now available

2011-04-15 Thread Don Stewart
XCode 4 works, amongst other things:

http://www.haskell.org/ghc/docs/7.0.3/html/users_guide/release-7-0-3.html

Cheers,
   Don

On Fri, Apr 15, 2011 at 7:15 PM, Conal Elliott co...@conal.net wrote:
 This release adds support for GHC 7.0.3, and significant improvements for
 Mac OS X users.

 Enticing! What are these significant improvements for Mac OS X users?

   - Conal

 On Fri, Apr 15, 2011 at 3:44 PM, Don Stewart don...@gmail.com wrote:

 We're pleased to announce the 2011.2.0.1 release of the Haskell Platform:
 a single, standard Haskell distribution for everyone.

 Download the Haskell Platform 2011.2.0.1:

    http://haskell.org/platform/

 This release adds support for GHC 7.0.3, and significant improvements for
 Mac OS X users.

 The specification, along with installers (including Windows, Mac and
 Unix installers for a full Haskell environment) are available.

 The Haskell Platform is a single, standard Haskell distribution for
 every system, in the form of a blessed library and tool suite for
 Haskell distilled from the thousands of libraries on Hackage, along with
 installers for a wide variety of systems. It saves developers work
 picking and choosing the best Haskell libraries and tools to use for a
 task.

 When you install the Haskell Platform, you get the latest stable
 compiler, an expanded set of core libraries, additional development
 tools, and cabal-install – so you can download anything else you need
 from Hackage.

 This release ships with GHC 7.0.3.

 What you get is specified here:

    http://hackage.haskell.org/platform/contents.html

 Thanks!

 -- The Platform Infrastructure Team

 P.S. a big thanks to Mark Lentczner and Mikhail Glushenkov who built the
 Mac
 and Windows installers!

 ___
 Libraries mailing list
 librar...@haskell.org
 http://www.haskell.org/mailman/listinfo/libraries



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


Re: [Haskell-cafe] 64 bit generic link warning on every compile

2011-04-15 Thread Lyndon Maydwell
I get this too.

I've heard that it is resolved in 7.0.3 but I can't recall where.

(System Version: Mac OS X 10.6.7 (10J869), The Glorious Glasgow
Haskell Compilation System, version 7.0.2)

On Sat, Apr 16, 2011 at 10:47 AM, Andrew Pennebaker
andrew.penneba...@gmail.com wrote:
 GHC 7 compiles fine, but there's an additional warning during linking.
 $ system_profiler SPSoftwareDataType | grep System Version
       System Version: Mac OS X 10.6.7 (10J869)
 $ ghc --version
 The Glorious Glasgow Haskell Compilation System, version 7.0.2
 $ cat hello.hs
 #!/usr/bin/env runhaskell
 module Main where
 main :: IO ()
 main = putStrLn Hello World
 $ ghc --make hello.hs
 [1 of 1] Compiling Main             ( hello.hs, hello.o )
 Linking hello ...
 ld: warning: -read_only_relocs cannot be used with x86_64
 $ ./hello
 Hello World
 Cheers,
 Andrew Pennebaker
 www.yellosoft.us
 ___
 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