Re: [GHC] #1232: generalise runhaskell to support arbitrary file names, not just those with .{l}hs extensions

2007-04-22 Thread Frederik Eaton
By the way, I replied to this via email because I can't figure out how
to annotate the bug anymore. I'm rather stumped... I thought email
replies might automatically become associated with the bug.

Frederik

On Sat, Apr 14, 2007 at 01:04:52PM +0100, Frederik Eaton wrote:
 Hi Igloo,
 
 We are not suggesting that runhaskell should support a leading #! line
 - it already does. The argument is about whether it should support
 files that don't have an extension.
 
 Also, this is a tangent, but: for files that start with #!, I
 generally interpret the lines following the first line as the real
 file. I.e., if a file is being interpreted via the #! mechanism by (or
 any other interpreter), then the interpreter should consider
 everything following the initial line to be the real file for the
 purposes of code parsing. If the interpreter doesn't know whether it
 is being run via #! or not, then it can simply check the first two
 characters of the file - if they are #! (which no legal haskell file
 starts with) then it should be safe to assume that it is.
 
 Frederik
 
 On Fri, Mar 30, 2007 at 08:03:04PM -, GHC wrote:
  #1232: generalise runhaskell to support arbitrary file names, not just 
  those with
  .{l}hs extensions
  -+--
   Reporter:  Frederik |  Owner: 
   Type:  feature request  | Status:  new
   Priority:  normal   |  Milestone:  6.8
  Component:  Compiler |Version:  6.6
   Severity:  normal   | Resolution: 
   Keywords:  runhaskell   | Difficulty:  Easy (1 hr)
   Testcase:   |   Architecture:  Multiple   
 Os:  Unknown  |  
  -+--
  Comment (by igloo):
  
   I don't think runhaskell should be encouraging people to write files that
   aren't valid Haskell, and thus that a Haskell-compliant implementation
   might not be able to load.
  
   I wouldn't object to Haskell' saying a leading `#!` line, or any line
   starting with `#` or `#!`, will be treated as a comment, though (something
   like this seems to be where we are in practice anyway).
  
  -- 
  Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1232
  GHC http://www.haskell.org/ghc/
  The Glasgow Haskell Compiler
 
  ___
  Glasgow-haskell-bugs mailing list
  Glasgow-haskell-bugs@haskell.org
  http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
 
 
 -- 
 http://ofb.net/~frederik/
 ___
 Glasgow-haskell-bugs mailing list
 Glasgow-haskell-bugs@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
 

-- 
http://ofb.net/~frederik/
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #1232: generalise runhaskell to support arbitrary file names, not just those with .{l}hs extensions

2007-04-22 Thread Stefan O'Rear
On Sun, Apr 22, 2007 at 12:02:19PM +0100, Frederik Eaton wrote:
 By the way, I replied to this via email because I can't figure out how
 to annotate the bug anymore. I'm rather stumped... I thought email
 replies might automatically become associated with the bug.

I'm pretty sure they won't.

1) go to http://hackage.haskell.org/trac/ghc/ticket/1232

2) click on the login link, log in as guest/guest

   a) if you want a user, register, but you'll also need to have Ian
  Lynagh (email easily findable) activate it

3) type your comment

4) save changes

Stefan
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #1282: binary package wants uncheckedShift functions to be exported from base

2007-04-22 Thread GHC
#1282: binary package wants uncheckedShift functions to be exported from base
+---
 Reporter:  Isaac Dupree|  Owner:  
 Type:  bug | Status:  new 
 Priority:  normal  |  Milestone:  6.8 
Component:  libraries/base  |Version:  6.7 
 Severity:  normal  | Resolution:  
 Keywords:  | Difficulty:  Unknown 
 Testcase:  |   Architecture:  Multiple
   Os:  Multiple|  
+---
Changes (by igloo):

  * architecture:  powerpc = Multiple
  * component:  Compiler = libraries/base
  * milestone:  = 6.8
  * summary:  stg_uncheckedShift* not found: regression from ghc-6.6 to
  ghc-6.6.1 RC 6.6.20070415 (?) = binary package
  wants uncheckedShift functions to be exported
  from base
  * version:  6.6 = 6.7
  * os:  Linux = Multiple

Comment:

 I don't think that these names are intended to be part of the interface of
 base - not even part of the internal GHC.* interface. Nevertheless I've
 reverted the names for 6.6.1 so binary will continue to work.

 However, for 6.8, it would be better to have any necessary functions
 exported by GHC.Int/GHC.Word/GHC.Base/GHC.Exts/... instead. I'm not sure
 if you need a word-sized unchecked shift, a 64-bit one, or something else?

 (moving the bug to the 6.8 milestone as the 6.6 branch part should be
 fixed now)

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1282
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #1232: generalise runhaskell to support arbitrary file names, not just those with .{l}hs extensions

2007-04-22 Thread Frederik Eaton
On Sun, Apr 22, 2007 at 08:44:44AM -0700, Stefan O'Rear wrote:
 On Sun, Apr 22, 2007 at 12:02:19PM +0100, Frederik Eaton wrote:
  By the way, I replied to this via email because I can't figure out how
  to annotate the bug anymore. I'm rather stumped... I thought email
  replies might automatically become associated with the bug.
 
 I'm pretty sure they won't.
 
 1) go to http://hackage.haskell.org/trac/ghc/ticket/1232
 
 2) click on the login link, log in as guest/guest
 
a) if you want a user, register, but you'll also need to have Ian
   Lynagh (email easily findable) activate it
 
 3) type your comment
 
 4) save changes

OK, thanks. I should have checked this myself to begin with - your
instructions work with guest/guest. I already have my own account, and
it is that account under which I cannot edit. I'll brashly presume
that my editing privileges haven't been revoked with a purpose in
mind, and procede to add the comment as 'guest'...

Frederik

-- 
http://ofb.net/~frederik/
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #1232: generalise runhaskell to support arbitrary file names, not just those with .{l}hs extensions

2007-04-22 Thread Stefan O'Rear
On Sun, Apr 22, 2007 at 06:53:44PM +0100, Frederik Eaton wrote:
 On Sun, Apr 22, 2007 at 08:44:44AM -0700, Stefan O'Rear wrote:
  On Sun, Apr 22, 2007 at 12:02:19PM +0100, Frederik Eaton wrote:
   By the way, I replied to this via email because I can't figure out how
   to annotate the bug anymore. I'm rather stumped... I thought email
   replies might automatically become associated with the bug.
  
  I'm pretty sure they won't.
  
  1) go to http://hackage.haskell.org/trac/ghc/ticket/1232
  
  2) click on the login link, log in as guest/guest
  
 a) if you want a user, register, but you'll also need to have Ian
Lynagh (email easily findable) activate it
  
  3) type your comment
  
  4) save changes
 
 OK, thanks. I should have checked this myself to begin with - your
 instructions work with guest/guest. I already have my own account, and
 it is that account under which I cannot edit. I'll brashly presume
 that my editing privileges haven't been revoked with a purpose in
 mind, and procede to add the comment as 'guest'...

No, ping Ian Lynagh.  Your editing privledges were revoked because
spambots have become smart enough to register accounts, so he
deactivated all existing and new accounts.  He will reactivate yours
if you send him email and promise him you are human (or at least
benevolent). 
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #1232: generalise runhaskell to support arbitrary file names, not just those with .{l}hs extensions

2007-04-22 Thread GHC
#1232: generalise runhaskell to support arbitrary file names, not just those 
with
.{l}hs extensions
-+--
 Reporter:  Frederik |  Owner: 
 Type:  feature request  | Status:  new
 Priority:  normal   |  Milestone:  6.8
Component:  Compiler |Version:  6.6
 Severity:  normal   | Resolution: 
 Keywords:  runhaskell   | Difficulty:  Easy (1 hr)
 Testcase:   |   Architecture:  Multiple   
   Os:  Unknown  |  
-+--
Comment (by guest):

 We are not suggesting that runhaskell should support a leading #! line -
 it already does. The argument is about whether it should support files
 that don't have an extension.

 Also, this is a tangent, but: for files that start with #!, I generally
 read the lines following the first line as the real file. I.e., if a
 file is being interpreted via the #! mechanism by runhaskell (or any other
 interpreter), then the interpreter should consider everything following
 the initial line to be the real file for the purposes of code parsing.
 If the interpreter doesn't know whether it is being run via #! or not,
 then it can simply check the first two characters of the file - if they
 are #! (which no legal haskell file starts with) then it should be safe
 to assume that it is. I don't really understand why a change to the
 language specification would be necessary in order for us to feel
 comfortable doing this. The only requirement for the specification need be
 that a leading '#!' should not have an alternative meaning, which I'm
 reasonably certain it never will.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1232
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #1284: GHC 6.6 does not compile on Slackware 11.0 linux

2007-04-22 Thread GHC
#1284: GHC 6.6 does not compile on Slackware 11.0 linux
--+-
 Reporter:  guest |  Owner: 
 Type:  bug   | Status:  closed 
 Priority:  normal|  Milestone: 
Component:  Build System  |Version:  6.6
 Severity:  critical  | Resolution:  fixed  
 Keywords:| Difficulty:  Unknown
 Testcase:|   Architecture:  x86
   Os:  Linux |  
--+-
Changes (by igloo):

  * resolution:  = fixed
  * status:  new = closed

Comment:

 I think this was fixed by:
 {{{
 Fri Jan 19 13:50:14 GMT 2007  Ian Lynagh [EMAIL PROTECTED]
   * Fixes for bootstrapping from HC files
 }}}
 i.e. 6.6.1 should work.


 Thanks

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1284
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #1282: binary package wants uncheckedShift functions to be exported from base

2007-04-22 Thread GHC
#1282: binary package wants uncheckedShift functions to be exported from base
+---
 Reporter:  Isaac Dupree|  Owner:  
 Type:  bug | Status:  new 
 Priority:  normal  |  Milestone:  6.8 
Component:  libraries/base  |Version:  6.7 
 Severity:  normal  | Resolution:  
 Keywords:  | Difficulty:  Unknown 
 Testcase:  |   Architecture:  Multiple
   Os:  Multiple|  
+---
Comment (by duncan):

 Yes, it'd clearly be better to be using an exported API. We'll try and
 figure out exactly what is needed and then see about getting that exported
 properly.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1282
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[Haskell] ANNOUNCE: xmonad 0.1

2007-04-22 Thread Spencer Janssen
The xmonad dev team is pleased to announce the inaugural release of:

xmonad: a tiling window manager
   http://xmonad.org

Xmonad is a minimalist tiling window manager for X, written in Haskell.
Windows are managed using automatic layout algorithms, which can be
dynamically reconfigured. At any time windows are arranged so as to
maximise the use of screen real estate. All features of the window
manager are accessible purely from the keyboard: a mouse is entirely
optional. Xmonad is configured in Haskell, and custom layout algorithms
may be implemented by the user in config files. A principle of Xmonad
is predictability: the user should know in advance precisely the window
arrangement that will result from any action.

By default xmonad provides three layout algorithms: tall, wide and
fullscreen. In tall or wide mode, windows are tiled and arranged to
prevent overlap and maximise screen use. Sets of windows are grouped
together on virtual screens, and each screen retains its own layout,
which may be reconfigured dynamically. Multiple physical monitors are
supported via Xinerama, allowing simultaneous display of a number of
screens.

By utilising the expressivity of a modern functional language with a
rich static type system, Xmonad provides a complete, featureful window
manager in less than 500 lines of code, with an emphasis on correctness
and robustness. Internal properties of the window manager are checked
using a combination of static guarantees provided by the type system,
and type-based automated testing. A benefit of this is that the code is
simple to understand, and easy to modify.  

More information, screenshots, documentation and community resources are
available from:

 http://xmonad.org

Xmonad is available from hackage, and via darcs. Happy hacking!

The Xmonad Team:

Spencer Janssen
Don Stewart
Jason Creigh
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] GHC

2007-04-22 Thread Preininger
hello

I have Suse 10.1

I try to compile the file hase.hs

the content of hase.hs is

module Main where
main = do putStrLn Hello World

I try another gmp and gmp-devel rpm's, no help where can i get the right gmp
rpm's`?

Thank you in advance for any help.

helmut

compile from KDevelop

cd '/home/helmut/hase/src'  ghc --make hase.hs -o
/home/helmut/hase/src/hase
[1 of 1] Compiling Main ( hase.hs, hase.o )
Linking /home/helmut/hase/src/hase ...
/usr/lib/ghc-6.6/libHSrts.a(Storage.o): In function `initStorage':
Storage.c:(.text+0xe2c): undefined reference to `__gmp_set_memory_functions'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `plusIntegerzh_fast':
ghc22140_0.hc:(.text+0x71d): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0x739): undefined reference to `__gmpz_add'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `minusIntegerzh_fast':
ghc22140_0.hc:(.text+0x7d6): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0x7f2): undefined reference to `__gmpz_sub'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `timesIntegerzh_fast':
ghc22140_0.hc:(.text+0x889): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0x8a5): undefined reference to `__gmpz_mul'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `gcdIntegerzh_fast':
ghc22140_0.hc:(.text+0x93d): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0x959): undefined reference to `__gmpz_gcd'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `quotIntegerzh_fast':
ghc22140_0.hc:(.text+0x9f6): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0xa12): undefined reference to `__gmpz_tdiv_q'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `remIntegerzh_fast':
ghc22140_0.hc:(.text+0xaa9): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0xac5): undefined reference to `__gmpz_tdiv_r'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function
`divExactIntegerzh_fast':
ghc22140_0.hc:(.text+0xb5d): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0xb79): undefined reference to `__gmpz_divexact'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `andIntegerzh_fast':
ghc22140_0.hc:(.text+0xc16): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0xc32): undefined reference to `__gmpz_and'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `orIntegerzh_fast':
ghc22140_0.hc:(.text+0xcc9): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0xce5): undefined reference to `__gmpz_ior'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `xorIntegerzh_fast':
ghc22140_0.hc:(.text+0xd7d): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0xd99): undefined reference to `__gmpz_xor'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function
`complementIntegerzh_fast':
ghc22140_0.hc:(.text+0xe12): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0xe26): undefined reference to `__gmpz_com'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `quotRemIntegerzh_fast':
ghc22140_0.hc:(.text+0xebd): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0xec9): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0xeed): undefined reference to `__gmpz_tdiv_qr'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `divModIntegerzh_fast':
ghc22140_0.hc:(.text+0xf99): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0xfa5): undefined reference to `__gmpz_init'
ghc22140_0.hc:(.text+0xfc9): undefined reference to `__gmpz_fdiv_qr'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `gcdIntzh_fast':
ghc22140_0.hc:(.text+0x1019): undefined reference to `__gmpn_gcd_1'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `gcdIntegerIntzh_fast':
ghc22140_0.hc:(.text+0x1039): undefined reference to `__gmpn_gcd_1'
/usr/lib/ghc-6.6/libHSrts.a(PrimOps.o): In function `cmpIntegerzh_fast':
ghc22140_0.hc:(.text+0x10f4): undefined reference to `__gmpn_cmp'
/usr/lib/ghc-6.6/libHSrts.a(Linker.o):(.data+0x14c): undefined reference to
`__gmpn_gcd_1'
/usr/lib/ghc-6.6/libHSrts.a(Linker.o):(.data+0x154): undefined reference to
`__gmpz_cmp'
/usr/lib/ghc-6.6/libHSrts.a(Linker.o):(.data+0x15c): undefined reference to
`__gmpz_cmp_si'
/usr/lib/ghc-6.6/libHSrts.a(Linker.o):(.data+0x164): undefined reference to
`__gmpz_cmp_ui'
/usr/lib/ghc-6.6/libHSrts.a(Linker.o):(.data+0x16c): undefined reference to
`__gmpz_get_si'
/usr/lib/ghc-6.6/libHSrts.a(Linker.o):(.data+0x174): undefined reference to
`__gmpz_get_ui'
collect2: ld returned 1 exit status
*** Beendet mit Status: 1 ***

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


Re: [Haskell] GHC

2007-04-22 Thread Johannes Waldmann

 [1 of 1] Compiling Main ( hase.hs, hase.o )
 Linking /home/helmut/hase/src/hase ...
 /usr/lib/ghc-6.6/libHSrts.a(Storage.o): In function `initStorage':
 Storage.c:(.text+0xe2c): undefined reference to `__gmp_set_memory_functions'

this is strange since ghc itself has been compiled by ghc,
and your installations seems to be able to run ghc itself.
from where did you install? (binary rpm?)

find out where the actual ghc executable is:   cat $(which ghc)
something like  GHC_BIN=/usr/local/lib/ghc-6.6/ghc-6.6
and then look at the output of   ldd /usr/local/lib/ghc-6.6/ghc-6.6
this should tell you where  gmp.so  lives.
then you try to find out why the linker does not find it.

best regards, J. W.
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: Literate Haskell specification

2007-04-22 Thread Vivian McPhail

Dear Committee

If I recall correctly, in the tex-style literate haskell specification, code
is delimited by a

\begin{code}
\end{code}

This does not allow for multilanguage support in a single source file.  It
would be nice to have a single document in which we could mix English,
Haskell, and, for example, Coq proofs.

To this end, would it make more sense to delimit haskell code by

\begin{haskell}
\end{haskell}

?

Cheers,

Vivian


Date: Fri, 06 Apr 2007 15:07:28 -0400

From: Isaac Dupree [EMAIL PROTECTED]
Subject: Literate Haskell specification
To: haskell-prime@haskell.org
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain; charset=ISO-8859-1

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

As I brought up earlier in Haskell-cafe
http://thread.gmane.org/gmane.comp.lang.haskell.cafe/20026
, the Haskell98 specification for literate haskell (report section 9.4)
could use some work, at least clarifications (existing haskell
implementations differ in some ways) - see that thread for details.
Since I haven't successfully gotten to writing a concrete revision of
that section, I thought I'd at least bring the issue to the attention of
specifically haskell-prime people, as it is an issue that should
definitely be addressed in the Report.  Hopefully there's someone
around here who might tackle it :)


Good luck,
Isaac
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGFppvHgcxvIWYTTURAgoqAKDKFXaVBVeSfodzlgEte5Loy42unACfXfbl
qDlxnSUaNH5rg8r58KAkKl8=
=UVvx
-END PGP SIGNATURE-

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


[Haskell-cafe] Re: How Albus Dumbledore would sell Haskell

2007-04-22 Thread apfelmus
Claus Reinke wrote:
 - oscon seems to be a huge event.

A bold idea would be to redo a talk of another speaker in Haskell and
accidentally surpass the techniques presented there :) Alas, this
doesn't work for OSCON since there are too many talks attendees have to
choose between and the event starts with the tutorials, so the audience
doesn't know a common talk it could compare the Haskell tutorial to.

Regards,
apfelmus

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


Re: [Haskell-cafe] Tutorial on Haskell: Use closures

2007-04-22 Thread Paul Johnson
Closures look like magic to those who don't know them.  So you might try 
something like this (which I have not compiled BTW):


 -- Haskell version

 data Train = Train {departs :: Time, platform :: Int }

 departsBefore :: Time - Train - Bool
 departsBefore t train = t  departs train

 beforeAfter :: Time - [Train] - ([Train], [Train])
 beforeAfter t = partition (departsBefore t) departures

The crucial point is that partition takes a function argument, but 
that function has to carry the 't' argument with it.


The only way you could write partition as a generic function in Java 
would be to define an interface class discriminator which is passed to 
partition.  discriminator is then specialised for every closure you 
want to create.  This is a lot of code for something that can be done 
in-line in Haskell.  The fact that all functions are curried by default 
also saves having lots of lambdas.


You might also show how deforestation optimises functional pipelines.  
Lots of Haskell code contains lines of the form


   foo = bar x $ foldr1 boz $ map baz ls

In other FP languages (like Erlang) you can use this style, but it tends 
to be inefficient because of all the intermediate lists.  Haskell is 
free to arrange the functions how it likes because of purity.  Hence it 
can optimise this pipeline into a single loop.  Obviously you know much 
more about this than I do, but to me its one of the biggest arguments in 
favour of purity.


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


[Haskell-cafe] ANNOUNCE: xmonad 0.1

2007-04-22 Thread Spencer Janssen
The xmonad dev team is pleased to announce the inaugural release of:

xmonad: a tiling window manager
   http://xmonad.org

Xmonad is a minimalist tiling window manager for X, written in Haskell.
Windows are managed using automatic layout algorithms, which can be
dynamically reconfigured. At any time windows are arranged so as to
maximise the use of screen real estate. All features of the window
manager are accessible purely from the keyboard: a mouse is entirely
optional. Xmonad is configured in Haskell, and custom layout algorithms
may be implemented by the user in config files. A principle of Xmonad
is predictability: the user should know in advance precisely the window
arrangement that will result from any action.

By default xmonad provides three layout algorithms: tall, wide and
fullscreen. In tall or wide mode, windows are tiled and arranged to
prevent overlap and maximise screen use. Sets of windows are grouped
together on virtual screens, and each screen retains its own layout,
which may be reconfigured dynamically. Multiple physical monitors are
supported via Xinerama, allowing simultaneous display of a number of
screens.

By utilising the expressivity of a modern functional language with a
rich static type system, Xmonad provides a complete, featureful window
manager in less than 500 lines of code, with an emphasis on correctness
and robustness. Internal properties of the window manager are checked
using a combination of static guarantees provided by the type system,
and type-based automated testing. A benefit of this is that the code is
simple to understand, and easy to modify.  

More information, screenshots, documentation and community resources are
available from:

 http://xmonad.org

Xmonad is available from hackage, and via darcs. Happy hacking!

The Xmonad Team:

Spencer Janssen
Don Stewart
Jason Creigh
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] newbie question on ordering

2007-04-22 Thread Nikolay Metchev

Hello guys,
I have decided to try and get back into Haskell recently. I have used it in
the past but have forgotten large chunks.
I am trying to express the logic of a particular card game. For this purpose
I need to be able to order cards in various orders. At first I thought that
the Ord class was my answer but I found it very verbose. Below is my best
attempt so far but I can't help but feel it too is verbose and that there
must be a better way of comparing cards in different orders.

data Face = Ace | Two | Three | Four | Five | Six | Seven | Eight | Nine
 | Ten | Jack | Queen | King deriving (Enum, Show, Eq)

data Suit = Clubs | Diamonds | Hearts | Spades deriving (Show, Enum, Eq)

type Card = (Face, Suit)

listComparator :: (Eq a) = [a] - a - a - Ordering
listComparator xs a b = compare x y
   where
 x = elemIndex a xs
 y = elemIndex b xs

sequentialBonusFaceOrder :: [Face]
sequentialBonusFaceOrder  = [Seven, Eight, Nine, Ten, Jack, Queen, King,
Ace]

fourOfAKindBonusFaceOrder :: [Face]
fourOfAKindBonusFaceOrder = [Queen, King, Ten, Ace, Nine, Jack]

sequentialBonusFaceComparator :: Face - Face - Ordering
sequentialBonusFaceComparator = listComparator sequentialBonusFaceOrder

fourOfAKindBonusFaceComparator :: Face - Face - Ordering
fourOfAKindBonusFaceComparator = listComparator fourOfAKindBonusFaceOrder

The problem with this approach is that if you want to compare you to write
things of the following nature:
fourOfAKindBonusFaceComparator f1 f2 == GT

this isn't very clear especially if you want = you have to do
fourOfAKindBonusFaceComparator f1 f2 /= GT

Any suggestions would be nice.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Bryan O'Sullivan

Ketil Malde wrote:


Hm - nobody suggested using ByteStrings yet?


I wrote an independent port of Norvig's spellchecker, because I figured 
it would make the basis of an interesting tutorial.  For such a small 
program, it's been quite a challenge!


I started out using lazy ByteStrings, Data.Map, and Data.Set.  As Albert 
observed, using Data.Set is poison for heap size and performance.  The 
result of switching from sets to lists was a  90% reduction in memory 
usage, and a big (but unmeasured) speedup.


After this switch, I found that spellchecking one word still took 4x as 
long in Haskell as Norvig's Python program.  Since I was checking only 
one word in each case, essentially all of the runtime was taken up by 
building the word frequency map.


In my profile results, I find that simply converting words to lower case 
accounts for a whopping 40% of time and allocation (see the attachment 
for my definition of the train function).


COST CENTREMODULE   %time %alloc

lower  Spell 40.5   41.2
train  Spell 26.3   14.3
mkWordsSpell 21.9   24.1

I was interested in building a profile-enabled version of fps to see 
what might be going on inside the library, but was stymied by not 
knowing how to get GHC 6.6's base to coexist peacefully with fps (hiding 
base isn't very practical).


My experiments are available here:

darcs get http://darcs.serpentine.com/spell

Norvig's training data is available from http://norvig.com/big.txt

b
import qualified Data.Map as M
import qualified Data.ByteString.Lazy.Char8 as B
import qualified Data.ByteString.Lazy as X

type Model = M.Map B.ByteString Int

train :: B.ByteString - Model

train = foldl' updateMap M.empty . map lower . mkWords
where updateMap model word = M.insertWith' (+) word 1 model
  mkWords = filter (not . B.null) . X.splitWith isNotAlpha
  lower !s = X.map toLower s
  isNotAlpha !c = c  0x41 || (c  0x5a  c  0x61) || c  0x7a
  toLower !c | c = 0x41  c = 0x5a = c + 0x20
 | otherwise = c
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Performance and STUArrays

2007-04-22 Thread Dominic Steinitz
I've been playing around some more trying improve the performance of the SHA1 
implmentation in the crypto library. I've isolated one of the functions and 
implemented it using

a) unfold

and

b) STUArray

The STUArray implementation is about twice as fast but I was expecting an 
order of magnitude improvement given I thought I would have been allocating 
16 x 80 new 32 bit words with unfold but nothing with the STUArray. 

Should I have been disappointed?

[EMAIL PROTECTED]:~/sha12 time ./arrTest 17 STUArray  /dev/null

real0m11.102s
user0m9.129s
sys 0m0.112s
[EMAIL PROTECTED]:~/sha12 time ./arrTest 17 Unfold  /dev/null

real0m18.381s
user0m16.361s
sys 0m0.212s

Dominic.

import Data.Bits
import Data.List
import Data.Word
import Control.Monad.ST
import Data.Array.ST
import System
import System.IO

data Word160 = Word160 !Word32 !Word32 !Word32 !Word32 !Word32
   deriving (Eq, Show)

ss :: Word160
ss = Word160 0x67452301 0xefcdab89 0x98badcfe 0x10325476 0xc3d2e1f0

test :: [Word32]
test = [0x61626380, 0x, 0x, 0x,
0x, 0x, 0x, 0x,
0x, 0x, 0x, 0x,
0x, 0x, 0x, 0x0018]

tests :: Int - [[Word32]]
tests n = map (\n - n:[0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
0x0, 0x0, 0x0, 0x18]) [1..2^n]

rotL :: Bits b = Int - b - b
rotL = flip rotateL

v1 :: a - [Word32] - [Word32]
v1 ss xs = take 80 (n xs)
   where
  h [w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15] 
=
 Just (w0,[w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, 
w14, w15, (rotL 1 (w0 `xor` w2 `xor` w8 `xor` w13))])
  n = unfoldr h

v2 ss xs = vs
   where
  us =
 do w - newArray (0,79) 0 :: ST s (STUArray s Int Word32)
let initLoop 15 = writeArray w 15 (xs!!15)
initLoop n = 
   do writeArray w n (xs!!n)
  initLoop (n+1)
mainLoop 79 = nextW 79
mainLoop n =
   do nextW n
  mainLoop (n+1)
nextW n = 
   do wm16 - readArray w (n-16)
  wm14 - readArray w (n-14)
  wm8  - readArray w (n-8)
  wm3  - readArray w (n-3)
  writeArray w n (rotL 1 (wm3 `xor` wm8 `xor` wm14 `xor` 
wm16))
initLoop 0
mainLoop 16
getElems w
  vs = runST us

test1 n = map (v1 ss) (tests n)
test2 n = map (v2 ss) (tests n)

data TestType = Unfold | STUArray
   deriving (Eq, Read, Show)

main =
   do progName - getProgName
  args - getArgs
  if length args /= 2
 then putStrLn (Usage:  ++ progName ++  testSize testType)
 else do let n = read (args!!0)
 t = read (args!!1)
 if t == Unfold
then putStrLn (show (test1 n))
else putStrLn (show (test2 n))

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


[Haskell-cafe] Is there a best *nix or BSD distro for Haskell hacking?

2007-04-22 Thread David Cabana
I have a spare Windows machine I want to put to better use.  I want  
to turn it into a Haskell hacking box, and was wondering whether any  
particular *nix or BSD distribution is best (or worst) suited for  
this.  Any thoughts?


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


Re: [Haskell-cafe] Is there a best *nix or BSD distro for Haskell hacking?

2007-04-22 Thread brad clawsie
On Sun, Apr 22, 2007 at 10:07:32AM -0400, Tom Harper wrote:
  I'd go with the one you feel is the best desktop OS.  For me that
  usually counts BSD out (great server, bad desktop).

this is not true. freebsd in particular supports all of the latest
free desktops and also has good support for haskell packages:

http://www.freebsd.org/cgi/ports.cgi?query=haskellstype=all

the only downside for new users is that freebsd by default does not
use a livecd for installation

ubuntu offers a livecd installation and has a great selection of
haskell packages as well by virtue of its debian roots
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Ketil Malde
On Sun, 2007-04-22 at 00:25 -0400, Pete Kazmier wrote:
 Pete Kazmier [EMAIL PROTECTED] writes:
 
  I'd love to see other Haskell implementations as well if anyone has a
  few moments to spare.  Admittedly, it took me several hours to get my
  version working, but I'm a Haskell newbie.  Unfortunately, I think it
  runs as slow as it took me to write it!

Hm - nobody suggested using ByteStrings yet?  String is notoriously
wasteful, and replacing it with ByteString normally gives a quite
significant speedup.

Worse - and this is true for ByteStrings, too - String comparisons are
O(n), which means lookups in Sets and Maps are expensive.  A trie (i.e,
a search tree where each internal node corresponds to a word prefix, and
has one branch per letter in the alphabet) will give you lookup that
scales with word size (and possibly alphabet size).

Instead of generating the (huge) list of misspelled words, you could
calculate edit distance to each correctly spelled word?  With a bound on
allowable mistakes, this is a linear time operation using the standard
dynamic programming algorithm.

-k



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


[Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Pete Kazmier
Ketil Malde [EMAIL PROTECTED] writes:

 On Sun, 2007-04-22 at 00:25 -0400, Pete Kazmier wrote:
 Pete Kazmier [EMAIL PROTECTED] writes:
 
  I'd love to see other Haskell implementations as well if anyone has a
  few moments to spare.  Admittedly, it took me several hours to get my
  version working, but I'm a Haskell newbie.  Unfortunately, I think it
  runs as slow as it took me to write it!

 Hm - nobody suggested using ByteStrings yet?  String is notoriously
 wasteful, and replacing it with ByteString normally gives a quite
 significant speedup.

I actually have a ByteString version but it runs much slower.  This
part of the code is where all of the time is spent in the ByteString
version:

  type WordFreq   = M.Map B.ByteString Int
 
  train:: [B.ByteString] - WordFreq
  train words = frequencyMap
  where
frequencyMap = foldr incWordCount M.empty words
incWordCount w m = M.insertWith (+) w 1 m
  
 Worse - and this is true for ByteStrings, too - String comparisons are
 O(n), which means lookups in Sets and Maps are expensive.  A trie (i.e,
 a search tree where each internal node corresponds to a word prefix, and
 has one branch per letter in the alphabet) will give you lookup that
 scales with word size (and possibly alphabet size).

Right.  My first version was just a direct translation of Norvig's
code with an emphasis on trying to keep the complexity and size of
code to a minimum.

 Instead of generating the (huge) list of misspelled words, you could
 calculate edit distance to each correctly spelled word?  With a bound on
 allowable mistakes, this is a linear time operation using the standard
 dynamic programming algorithm.

Could you provide additional information on this standard dynamic
programming algorithm?  I'm not familiar with dynamic programming.

Thanks!
Pete

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


Re: [Haskell-cafe] Is there a best *nix or BSD distro for Haskell hacking?

2007-04-22 Thread David Cabana
I'm not dissing Windows; I work with it all the time, just not for  
Haskell. On the other hand, I am writing this on my Powerbook.


My desire to use linux is mostly aesthetic. I want to go mouse free  
(I'm thinking Xmonad), and neither Windows nor OS X naturally lends  
itself to that.  With respect to choice of linux, the machine I have  
in mind is not terribly fast, so I prefer to install from binaries  
rather than source.  Do  Debian and Ubuntu provide more or less the  
same Haskell packages?


On Apr 22, 2007, at 10:09 AM, Neil Mitchell wrote:


Hi David,

At the risk of getting into an OS war, its perfectly feasible to
develop Haskell on Windows. Some Haskell applications are only
available for Windows (WinHugs mainly), but you are likely to have a
less bumpy ride compiling GHC if you aren't on Windows.

Pick what you want, Gentoo and Debian are both quite well supported  
for Haskell.


Thanks

Neil

On 4/22/07, David Cabana [EMAIL PROTECTED] wrote:

I have a spare Windows machine I want to put to better use.  I want
to turn it into a Haskell hacking box, and was wondering whether any
particular *nix or BSD distribution is best (or worst) suited for
this.  Any thoughts?

Thank you,
David Cabana
___
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] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Pete Kazmier
Bryan O'Sullivan [EMAIL PROTECTED] writes:

 After this switch, I found that spellchecking one word still took 4x
 as long in Haskell as Norvig's Python program.  Since I was checking
 only one word in each case, essentially all of the runtime was taken
 up by building the word frequency map.

 train = foldl' updateMap M.empty . map lower . mkWords
 where updateMap model word = M.insertWith' (+) word 1 model
   mkWords = filter (not . B.null) . X.splitWith isNotAlpha
   lower !s = X.map toLower s
   isNotAlpha !c = c  0x41 || (c  0x5a  c  0x61) || c  0x7a
   toLower !c | c = 0x41  c = 0x5a = c + 0x20
  | otherwise = c

After reading Bryan's post, I switched my right fold to a strict left
fold and almost tripled my original speed.  Could someone provide some
guidelines on when to use each?  I thought foldr should be used when
building some large data structure such as the map I build.

Bryan, out of curiosity, is a non bytestring version of your code
faster?

Thanks,
Pete

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


Re: [Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Derek Elkins

Pete Kazmier wrote:

Bryan O'Sullivan [EMAIL PROTECTED] writes:


After this switch, I found that spellchecking one word still took 4x
as long in Haskell as Norvig's Python program.  Since I was checking
only one word in each case, essentially all of the runtime was taken
up by building the word frequency map.

train = foldl' updateMap M.empty . map lower . mkWords
where updateMap model word = M.insertWith' (+) word 1 model
  mkWords = filter (not . B.null) . X.splitWith isNotAlpha
  lower !s = X.map toLower s
  isNotAlpha !c = c  0x41 || (c  0x5a  c  0x61) || c  0x7a
  toLower !c | c = 0x41  c = 0x5a = c + 0x20
 | otherwise = c


After reading Bryan's post, I switched my right fold to a strict left
fold and almost tripled my original speed.  Could someone provide some
guidelines on when to use each?  I thought foldr should be used when
building some large data structure such as the map I build.

Bryan, out of curiosity, is a non bytestring version of your code
faster?


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


[Haskell-cafe] Compilling GHC on Vista

2007-04-22 Thread Monique Monteiro

Hi all,

 I'm trying to compile GHC on Windows Vista, but I encountered the
following error when running ./configure --host=i386-unknown-mingw32
--with-gcc=c:/MinGW/bin/gcc:

configure: error: C compiler cannot create executables
See `config.log' for more details.
./configure: line 3404: cannot create temp file for here document: No such file
or directory
./configure: line 3441: cannot create temp file for here document: No such file
or directory

Has anyone any idea about what may be happening?

Thanks in advance,

Monique

--
__
Monique Monteiro, MSc
MCP .NET Framework 2.0 / SCJP / IBM OOAD
Project Manager
Recife Microsoft Innovation Center
+55 81 34198137
http://www.cin.ufpe.br/~mlbm
http://thespoke.net/blogs/moniquelouise/default.aspx
[EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is there a best *nix or BSD distro for Haskell hacking?

2007-04-22 Thread Neil Mitchell

Hi David,

At the risk of getting into an OS war, its perfectly feasible to
develop Haskell on Windows. Some Haskell applications are only
available for Windows (WinHugs mainly), but you are likely to have a
less bumpy ride compiling GHC if you aren't on Windows.

Pick what you want, Gentoo and Debian are both quite well supported for Haskell.

Thanks

Neil

On 4/22/07, David Cabana [EMAIL PROTECTED] wrote:

I have a spare Windows machine I want to put to better use.  I want
to turn it into a Haskell hacking box, and was wondering whether any
particular *nix or BSD distribution is best (or worst) suited for
this.  Any thoughts?

Thank you,
David Cabana
___
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] Is there a best *nix or BSD distro for Haskell hacking?

2007-04-22 Thread Dan Mead

I've tried doing haskell projects on fedora ubuntu and gentoo and gentoo was
by far
the best supported.

-Dan

On 4/22/07, David Cabana [EMAIL PROTECTED] wrote:


I'm not dissing Windows; I work with it all the time, just not for
Haskell. On the other hand, I am writing this on my Powerbook.

My desire to use linux is mostly aesthetic. I want to go mouse free
(I'm thinking Xmonad), and neither Windows nor OS X naturally lends
itself to that.  With respect to choice of linux, the machine I have
in mind is not terribly fast, so I prefer to install from binaries
rather than source.  Do  Debian and Ubuntu provide more or less the
same Haskell packages?

On Apr 22, 2007, at 10:09 AM, Neil Mitchell wrote:

 Hi David,

 At the risk of getting into an OS war, its perfectly feasible to
 develop Haskell on Windows. Some Haskell applications are only
 available for Windows (WinHugs mainly), but you are likely to have a
 less bumpy ride compiling GHC if you aren't on Windows.

 Pick what you want, Gentoo and Debian are both quite well supported
 for Haskell.

 Thanks

 Neil

 On 4/22/07, David Cabana [EMAIL PROTECTED] wrote:
 I have a spare Windows machine I want to put to better use.  I want
 to turn it into a Haskell hacking box, and was wondering whether any
 particular *nix or BSD distribution is best (or worst) suited for
 this.  Any thoughts?

 Thank you,
 David Cabana
 ___
 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] IDE support

2007-04-22 Thread Philipp Volgger
What IDE support is available for Haskell (Visuall Haskell, EclipseFP), 
anything else?



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


Re: [Haskell-cafe] Is there a best *nix or BSD distro for Haskell hacking?

2007-04-22 Thread Stefan O'Rear
On Sun, Apr 22, 2007 at 10:02:32AM -0400, David Cabana wrote:
 I have a spare Windows machine I want to put to better use.  I want  
 to turn it into a Haskell hacking box, and was wondering whether any  
 particular *nix or BSD distribution is best (or worst) suited for  
 this.  Any thoughts?

I'd like to advocate for Debian Sid.  Probably not the best for random
desktop uses, but you do get haskell packages within weeks of
announce, and there are no freezes or release timelines to annoy you!

PS: I've been running sid for 6mo now with no major system
malfunctions - don't let the unstable codename scare you off.  Then
again, my /usr/local/bin/ghc is HEAD installed from source
biweekly .. 

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


Re: [Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Bryan O'Sullivan

Pete Kazmier wrote:


Bryan, out of curiosity, is a non bytestring version of your code
faster?


No, but the difference is smaller than I expected: the lazy ByteString 
version is about 1.8x faster than using String.


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


Re: [Haskell-cafe] Is there a best *nix or BSD distro for Haskell hacking?

2007-04-22 Thread Lennart Augustsson
I have no idea why you say BSD is bad for the desktop.  I've run it  
as my desktop OS since about 1992.


-- Lennart

On Apr 22, 2007, at 15:07 , Tom Harper wrote:


I'd go with the one you feel is the best desktop OS.  For me that
usually counts BSD out (great server, bad desktop).  I'd stick with
your favourite version of Linux unless you have some special
requirements.

On 4/22/07, David Cabana [EMAIL PROTECTED] wrote:

I have a spare Windows machine I want to put to better use.  I want
to turn it into a Haskell hacking box, and was wondering whether any
particular *nix or BSD distribution is best (or worst) suited for
this.  Any thoughts?

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




--
Tom Harper
Computer Science Major '07
Syracuse University
+1 949 235 0185
Public Key: http://aftereternity.co.uk/rth.asc
___
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] IDE support

2007-04-22 Thread Marc Weber
On Sun, Apr 22, 2007 at 07:34:27PM +0200, Philipp Volgger wrote:
 What IDE support is available for Haskell (Visuall Haskell, EclipseFP), 
 anything else?

Hi Philipp.
I've written some completion scripts for vim. Don't know wether you can
call it an ide. Also tagging source is supported by one command.
With a little effort you can configure vim to create a new cabal project
using one command some settings, too.

If you're interested drop me a mail.
You can see some screenshots here http://www.mawercer.de/marcweber/vim/ss/vim/

There is also some emacs support I don't know much about.
All further information I could give you you can find on 
http://haskell.org/haskellwiki/Libraries_and_tools/Program_development  - 2. 
Editor support

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


Re: [Haskell-cafe] IDE support

2007-04-22 Thread Leif Frenzel

Hi,

On Sun, Apr 22, 2007 at 07:34:27PM +0200, Philipp Volgger wrote:
What IDE support is available for Haskell (Visuall Haskell, EclipseFP), 
anything else?
In addition, there are plugins for XCode, IntelliJ IDEA and KDevelop 
(don't have a specific link for the last one).


http://www.hoovy.org/HaskellXcodePlugin/
http://www.workingmouse.com/research/IntelliJIdea-Haskell/

Ciao,
Leif



Hi Philipp.
I've written some completion scripts for vim. Don't know wether you can
call it an ide. Also tagging source is supported by one command.
With a little effort you can configure vim to create a new cabal project
using one command some settings, too.

If you're interested drop me a mail.
You can see some screenshots here http://www.mawercer.de/marcweber/vim/ss/vim/

There is also some emacs support I don't know much about.
All further information I could give you you can find on 
http://haskell.org/haskellwiki/Libraries_and_tools/Program_development  - 2. 
Editor support

Marc
___
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] Is there a best *nix or BSD distro for Haskell hacking?

2007-04-22 Thread Ryan Dickie

My vote goes to ubuntu. I've been using it for a few years and before that I
tried a wide variety of distros. Ubuntu has a lot of polish, takes 20
minutes to install, and is just a really nice distribution overall. Things
just work. Ubuntu is debian based so if you chose against ubuntu my second
vote goes for debian.

Many of the haskell packages including darcs, ghc, and well over 100 other
packages (mostly libraries) are in the package manager ready to be
installed.

--ryan

On 4/22/07, David Cabana [EMAIL PROTECTED] wrote:


I have a spare Windows machine I want to put to better use.  I want
to turn it into a Haskell hacking box, and was wondering whether any
particular *nix or BSD distribution is best (or worst) suited for
this.  Any thoughts?

Thank you,
David Cabana
___
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] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Pete Kazmier
Derek Elkins [EMAIL PROTECTED] writes:

 After reading Bryan's post, I switched my right fold to a strict left
 fold and almost tripled my original speed.  Could someone provide some
 guidelines on when to use each?  I thought foldr should be used when
 building some large data structure such as the map I build.
 Bryan, out of curiosity, is a non bytestring version of your code
 faster?

 http://www.haskell.org/hawiki/StackOverflow

I read the article and understand it, but I am having a hard time
applying that specifically to my use of foldr.  Here is how I was
using foldr:

  type WordFreq   = M.Map B.ByteString Int
 
  train:: [B.ByteString] - WordFreq
  train words = frequencyMap
  where
frequencyMap = foldr incWordCount M.empty words
incWordCount w m = M.insertWith (+) w 1 m

So is 'incWordCount' strict in its second argument?  I'm still not
sure exactly what that means.  According to the wiki page, if it is
strict in the second argument, I should have used foldl' instead of
foldr.

Thanks,
Pete

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


Re: [Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Derek Elkins

Pete Kazmier wrote:

Derek Elkins [EMAIL PROTECTED] writes:


After reading Bryan's post, I switched my right fold to a strict left
fold and almost tripled my original speed.  Could someone provide some
guidelines on when to use each?  I thought foldr should be used when
building some large data structure such as the map I build.
Bryan, out of curiosity, is a non bytestring version of your code
faster?

http://www.haskell.org/hawiki/StackOverflow


I read the article and understand it, but I am having a hard time
applying that specifically to my use of foldr.  Here is how I was
using foldr:

  type WordFreq   = M.Map B.ByteString Int
 
  train:: [B.ByteString] - WordFreq

  train words = frequencyMap
  where
frequencyMap = foldr incWordCount M.empty words
incWordCount w m = M.insertWith (+) w 1 m

So is 'incWordCount' strict in its second argument?  I'm still not
sure exactly what that means.  According to the wiki page, if it is
strict in the second argument, I should have used foldl' instead of
foldr.


insertWith will definitely need to examine 'm' to perform it's action, therefore 
it is strict.

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


Re: [Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Ketil Malde
On Sun, 2007-04-22 at 11:51 -0400, Pete Kazmier wrote:

   type WordFreq   = M.Map B.ByteString Int
  
   train:: [B.ByteString] - WordFreq
   train words = frequencyMap
   where
 frequencyMap = foldr incWordCount M.empty words
 incWordCount w m = M.insertWith (+) w 1 m

Isn't this going to build unevaluate thunks for the counts?  This is
what frequency counting looks like in some of my old code:

-- IM is Data.IntMap
index ss = foldl' myupdate IM.empty ss
 where myupdate m k = let x = 1 + IM.findWithDefault 0 k m 
  in x `seq` IM.insert k x m

(edited a bit, but hopefully correct)

I.e. use foldl', and look up previous value, succ and seq it, and put it
back.

Generally, I only seem to want strict Maps.  It seems so easy to build a
lazy one if you need it (data Lazy a = Lazy a), so I wonder if strict
should be the default?

  Instead of generating the (huge) list of misspelled words, you could
  calculate edit distance to each correctly spelled word?  With a bound on
  allowable mistakes, this is a linear time operation using the standard
  dynamic programming algorithm.
 
 Could you provide additional information on this standard dynamic
 programming algorithm?  I'm not familiar with dynamic programming.

Sorry!  Dynamic programming just means using memoizing on a recursive
function to reduce its run time complexity (although I don't think I've
seen that definition anywhere?).  A simple example is finding the n'th
Fibonacci number by calculating (and referring to) the whole list.

For edit distance, you can do something like:

data Edit a = Repl a a | Delete a | Insert a

align (x:xs) (y:ys) = best [ Repl x y : align xs ys,
 Insert y : align (x:xs) ys,
 Delete x : align xs (y:ys)]

Where 'best' is some fitness function, selecting the best alignment.

Applying this directly gives an exponential algorithm, but since there
are only n*m (n = lenght (x:xs), m = length (y:ys) possible ways to pick
the remainders in the recursive calls throughout the execution, you
might as well store them all in an n*m matrix - which only takes O(nm)
time.

This is probably the worst explanation of DP so far this century, but if
you Google for it, you'll find tons of information.  Wikipedia has an
entry as well.

Anyway: since the number of edits in this case is bounded (to four,
since transposition can be modelled by an insertion and a deletion), you
know the optimal solution will never stray further than two off the
diagonal of the DP matrix, so you only need to caclulate a diagonal band
(linear space/time), not the full matrix (quadratic).

-k

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


Re: [Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Stefan O'Rear
On Sun, Apr 22, 2007 at 10:10:44PM +0200, Ketil Malde wrote:
 On Sun, 2007-04-22 at 11:51 -0400, Pete Kazmier wrote:
 
type WordFreq   = M.Map B.ByteString Int
   
train:: [B.ByteString] - WordFreq
train words = frequencyMap
where
  frequencyMap = foldr incWordCount M.empty words
  incWordCount w m = M.insertWith (+) w 1 m
 
 Isn't this going to build unevaluate thunks for the counts?  This is
 what frequency counting looks like in some of my old code:
 
 -- IM is Data.IntMap
 index ss = foldl' myupdate IM.empty ss
  where myupdate m k = let x = 1 + IM.findWithDefault 0 k m 
   in x `seq` IM.insert k x m
 
 (edited a bit, but hopefully correct)
 
 I.e. use foldl', and look up previous value, succ and seq it, and put it
 back.
 
 Generally, I only seem to want strict Maps.  It seems so easy to build a
 lazy one if you need it (data Lazy a = Lazy a), so I wonder if strict
 should be the default?
 
   Instead of generating the (huge) list of misspelled words, you could
   calculate edit distance to each correctly spelled word?  With a bound on
   allowable mistakes, this is a linear time operation using the standard
   dynamic programming algorithm.
  
  Could you provide additional information on this standard dynamic
  programming algorithm?  I'm not familiar with dynamic programming.
 
 Sorry!  Dynamic programming just means using memoizing on a recursive
 function to reduce its run time complexity (although I don't think I've
 seen that definition anywhere?).  A simple example is finding the n'th
 Fibonacci number by calculating (and referring to) the whole list.
 
 For edit distance, you can do something like:
 
   data Edit a = Repl a a | Delete a | Insert a
 
   align (x:xs) (y:ys) = best [ Repl x y : align xs ys,
Insert y : align (x:xs) ys,
  Delete x : align xs (y:ys)]
 
 Where 'best' is some fitness function, selecting the best alignment.
 
 Applying this directly gives an exponential algorithm, but since there
 are only n*m (n = lenght (x:xs), m = length (y:ys) possible ways to pick
 the remainders in the recursive calls throughout the execution, you
 might as well store them all in an n*m matrix - which only takes O(nm)
 time.
 
 This is probably the worst explanation of DP so far this century, but if
 you Google for it, you'll find tons of information.  Wikipedia has an
 entry as well.
 
 Anyway: since the number of edits in this case is bounded (to four,
 since transposition can be modelled by an insertion and a deletion), you
 know the optimal solution will never stray further than two off the
 diagonal of the DP matrix, so you only need to caclulate a diagonal band
 (linear space/time), not the full matrix (quadratic).

You can almost always do DP with less space, and this is no exception:
linear space for full Levenschtein, constant for the diagonal band. 

http://www.haskell.org/haskellwiki/Dynamic_programming_example#Optimization

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


Re: [Haskell-cafe] IDE support

2007-04-22 Thread Claus Reinke
What IDE support is available for Haskell (Visuall Haskell, EclipseFP), 
anything else?


in addition to the vim plugins already mentioned, i've got a few old ones at 


   http://www.cs.kent.ac.uk/people/staff/cr3/toolbox/haskell/Vim/

the page is many years old, but the logs indicate that many folks stumble 
across it via google, without ever telling me, and i've noticed that the 
haskell.org wiki now points to it, so i've just added my current vim files 
for haskell:


   compiler/ghc.vim: basic quickfix settings for ghc
   ftplugin/haskell.vim: basic settings allowing vim to recognise imports
   (also load other haskell plugins from here)
   ftplugin/haskell_doc.vim: extensive functionality based on haddock's
   html files for libraries, including doc lookup  id completion

i don't know how i ever haskelled without that last plugin - completing long
library ids or adding imports, is just part of the fun, mostly i like to lookup
docs quickly (if you're using hugs, also try :find), or just get a menu of 
possible imports an id might come from.


the files ought to be portable, but might retain some settings specific to 
windows as that is my working platform, please check and adjust as 
necessary. together with the pre-installed syntax-colouring for haskell, 
this enables much of vim's general ide functionality for haskell, but 
i'm sure one could do more. just pick and mix with the other vim files 
mentioned in this thread or on haskell.org (which perhaps should be more 
prominent, even though there isn't one mode to rule them all for vim!-)


if you can stay within haskell98, HaRe refactoring support for emacs and 
vim is still around:http://www.cs.kent.ac.uk/projects/refactor-fp/


claus

ps since surprisingly many haskellers are not quite aware of vim's ide
   functions, here is a partial list: syntax highlighting, quickfix (run source
   through ghci, jump to errors listed), tags (jump to definitions; using 
   'ghc -e :ctags Main.hs' to generate tag file for Main.hs and imports,
   exported ids only at the moment; or use another tag file generator), 
   completion with respect to current file, imported modules, tag files,
   haddock files (using haskell_doc.vim), (or define your own 
   completion function), list lines using id under cursor, match open/
   close brackets and parens, fold away sections of modules, ... not 
   to mention the general editor, searchreplace functions..


   see the help files (:help), in vim, or online at 
   http://vimdoc.sourceforge.net/htmldoc/usr_toc.html


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


Re: [Haskell-cafe] Is there a best *nix or BSD distro for Haskell hacking?

2007-04-22 Thread Dougal Stanton

On 22/04/07, Ryan Dickie [EMAIL PROTECTED] wrote:


Many of the haskell packages including darcs, ghc, and well over 100 other
packages (mostly libraries) are in the package manager ready to be
installed.


The problem with Ubuntu (at least until the Feisty release a few days
ago?) was that GHC wasn't up-to-date by default; it came with 6.4.
Moving to 6.6 isn't a difficult feat (the generic binaries from the
GHC site seem to work fine for Edgy, if you install libreadline too)
but being behind that curve is noticeable. If you want to stay on the
cutting edge Gentoo takes a lot of the hassle out of it, since you can
use the repository stored on haskell.org. The downside is having to
keep the rest of the system updated if you've got a slow machine.

You pays your money, etc.

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


Re: [Haskell-cafe] question about Data.Binary and Double instance

2007-04-22 Thread Ian Lynagh
On Wed, Apr 18, 2007 at 09:12:30PM -0700, David Roundy wrote:
 
 I just want to read in a file full of Doubles (written in binary format
 from C++)

Note that if you write double's from C++ then you need to read CDoubles
in Haskell and then realToFrac them (which will presumably be optimised
out in practice).

Or alternatively you can work with HsDouble's in C++.


Thanks
Ian

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


[Haskell-cafe] tiff reader or libtiff bindings

2007-04-22 Thread Andreas Voellmy

Hi,

Does anyone know of a haskell library to read (and write) tiff files? Or has
someone written a binding to libtiff?

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


Re: [Haskell-cafe] question about Data.Binary and Double instance

2007-04-22 Thread Ian Lynagh
On Tue, Apr 17, 2007 at 11:42:40PM -0400, Brian Alliet wrote:
 
  Perhaps we just don't care about ARM or other arches where GHC runs that
 
 Are there really any architectures supported by GHC that don't use IEEE
 floating point? If so GHC.Float is wrong as isIEEE is always true.

The one most likely to be non-IEEE is ARM, which has a middle-endian
representation; to make it explicit, it's the middle case here
(FLOAT_WORDS_BIGENDIAN but not WORDS_BIGENDIAN):

#if WORDS_BIGENDIAN
unsigned int negative:1;
unsigned int exponent:11;
unsigned int mantissa0:20;
unsigned int mantissa1:32;
#else
#if FLOAT_WORDS_BIGENDIAN
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
unsigned int mantissa1:32;
#else
unsigned int mantissa1:32;
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
#endif
#endif

Does anyone know if that makes it non-IEEE?


Thanks
Ian

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


Re: [Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Felipe Almeida Lessa

On 4/22/07, Pete Kazmier [EMAIL PROTECTED] wrote:

 Worse - and this is true for ByteStrings, too - String comparisons are
 O(n), which means lookups in Sets and Maps are expensive.  A trie (i.e,
 a search tree where each internal node corresponds to a word prefix, and
 has one branch per letter in the alphabet) will give you lookup that
 scales with word size (and possibly alphabet size).

Right.  My first version was just a direct translation of Norvig's
code with an emphasis on trying to keep the complexity and size of
code to a minimum.


AFAIK, Python's dictionaries are implemented using hashtables, so
lookups with them are much faster than with M.Map String Int.  So
should a direct translation use a Data.HashTable (despite its unpure
interface)? But probably a trie should be better than both (just
gambling ;-).

Cheers,

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


Re: [Haskell-cafe] question about Data.Binary and Double instance

2007-04-22 Thread Stefan O'Rear
On Sun, Apr 22, 2007 at 10:43:23PM +0100, Ian Lynagh wrote:
 On Tue, Apr 17, 2007 at 11:42:40PM -0400, Brian Alliet wrote:
  
   Perhaps we just don't care about ARM or other arches where GHC runs that
  
  Are there really any architectures supported by GHC that don't use IEEE
  floating point? If so GHC.Float is wrong as isIEEE is always true.
 
 The one most likely to be non-IEEE is ARM, which has a middle-endian
 representation; to make it explicit, it's the middle case here
 (FLOAT_WORDS_BIGENDIAN but not WORDS_BIGENDIAN):
 
 #if WORDS_BIGENDIAN
 unsigned int negative:1;
 unsigned int exponent:11;
 unsigned int mantissa0:20;
 unsigned int mantissa1:32;
 #else
 #if FLOAT_WORDS_BIGENDIAN
 unsigned int mantissa0:20;
 unsigned int exponent:11;
 unsigned int negative:1;
 unsigned int mantissa1:32;
 #else
 unsigned int mantissa1:32;
 unsigned int mantissa0:20;
 unsigned int exponent:11;
 unsigned int negative:1;
 #endif
 #endif
 
 Does anyone know if that makes it non-IEEE?

AIUI, ieee754 talks about high bits and low bits, not first or last
bytes, which means that it is endianness independant.  this also means
that ieee754 values are endian dependant - we'll have to swap them
into network byte order before saving, if we're on a le host. 

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


Re: [Haskell-cafe] Is there a best *nix or BSD distro for Haskell hacking?

2007-04-22 Thread Ryan Dickie

I'm running feisty.
[EMAIL PROTECTED]:~$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.6

--ryan

On 4/22/07, Dougal Stanton [EMAIL PROTECTED] wrote:


On 22/04/07, Ryan Dickie [EMAIL PROTECTED] wrote:

 Many of the haskell packages including darcs, ghc, and well over 100
other
 packages (mostly libraries) are in the package manager ready to be
 installed.

The problem with Ubuntu (at least until the Feisty release a few days
ago?) was that GHC wasn't up-to-date by default; it came with 6.4.
Moving to 6.6 isn't a difficult feat (the generic binaries from the
GHC site seem to work fine for Edgy, if you install libreadline too)
but being behind that curve is noticeable. If you want to stay on the
cutting edge Gentoo takes a lot of the hassle out of it, since you can
use the repository stored on haskell.org. The downside is having to
keep the rest of the system updated if you've got a slow machine.

You pays your money, etc.

D.
___
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] question about Data.Binary and Double instance

2007-04-22 Thread David Roundy
On Sun, Apr 22, 2007 at 10:36:17PM +0100, Ian Lynagh wrote:
 On Wed, Apr 18, 2007 at 09:12:30PM -0700, David Roundy wrote:
  I just want to read in a file full of Doubles (written in binary format
  from C++)
 
 Note that if you write double's from C++ then you need to read CDoubles
 in Haskell and then realToFrac them (which will presumably be optimised
 out in practice).

This is a one-off script, which doesn't need to be portable.  Or, it would
have been, if I hadn't written it in perl and octave.
-- 
David Roundy
http://www.darcs.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: haskell question

2007-04-22 Thread oleg

 Is there documentation on the multi-parameter type classes?

Sections 7.4.2. Class declarations, 7.4.3 Functional dependencies and
7.4.4. Instance declarations of the GHC user guide give the short
description of these features. These section refer to a couple of
papers. The best explanation can be found in papers by Mark P. Jones:
http://web.cecs.pdx.edu/~mpj/pubs.html
(see especially `qualified types').

 i think i see what you've done, but i'd like to read up on it to make
 sure that i understand.

The approach in the previous message was quite close to that used for
representing collections. The type of a particular collection implies
the type of collection's elements. In your case, the type of the agent
implies the type of the processor for that particular agent (and vice
versa). Incidentally, instance declarations can be recursive and
mutually recursive.

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


Re: [Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Duncan Coutts
On Sun, 2007-04-22 at 12:55 -0400, Pete Kazmier wrote:

 After reading Bryan's post, I switched my right fold to a strict left
 fold and almost tripled my original speed.  Could someone provide some
 guidelines on when to use each?  I thought foldr should be used when
 building some large data structure such as the map I build.

You are building a strict data structure, not a lazy one. You cannot use
that map until every element has been inserted into it, there are no
partial intermediate results you can use like say when you build a lazy
list. Hence it's better to use a strict left fold.

Rule of thumb: use a lazy fold to build lazy structures, use a strict
fold to build strict ones.

Duncan

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


Re: [Haskell-cafe] Re: How Albus Dumbledore would sell Haskell

2007-04-22 Thread Cale Gibbard

On 21/04/07, apfelmus [EMAIL PROTECTED] wrote:

Dan Weston wrote:
 -- Why is this not in Prelude?
 dup x = (x,x)

It is (almost). It's called

  join (,)


It's unfortunate that the Monad instance for ((-) e) isn't in the Prelude.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] newbie question on ordering

2007-04-22 Thread Albert Y. C. Lai

Nikolay Metchev wrote:

data Face = Ace | Two | Three | Four | Five | Six | Seven | Eight | Nine
 | Ten | Jack | Queen | King deriving (Enum, Show, Eq)

listComparator :: (Eq a) = [a] - a - a - Ordering
listComparator xs a b = compare x y
   where
 x = elemIndex a xs
 y = elemIndex b xs

fourOfAKindBonusFaceOrder :: [Face]
fourOfAKindBonusFaceOrder = [Queen, King, Ten, Ace, Nine, Jack]


Add:

newtype FourOfAKindBonusFace = FKBF Face deriving Eq

instance Ord FourOfAKindBonusFace where
compare (FKBF x) (FKBF y) =
  listComparator fourOfAKindBonusFaceOrder x y

Henceforth you can do these in the four-of-a-kind order:
FKBF Queen = FKBF Ten
FKBF Ten = FKBF Queen
compare (FKBF Ten) (FKBF Queen)

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


Re: [Haskell-cafe] IDE support

2007-04-22 Thread Gour
On Sun, 22 Apr 2007 22:13:45 +0100
Claus Reinke [EMAIL PROTECTED] wrote:


 the page is many years old, but the logs indicate that many folks
 stumble across it via google, without ever telling me, and i've
 noticed that the haskell.org wiki now points to it, so i've just
 added my current vim files for haskell:

[...]

Thank you very much for your reply.

 
 if you can stay within haskell98, HaRe refactoring support for emacs
 and vim is still around:
 http://www.cs.kent.ac.uk/projects/refactor-fp/

What about shim (http://shim.haskellco.de/trac/) ?

Is it going to get vim support or the only the other editor's users are
happy?

 ps since surprisingly many haskellers are not quite aware of vim's ide
 functions, here is a partial list: syntax highlighting, quickfix
 (run source through ghci, jump to errors listed), tags (jump to
 definitions; using 'ghc -e :ctags Main.hs' to generate tag file for
 Main.hs and imports, exported ids only at the moment; or use another
 tag file generator), completion with respect to current file,
 imported modules, tag files, haddock files (using haskell_doc.vim),
 (or define your own completion function), list lines using id under
 cursor, match open/ close brackets and parens, fold away sections of
 modules, ... not to mention the general editor, searchreplace
 functions..

I must admit I wasn't aware of all the above. Thank you for
enlightenment ;)


Sincerely,
Gour


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


Re: [Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Bryan O'Sullivan

Bryan O'Sullivan wrote:

In my profile results, I find that simply converting words to lower case 
accounts for a whopping 40% of time and allocation (see the attachment 
for my definition of the train function).


COST CENTREMODULE  %time %alloc

lower  Spell40.5   41.2
train  Spell26.3   14.3
mkWordsSpell21.9   24.1


A little more instrumentation says this (using the darcs head of fps 
built with -auto-all):


loopU  NewData.ByteString.Fusion  25.4   28.8
splitWith  NewData.ByteString 15.4   17.2
train  Spell  10.26.1
isNotAlpha Spell   9.4   12.2
compareBytes   NewData.ByteString  8.89.6
compareBytes   NewData.ByteString.Lazy 7.40.4
inlinePerformIONewData.ByteString.Base 6.60.0

(At Stefan's suggestion, I renamed the modules in fps to NewData.*, in 
order to get around the name clashes when I try to concurrently use fps 
and base.)


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