RE: [Haskell-cafe] COM and Haskell

2007-04-23 Thread Simon Peyton-Jones
Lennart Augustsson has quite a bit of experience in interface Haskell and 
Excel, although I'm not sure which way.

Simon


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Justin Bailey
Sent: 19 April 2007 16:59
To: haskell-cafe@haskell.org
Subject: [Haskell-cafe] COM and Haskell

All,

I'm interested in automating Excel using Haskell. I'm writing a little program 
for my wife and it'd be nice to fill out an Excel spreadsheet for her (with 
formatting so I don't think CSV will cut it). A bit of Googling didn't turn up 
anything interesting.

Has any work been done on using Excel (or more generally, COM) from Haskell?

Thanks for any pointers!

Justin

p.s. I'm aware of the article Spreadsheet for Functional Programmers article 
and Neil Mitchell's post about HsExcel - but those go the wrong way :(
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Compilling GHC on Vista

2007-04-23 Thread Tom Schrijvers

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?


Monique,

What does the config.log say?

Are you able to run the MingW's gcc compiler yourself on a simple C 
program?


I had a similar error, cause by the fact that gcc.exe cannot find cc1.exe,
which is in MingW/libexec/gcc/mingw32/3.4.2/. I had to add it to my PATH.

Cheers,

Tom

--
Tom Schrijvers

Department of Computer Science
K.U. Leuven
Celestijnenlaan 200A
B-3001 Heverlee
Belgium

tel: +32 16 327544
e-mail: [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Performance and STUArrays

2007-04-23 Thread Jean-Marie Gaillourdet
Hi Dominic,

Dominic Steinitz wrote:
 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

 code snipped

I did not have time to look into your code yet. But the question whether
this is only a constant factor improvement or an implementation with a
different time complexity can only be researched by a series of
experiments with different input sizes. An interpretation of a series of
 results of experiments is more meaningful than just one data point.

Greets,
  Jean-Marie


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


Re: [Haskell-cafe] IDE support

2007-04-23 Thread David House

On 22/04/07, Philipp Volgger [EMAIL PROTECTED] wrote:

What IDE support is available for Haskell (Visuall Haskell, EclipseFP),
anything else?


There is pretty decent Emacs support. haskell-mode [1] provides the
basis of this support. There are Emacs Lisp libraries for Haskell
indentation, Haskell syntax highlighting, and many other things. Make
sure you read the notes on the Haskellwiki [2], as they contain a lot
of helpful hints for getting the best out of the mode.

There are also libraries for integration of common Haskell tools like
hoogle [3] and hpaste [4] in the form of hoogle.el [5] and hpaste.el
[6].

Enjoy!

[1]: http://www.haskell.org/haskell-mode/
[2]: http://haskell.org/haskellwiki/Haskell_mode_for_Emacs
[3]: http://haskell.org/hoogle
[4]: http://hpaste.org
[5]: http://haskell.org/haskellwiki/Hoogle.el
[6]: http://haskell.org/haskellwiki/Hpaste.el

--
-David House, [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-23 Thread Thomas Hartman

If you opt for ubuntu, have a look at

http://groups.google.de/group/fa.haskell/browse_thread/thread/e63e73e7fc9e96c2/be76e381f8c33f39?lnk=stq=%22haskell+cafe%22+%22Trouble+trying+to+find+packages+for+ubuntu+linux%22rnum=1hl=en#be76e381f8c33f39

This little hack enabled me to do a sort of one shot install for all
the haskell packages available for feisty, although I was running
dapper (long term support) ubuntu.

This meant a lot less dependency chasing when I wanted to install
something nonstandard, or with nonstandard dependencies, eg HApps.

(nota bene, I think the issue of dependency chasing should hopefully
cease to matter when the cabal developers figure out how to do that
during an install.)

thomas.

2007/4/22, Ryan Dickie [EMAIL PROTECTED]:

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



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


RE: [Haskell-cafe] COM and Haskell

2007-04-23 Thread Simon Peyton-Jones
| I've done things that are almost identical to what Neil suggests, and
| I've also done a lot of work on calling Haskell code from Excel via
| the Excel4 (XLL) API, but not so much work on calling COM from Haskell.
| It's all doable, but it's a lot of work.

I wonder what we (or someone else) could do to make it less work?

Even a 'cookbook' to explain what to do would be jolly useful.

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


Re: [Haskell-cafe] Compilling GHC on Vista

2007-04-23 Thread Monique Monteiro

Tom,

On 4/23/07, Tom Schrijvers [EMAIL PROTECTED] wrote:


What does the config.log say?





Are you able to run the MingW's gcc compiler yourself on a simple C
program?

I had a similar error, cause by the fact that gcc.exe cannot find cc1.exe,
which is in MingW/libexec/gcc/mingw32/3.4.2/. I had to add it to my PATH.


I did the same, but it still doesn't work...

Here is config.log:

PATH: /usr/local/bin
PATH: /usr/bin
PATH: /bin
PATH: /usr/X11R6/bin
PATH: /cygdrive/c/MinGW/bin
PATH: /cygdrive/c/MinGW/libexec/gcc/mingw32/3.4.2
PATH: /cygdrive/c/ghc/ghc-6.2.2/bin
PATH: /usr/local/bin
PATH: /cygdrive/c/GreenCard
PATH: /usr/bin
PATH: /usr/bin
PATH: /cygdrive/c/Program Files/MiKTeX 2.5/miktex/bin
PATH: /cygdrive/c/Windows/system32
PATH: /cygdrive/c/Windows
PATH: /cygdrive/c/Windows/System32/Wbem
PATH: /cygdrive/c/Program Files/Common Files/GTK/2.0/bin
PATH: /cygdrive/c/Program Files/QuickTime/QTSystem/
PATH: /cygdrive/c/Program Files/Microsoft SQL Server/90/Tools/binn/
PATH: /cygdrive/c/Program Files/Mondrian/bin
configure:1905: checking build system type
configure:1923: result: i686-pc-cygwin
configure:1945: checking host system type
configure:1960: result: i386-unknown-mingw32
configure:1982: checking target system type
configure:1997: result: i386-unknown-mingw32
configure:2415: checking for path to top of build tree
configure:2441: result: c:/ghc-6.2.2-src/ghc-6.2.2
configure:2455: checking for ghc
configure:2473: found /cygdrive/c/ghc/ghc-6.2.2/bin/ghc
configure:2485: result: /cygdrive/c/ghc/ghc-6.2.2/bin/ghc
configure:2513: checking version of ghc
The Glorious Glasgow Haskell Compilation System, version 6.2.2
configure:2542: result: 6.2.2
configure:2551: checking for nhc
configure:2584: result: no
configure:2551: checking for nhc98
configure:2584: result: no
configure:2594: checking for hbc
configure:2627: result: no
configure:2756: checking whether #! works in shell scripts
configure:2773: result: yes
configure:2782: checking for perl
configure:2798: found /bin/perl
configure:2809: result: /bin/perl
configure:2893: checking if your perl works in shell scripts
configure:2911: result: yes
configure:2916: checking for python
configure:2949: result: no
configure:2963: checking for i386-unknown-mingw32-gcc
configure:2990: result: c:/MinGW/bin/gcc
configure:3268: checking for C compiler version
configure:3275: c:/MinGW/bin/gcc --version 5
gcc.exe (GCC) 3.4.2 (mingw-special)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:3278: $? = 0
configure:3285: c:/MinGW/bin/gcc -v 5
Reading specs from c:/MinGW/lib/gcc/mingw32/3.4.2/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld
--with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw
--enable-threads --disable-nls
--enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry
--disable-shared --enable-sjlj-exceptions --enable-libgcj
--disable-java-awt --without-x --enable-java-gc=boehm
--disable-libgcj-debug --enable-interpreter
--enable-hash-synchronization --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.2 (mingw-special)
configure:3288: $? = 0
configure:3295: c:/MinGW/bin/gcc -V 5
gcc.exe: `-V' option must have argument
configure:3298: $? = 1
configure:3321: checking for C compiler default output file name
configure:3348: c:/MinGW/bin/gccconftest.c  5
ld: /mingw/lib/crt2.o: No such file: No such file or directory
configure:3351: $? = 1
configure:3389: result:
configure: failed program was:
configure:3396: error: C compiler cannot create executables
See `config.log' for more details.


ac_cv_build=i686-pc-cygwin
ac_cv_env_CC_set=
ac_cv_env_CC_value=
ac_cv_env_CFLAGS_set=
ac_cv_env_CFLAGS_value=
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_XMKMF_set=
ac_cv_env_XMKMF_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=set
ac_cv_env_host_alias_value=i386-unknown-mingw32
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_host=i386-unknown-mingw32
ac_cv_path_GHC=/cygdrive/c/ghc/ghc-6.2.2/bin/ghc
ac_cv_prog_CC=c:/MinGW/bin/gcc
ac_cv_prog_PerlCmd=/bin/perl
ac_cv_sys_interpreter=yes
ac_cv_target=i386-unknown-mingw32
fptools_cv_shebang_perl=yes


ALLOCA=''
AlexCmd=''
AlexVersion=''
ArCmd=''
ArSupportsInput=''
BootingFromHc='NO'
BootingFromUnregisterisedHc='NO'
BuildArch_CPP='i386'
BuildOS_CPP='mingw32'
BuildPlatform='i386-unknown-mingw32'
BuildPlatform_CPP='i386_unknown_mingw32'
BuildVendor_CPP='unknown'
CC='c:/MinGW/bin/gcc'
CFLAGS=''
CPP=''
CPPFLAGS=''
Catalog=''
ContextDiffCmd=''
DEFS=''
DotnetSupport='NO'
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
EXEEXT=''
FindCmd=''
GHC='/cygdrive/c/ghc/ghc-6.2.2/bin/ghc'
GLUT_LIBS=''
GL_CFLAGS=''
GL_LIBS=''
GREP=''
GTK_CONFIG=''

Re: [Haskell-cafe] newbie question on ordering

2007-04-23 Thread Joe Thornber

On 22/04/07, Nikolay Metchev [EMAIL PROTECTED] wrote:

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.


I wrote some code for comparing poker hands that you may find useful
[1].  It gives each hand a classification, and then orders first on
the classification, and then on some secondary property of the
classification (eg, highest card in hand).

- Joe

[1] http://www.lambda-software.com/darcs/programming-challenges/2.8.2/poker.hs
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Compilling GHC on Vista

2007-04-23 Thread Tom Schrijvers

On Mon, 23 Apr 2007, Monique Monteiro wrote:


Tom,

On 4/23/07, Tom Schrijvers [EMAIL PROTECTED] wrote:


What does the config.log say?





Are you able to run the MingW's gcc compiler yourself on a simple C
program?

I had a similar error, cause by the fact that gcc.exe cannot find cc1.exe,
which is in MingW/libexec/gcc/mingw32/3.4.2/. I had to add it to my PATH.


I did the same, but it still doesn't work...

Here is config.log:


Here's the more complete error message:


configure:3321: checking for C compiler default output file name
configure:3348: c:/MinGW/bin/gccconftest.c  5
ld: /mingw/lib/crt2.o: No such file: No such file or directory
configure:3351: $? = 1
configure:3389: result:
configure: failed program was:
configure:3396: error: C compiler cannot create executables
See `config.log' for more details.


Do make sure that MingW's bin/ and libexec/gcc/mingw32/3.4.2/ are the very 
first two in your path. I get the same error message if I don't do that.


Tom



--
Tom Schrijvers

Department of Computer Science
K.U. Leuven
Celestijnenlaan 200A
B-3001 Heverlee
Belgium

tel: +32 16 327544
e-mail: [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: IDE support

2007-04-23 Thread Benedikt Schmidt
Gour [EMAIL PROTECTED] writes:

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

 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?

I use emacs exclusively for hacking Haskell, but I wanted to see
if it's possible to connect to the shim server-process from vim
and started working on omnicompletion:

http://shim.haskellco.de/trac/attachment/wiki/ScreenShots/vim-shim.png

http://shim.haskellco.de/trac/wiki/ShimVim

http://darcsweb.haskellco.de/darcsweb.cgi?r=shim;a=tree;f=/vim

I don't think I will spend much more time working on this, but
if anyone wants to try it out or improve it,  I would be happy
to answer questions and review patches.

Thanks,
  Benedikt

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


Re: [Haskell-cafe] Gotta love Haskell - Mass management

2007-04-23 Thread Henning Thielemann

On Fri, 20 Apr 2007, Justin Bailey wrote:

 Here's the trick I thought was neat. When creating the MassTime value, I
 capture it in a closure and bind it to the selector function, as below:

  makeMass :: Day - MassTime
  makeMass day =
 mass
   where
 -- Use trick here to capture mass defined and pass to our selection
 function.
 mass = MassTime ... (weekendMassSelector mass) ...

 'weekendMassSelector' is defined elsewhere, and basically knows how to count
 up the right number of participants based on the mass definition given. It's
 signature is:

   weekendMassSelector :: MassTime - Participants - Maybe Participants

 So weekendMassSelector gets the MassTime value it needs, before it is even
 constructed. Partial evaluation then gives a function with the (Participants
 - Maybe Participants) signature required by the data constructor. I love
 Haskell - this just seems too cool.

I'd call that
  http://www.haskell.org/hawiki/TyingTheKnot
 However, I wonder if it is clearer to use 'let' for holding the computed
weekendMass value before passing it to MassTime and somewhere else:

let wm = computeWM
in  MassTime {otherData = f wm, weekendMassSelector = wm, ...}


In an imperative language you would certainly write

mass.weekend := bla;
mass.otherData := f(mass.weekend);
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] IDE support

2007-04-23 Thread David Waern
 What IDE support is available for Haskell (Visuall Haskell, EclipseFP),
 anything else?

I'm working in Haste2[1]. But it is unreleased :P

[1] http://www.dtek.chalmers.se/~davve/haste2-new.png

/David

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


[Haskell-cafe] Creating QuickCheck properties

2007-04-23 Thread Joel Reymont

Folks,

I have code like this that I want to test with QuickCheck but I'm  
having trouble imagining how I would wrap it up in a property.


Do I make sure that id, subs, back are always morphed properly or do  
I leave that to separate properties for their respective types?


Do I then ensure that array types are always unwrapped (see getType  
below), that a series variable is always declared, code added and a  
series reference returned?


Last but not least, is monadic testing part of Test.QuickCheck.*?

Thanks, Joel

type Core a = State CoreUnit a

data CoreUnit
= Core
  { coreSym :: Integer -- starting # for gensym
  , coreVars :: M.Map String VarDecl
  , coreCode :: M.Map Integer [Statement]
  }
deriving (Show, Eq)

morphHistArrayAccess :: VarIdent - Subscript - BackRef - C.Core  
C.Expr

morphHistArrayAccess id subs back = do
  id' - morph id
  subs' - morph subs
  back' - morph back
  (C.TyArray ty) - getType id'
  s - genSym series
  addVar s (C.TySeries ty) [] Nothing
  addCodeFront 1 [ C.AddToSeries (C.VarIdent s) (C.Var id' subs') ]
  return $ C.Series (C.VarIdent s) back'


--
http://wagerlabs.com/





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


Re: [Haskell-cafe] COM and Haskell

2007-04-23 Thread Justin Bailey

On 4/23/07, Simon Peyton-Jones [EMAIL PROTECTED] wrote:



I wonder what we (or someone else) could do to make it less work?

Even a 'cookbook' to explain what to do would be jolly useful.



Give me a way to get to the .NET libraries and the world is my oyster ...
Based on my experience using .NET from Ruby (via the RubyCLR library by John
Lam), having access to the .NET libraries allows you to get a lot of useful
work done. Ruby, of course, is extremely flexible  so working with .NET from
it feels very natural, and John did a lot of work to make it that way. It's
like he built an embedded DSL for interacting with .NET. I imagine the same
could be done in Haskell, though it might involve some sort of code
generation technique.

Justin

p.s. Mr. Lam is now working at Microsoft, FYI ...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] IDE support

2007-04-23 Thread Andrew Wagner

This looks nice! Is there a project page for Haste2? How far along is
it? Is it based on gtk2hs?

On 4/23/07, David Waern [EMAIL PROTECTED] wrote:

 What IDE support is available for Haskell (Visuall Haskell, EclipseFP),
 anything else?

I'm working in Haste2[1]. But it is unreleased :P

[1] http://www.dtek.chalmers.se/~davve/haste2-new.png

/David

___
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-23 Thread Dougal Stanton

On 23/04/07, David Waern [EMAIL PROTECTED] wrote:

 What IDE support is available for Haskell (Visuall Haskell, EclipseFP),
 anything else?

I'm working in Haste2[1]. But it is unreleased :P

[1] http://www.dtek.chalmers.se/~davve/haste2-new.png


That's really clean-looking and undistracting. When do you expect to
release it on the unsuspecting public? ;-)

Cheers,

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


Re: [Haskell-cafe] IDE support

2007-04-23 Thread David Waern
 This looks nice! Is there a project page for Haste2? How far along is
 it? Is it based on gtk2hs?

Yes, it's based on the Scintilla[1] editor and gtk2hs. I've only been
working on it for a couple of weeks, and that includes creating the
Scintilla binding for gtk2hs, so it doesn't have that many feature yet.
There's no homepage either.

[1] http://www.scintilla.org/

/David


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


Re: [Haskell-cafe] IDE support

2007-04-23 Thread Neil Mitchell

Hi David,


Yes, it's based on the Scintilla[1] editor and gtk2hs. I've only been
working on it for a couple of weeks, and that includes creating the
Scintilla binding for gtk2hs, so it doesn't have that many feature yet.
There's no homepage either.

[1] http://www.scintilla.org/


Have you seen the GuiHaskell project, and were you aware that there is
a summer of code project on it? This will provide some way of
interfacing to all compilers, and various buttons, but none of the
editing features.

If you want to have any input, we'd be greatful. This hopefully might
allow us to have a shared common bit.

Thanks

Neil

[1] http://www-users.cs.york.ac.uk/~ndm/guihaskell/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] IDE support

2007-04-23 Thread David Waern
 On 23/04/07, David Waern [EMAIL PROTECTED] wrote:
  What IDE support is available for Haskell (Visuall Haskell,
 EclipseFP),
  anything else?

 I'm working in Haste2[1]. But it is unreleased :P

 [1] http://www.dtek.chalmers.se/~davve/haste2-new.png

 That's really clean-looking and undistracting. When do you expect to
 release it on the unsuspecting public? ;-)


Thanks! I'll probably release it when my Scintilla patch for gtk2hs is
completed, if it gets accepted.

/David

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


Re: [Haskell-cafe] IDE support

2007-04-23 Thread David Waern
 Have you seen the GuiHaskell project, and were you aware that there is
 a summer of code project on it? This will provide some way of
 interfacing to all compilers, and various buttons, but none of the
 editing features.

Yes, I was aware of it. My plan was to experiment with the editor, the GHC
API and Haddock 2.0, so the project is a little bit different.

 If you want to have any input, we'd be greatful. This hopefully might
 allow us to have a shared common bit.

I'm all for sharing common bits! Let's pay some attention to each others
repositories. Here's mine: http://repos.mine.nu/davve/darcs/haste2/

There's probably a lot of stuff in Cabal (that just needs to be exposed)
that we could use also.

/David

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


Re: [Haskell-cafe] Compilling GHC on Vista

2007-04-23 Thread Monique Monteiro

On 4/23/07, Tom Schrijvers [EMAIL PROTECTED] wrote:

Do make sure that MingW's bin/ and libexec/gcc/mingw32/3.4.2/ are the very
first two in your path. I get the same error message if I don't do that.


Yes.  Here is my cygwin.bat:

@echo off

SET MAKE_MODE=UNIX
SET SHELL=c:/cygwin/bin/sh
SET HOME=C:/ghc-6.2.2-src
SET CVSROOT=:pserver:[EMAIL PROTECTED]:/cvs
SET TMPDIR=C:/Users/Monique/AppData/Local/Temp
SET 
PATH=c:/MinGW/bin;C:/MinGW/libexec/gcc/mingw32/3.4.2;C:\ghc\ghc-6.2.2\bin;C:\cygwin\usr\local\bin;C:\GreenCard;c:\cygwin\usr\bin;C:\cygwin\bin;%PATH%

C:
chdir C:\cygwin\bin

bash --login -i

__
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


[Haskell-cafe] About functional programing, type theory and a master thesis topic

2007-04-23 Thread Glauber Cabral

Hi everybody =)
First time I write to the list.
My name is Glauber and I'm doing my master course at UNICAMP, Brazil,
under supervisor of Prof. Dr. Arnaldo Vieira Moura.

I'm interested in Haskell, type theory and algebraic specification
(formal methods). I've been studying these subjects to my
Computer-Science-Bachelor-degree-final work. It was an implementation
of an homomorphism between a little constructive algebraic
specification code (based mainly in Loeckx's Specification of Abstract
Data Types) and a Haskell code. SableCC was used as tool to implement
the interpreter because I've already used it before. One theme to work
one should be implementing this in Haskell itself, but  there is
already HasCASL.

I've already contacted the HasCASL professors and I'm reading more
about the project.
At the same time, I want to look for some theme under type theory, too.
The main concern about HasCASL is that I want to get in deep touch
with functional programming during my master thesis and I'm not sure
(yet) if studying HasCASL would get me there.

I've reading some papers about type theory and Haskell (mainly the
ones suggested in the haskell.org site) and as I could see the topics
are very interesting. I'm not sure, however, if there is something
that can be done in a 2-year-master course. Mainly, they propose new
extensions that have became new languages (Cayenne, Omega and
Epigram).

Other topic I'd like to get in touch is theorem proving. As I could
see, Coq and Isabelle are the most used with Haskell. Indeed, HasCASL
use Isabelle and this could be a nice thing to work on, as was
suggested by HasCASL professors.

As I know that lots of you here are researchers, I'd like to ask some
opinions about what can be done as a master thesis having in mind that
I want to continue in a PhD course after the master one.

Sorry if the email is too large. And thank for the patience and for
any opinion you can give me.

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


[Haskell-cafe] faster factorial function via FFI?

2007-04-23 Thread Dan Drake
Hello everyone,

I have some code in which the bottleneck is the factorial function. I
began by using a naive

  fac n = product [1..n]

but it looks like there are faster ways to do it. I could try to look up
those faster algorithms and implement them, but I'm guessing that using
libgmp's factorial function is the best way to do it. I'm a poor
programmer, so I don't trust myself to implement those algorithms
properly. Hence I need to use FFI.

...but ghc already uses libgmp for Integers, so shouldn't I be able to
somehow call libgmp's factorial function?

Using regular FFI stuff, it looks like this might get complicated, since
the function doesn't return one of the usual foreign types, so I'd need
to mess around to get the result into an Integer, which is what I need.

Is there an easy way to do this? It might also be faster to use a lookup
table, since most of the time I'll be taking factorials of relatively
small numbers. 

Thanks,

Dan

-- 
Ceci n'est pas une .signature.


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


Re: [Haskell-cafe] Performance and STUArrays

2007-04-23 Thread Daniel Fischer
Am Sonntag, 22. April 2007 15:06 schrieb 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.

How do you calculate that?
I'd think that in the unfoldred function (h) you'd refer to 15 Word32s you 
don't use for each test, so that would be roughly a 20% overhead, the tail of 
h's argument could be reused, so in each step one Word32 - or rather one 
thunk to calculate a Word32 - would be appended (if the compiler knows how to 
do that, otherwise there'd be a lot of copying Word32s).

Warning: I know next to nothing about computers, so I'm quite naive in my 
expectations.

What I've tested is whether strictifying h gives a performance gain, it does,
roughly 10% on my computer.

h [w0 .. w15] = let w16 = rotL 1 (w0 `xor` ..) in w16 `seq` 
Just (w0,[w1 .. w16])

A further speedup results from switching from lists to a custom datatype:

data WW = WW
{ f0,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15 :: !Word32 }

fromL :: [Word32] - WW
fromL (w0:w1:w2:w3:w4:w5:w6:w7:w8:w9:w10:w11:w12:w13:w14:w15:_)
= WW w0 w1 w2 w3 w4 w5 w6 w7 w8 w9 w10 w11 w12 w13 w14 w15

next :: WW - WW
next (WW w0 w1 w2 w3 w4 w5 w6 w7 w8 w9 w10 w11 w12 w13 w14 w15)
= WW w1 w2 w3 w4 w5 w6 w7 w8 w9 w10 w11 w12 w13 w14 w15 (rotL 1 $ w0 `xor` 
w2 `xor` w8 `xor` w13)

v4 :: a - [Word32] - [Word32]
v4 ss xs = take 80 $ unfoldr (\ww - Just (f0 ww, next ww)) $ fromL xs

is about 16% faster than your v1 here.
Very odd, now this is slower than just strictifying, though I haven't touched 
that code. I still have the binary where v4 as above is faster than v1 (with 
or without added strictness), but in all more recently compiled versions it's 
slower than strictified v1.
How can that happen?

The STUArray version is about 9% faster if you use unsafeRead/Write instead of 
read/writeArray (we know it's safe here), a further 2% I gained by a slightly 
different loop (we needn't use list-indexing since we copy it in order):

v3 ss xs = ws
where
  ws = runST us
  us =
 do w - newArray (0,79) 0 :: ST s (STUArray s Int Word32)
let put = unsafeWrite w
look = unsafeRead w
loop 80 = getElems w
loop n = do wm16 - look (n-16)
wm14 - look (n-14)
wm8  - look (n-8)
wm3  - look (n-3)
put n (rotL 1 $ wm3 `xor` wm8 `xor` wm14 `xor` 
wm16)
loop (n+1)
ini n [] = loop n
ini n (x:xs)
   = do put n x
ini (n+1) xs
ini 0 xs


 Should I have been disappointed?

Don't know, I'm somewhat disappointed that a C-version is almost three times 
as fast as the STUArray version.
And I'm really astonished that compiled with -O0 the Unfold version is more 
than twice as fast as the STUArray.
Phrased differently, optimising (-O2) doesn't help the Unfold version much, 
but speeds the STUArray version up more than four times!

Cheers,
Daniel


 Dominic.


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


Re: [Haskell-cafe] faster factorial function via FFI?

2007-04-23 Thread David Roundy
On Mon, Apr 23, 2007 at 01:06:07PM -0500, Dan Drake wrote:
 Hello everyone,

Hi!

 I have some code in which the bottleneck is the factorial function. I
 began by using a naive
 
   fac n = product [1..n]
 
 but it looks like there are faster ways to do it. I could try to look up
 those faster algorithms and implement them, but I'm guessing that using
 libgmp's factorial function is the best way to do it. I'm a poor
 programmer, so I don't trust myself to implement those algorithms
 properly. Hence I need to use FFI.

I'm curious: what is your application? I've never seen one in which
factorials actually need be computed.  In physics, one factorial is
generally divided by another (e.g. for combinatorics), so it's rarely wise
to take the actual factorials.  And to be honest, we usually take the
thermodynamic limit and then use Stirling's approximation.  I guess they
also show up in Taylor expansions, but then we never go far enough for the
factorial to be expensive.

 Is there an easy way to do this? It might also be faster to use a lookup
 table, since most of the time I'll be taking factorials of relatively
 small numbers. 

If you really have small numbers and need speed, I'd switch to using Ints.
That'd gain you a lot more than an optimized Integer factorial.
-- 
David Roundy
Department of Physics
Oregon State University


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


[Haskell-cafe] New York Functional Programmers Network Inaugural Meeting - Thurs day May 3rd 2007 from 6pm

2007-04-23 Thread Mansell, Howard
We are starting up a New York area-based network for functional programmers. 
The idea is to have a regular meeting through which functional programmers can 
meet to discuss experiences, get and give information, find jobs etc.

The first official meeting will be held on Thursday May 3rd at the offices of 
Credit Suisse in Manhattan, from 6pm to ~8pm.  The meeting is intended to be an 
informal gathering and refreshments will be provided to make the experience 
even more pleasant.

Please let me know if you would like to attend so that I can make sure we have 
a large enough room and adequate libation.

Howard Mansell (Credit Suisse) 
Jeff Polakow (Deutsche Bank) 


==
Please access the attached hyperlink for an important electronic communications 
disclaimer: 

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Announce: DisTract: Distributed Bug Tracker implemented in Haskell

2007-04-23 Thread Matthew Sackman
DisTract is a Distributed Bug Tracker.

We're all now familiar with working with distributed software control
systems, such as Monotone, Git, Darcs, Mercurial and others, but bug
trackers still seem to be fully stuck in the centralised model:
Bugzilla and Trac both have single centralised servers. This is
clearly wrong, as if you're able to work on the Train, off the
network and still perform local commits of code then surely you should
also be able to locally close bugs too.

DisTract allows you to manage bugs in a distributed manner through
your web-browser. Currently only Firefox is supported. The reason for
this is that there is no local server used, and so the web-browser
must directly (via Javascript) call programs on your local system. I
only know how to do this in Firefox. The distribution is achieved by
making use of a distributed software control system, Monotone. Thus
Monotone is used to move files across the network, perform merging
operations and track the development of every bug. Finally, the glue
in the middle that generates the HTML summaries and modifies the bugs
is written in Haskell.

The first version, 0.1 has just been released. There are missing
features currently, and I've only tested it on Linux. However, it
should work on OS X and Windows if you can make it compile! It's only
been tested with Monotone version 0.33.

http://www.distract.wellquite.org/

Many thanks,

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


Re: [Haskell-cafe] Announce: DisTract: Distributed Bug Tracker implemented in Haskell

2007-04-23 Thread Bryan O'Sullivan
Nice.  You might find Bugs Everywhere 
http://www.panoramicfeedback.com/opensource/ interesting for comparison.


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


[Haskell-cafe] ANN: template 0.1 - Simple string substitution

2007-04-23 Thread Johan Tibell

As an exercise I wrote a simple string substitution library that supports
$-based substitution ala Perl or Python. Example usage:


import qualified Data.ByteString.Lazy.Char8 as B
import Text.Template

context = Map.fromList . map packPair
where packPair (x, y) = (B.pack x, B.pack y)

helloTemplate = B.pack Hello, $name! Want some ${fruit}s?
helloContext = context [(name, Johan), (fruit, banana)]

main = B.putStrLn $ substitute helloTemplate helloContext


Hopefully this is useful for someone who needs something more readable
than Text.Printf's %s-based substitution or string concatenation for
longer strings but less than a full blown templating system like the
ones found in most web frameworks.

Release:
http://www.johantibell.com/template/template-0.1.tar.gz

Source:
darcs get http://darcs.johantibell.com/template

Once we get ByteString literals most of the noise in the above example
will disappear. In the mean time it's probably a good idea to write
utility function like context above when you prefer a convenient
String interface to a somewhat faster ByteString interface.

It would be great if someone could do a code review and add it to
Hackage if it looks OK. I'll really appreciate the feedback. Also, I'm
not 100% sure how to make the haddock links work with Hackage so they
link to the library docs. Is this something done at upload time?

Here are some open issues:

  * I currently use my own ByteString parser. Data.Binary almost does
what I need. Basically I need takeWhile and two chars of look-ahead.

  * I would like to only depend on base, currently I use State so I
depend on mtl.

Cheers,

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


[Haskell-cafe] QuickCheck testing of AST transformers

2007-04-23 Thread Joel Reymont
My previous post did not receive any replies so I thought I might try  
generalizing the problem a bit...


Suppose I'm parsing a language into a syntax tree and then  
transforming that tree into another AST representing a core  
language. The core language is a more general AST that should help  
with compiling to other languages.


My problem is how to best structure my AST transformations to be able  
to test them with QuickCheck. I suspect that I'm not going about it  
in the most optimal way so I thought I should ask for suggestions.


The transformation into the core AST applies operations to simplify,  
or desugar, the AST of the original language. Here's sample code in  
the source language which, incidentally, was recently highlighted at  
Lambda the Ultimate [1].


Array: MyArray[10](10 + 2);
Value1 = MyArray[5][10];

This declares an array of 10 elements and initializes each element to  
12. Value1 (a built-in variable) is then initialized to the value of  
element #5 as of 10 bars ago. A bar is, basically, a stock quote. The  
code is invoked on every bar and so 5 bars ago can be treated as 5  
invocations ago.


The syntax tree of the above code is a 1-1 mapping. We declare an  
array of integers of 10 elements. Initialize it to the sum of two  
integers and then assign to Value1.


[ ArrayDecs [ VarDecl (VarIdent MyArray) TyInt [Int 10]
  (Op Plus (Int 10) (Int 2)) ]
, Assign (VarIdent Value1) [] (Var (VarIdent MyArray) [Int 5]
 (BarsBack (Int 10))) ]

The desugared version does away with the array declaration  
statement and declares MyArray to be a variable of array type. Arrays  
in the core language do not remember values from one invocation to  
another but there's a data series type, so we declare a series  
variable to hold the value of element #5.


We must manually store the value of the array element in the data  
series and can then refer to the value of the series 10 data points ago.


vars = [ (MyArray, VarDecl (TyArray TyInt) [Int 10]
   (Just (Plus (Int 10) (Int 2
   , (series0, VarDecl (TySeries TyInt) [] Nothing)
   ]

code = [ AddToSeries (VarIdent series0) (Var (VarIdent MyArray)  
[Int 5])

   , Assign (Var (VarIdent Value1) [])
(Series (VarIdent series0) (Int 10))
   ]

The next step would be to take the above core syntax tree and  
transform it yet again into a C# (or other target language) AST. It's  
assumed that all target languages have a data series type.


The OCaml version of my code translated directly into the C# AST but  
I figured an intermediate syntax tree will help me translate into  
other languages such as Haskell, Erlang or OCaml.


The part I can't figure out is how to come up with a set of  
invariants for my transformations.


Should I, for example, state that every access to an array value in a  
previous invocation should introduce an extra variable to hold the  
series plus the appropriate assignment code?


Should I write the translator as a series of small transformers in  
the ST monad that can be threaded and tested separately?


Thanks in advance, Joel

[1] http://lambda-the-ultimate.org/node/2201

--
http://wagerlabs.com/





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


Re: [Haskell-cafe] QuickCheck testing of AST transformers

2007-04-23 Thread Lennart Augustsson
Without looking into your language and transformation in more detail  
it's hard to come up with concrete suggestions.  But here are some  
anyway:


Write an interpreter for each of your languages (original AST,  
transformed AST) etc, and then use a quickcheck property stating that  
well formed programs have the same denotation before and after  
transformation, i.e., the two interpreters give the same value (you  
might need some relaxed notion of same).


You transformations are trying to get rid of some language construct,  
I presume.  So you can have some properties stating that they will be  
gone in the transformed program..


-- Lennart


On Apr 23, 2007, at 22:46 , Joel Reymont wrote:

My previous post did not receive any replies so I thought I might  
try generalizing the problem a bit...


Suppose I'm parsing a language into a syntax tree and then  
transforming that tree into another AST representing a core  
language. The core language is a more general AST that should help  
with compiling to other languages.


My problem is how to best structure my AST transformations to be  
able to test them with QuickCheck. I suspect that I'm not going  
about it in the most optimal way so I thought I should ask for  
suggestions.


The transformation into the core AST applies operations to  
simplify, or desugar, the AST of the original language. Here's  
sample code in the source language which, incidentally, was  
recently highlighted at Lambda the Ultimate [1].


Array: MyArray[10](10 + 2);
Value1 = MyArray[5][10];

This declares an array of 10 elements and initializes each element  
to 12. Value1 (a built-in variable) is then initialized to the  
value of element #5 as of 10 bars ago. A bar is, basically, a stock  
quote. The code is invoked on every bar and so 5 bars ago can be  
treated as 5 invocations ago.


The syntax tree of the above code is a 1-1 mapping. We declare an  
array of integers of 10 elements. Initialize it to the sum of two  
integers and then assign to Value1.


[ ArrayDecs [ VarDecl (VarIdent MyArray) TyInt [Int 10]
  (Op Plus (Int 10) (Int 2)) ]
, Assign (VarIdent Value1) [] (Var (VarIdent MyArray) [Int 5]
 (BarsBack (Int 10))) ]

The desugared version does away with the array declaration  
statement and declares MyArray to be a variable of array type.  
Arrays in the core language do not remember values from one  
invocation to another but there's a data series type, so we declare  
a series variable to hold the value of element #5.


We must manually store the value of the array element in the data  
series and can then refer to the value of the series 10 data points  
ago.


vars = [ (MyArray, VarDecl (TyArray TyInt) [Int 10]
   (Just (Plus (Int 10) (Int 2
   , (series0, VarDecl (TySeries TyInt) [] Nothing)
   ]

code = [ AddToSeries (VarIdent series0) (Var (VarIdent MyArray)  
[Int 5])

   , Assign (Var (VarIdent Value1) [])
(Series (VarIdent series0) (Int 10))
   ]

The next step would be to take the above core syntax tree and  
transform it yet again into a C# (or other target language) AST.  
It's assumed that all target languages have a data series type.


The OCaml version of my code translated directly into the C# AST  
but I figured an intermediate syntax tree will help me translate  
into other languages such as Haskell, Erlang or OCaml.


The part I can't figure out is how to come up with a set of  
invariants for my transformations.


Should I, for example, state that every access to an array value in  
a previous invocation should introduce an extra variable to hold  
the series plus the appropriate assignment code?


Should I write the translator as a series of small transformers in  
the ST monad that can be threaded and tested separately?


Thanks in advance, Joel

[1] http://lambda-the-ultimate.org/node/2201

--
http://wagerlabs.com/





___
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] faster factorial function via FFI?

2007-04-23 Thread Stefan O'Rear
On Mon, Apr 23, 2007 at 01:06:07PM -0500, Dan Drake wrote:
 Hello everyone,
 
 I have some code in which the bottleneck is the factorial function. I
 began by using a naive
 
   fac n = product [1..n]
 
 but it looks like there are faster ways to do it. I could try to look up
 those faster algorithms and implement them, but I'm guessing that using
 libgmp's factorial function is the best way to do it. I'm a poor
 programmer, so I don't trust myself to implement those algorithms
 properly. Hence I need to use FFI.
 
 ...but ghc already uses libgmp for Integers, so shouldn't I be able to
 somehow call libgmp's factorial function?
 
 Using regular FFI stuff, it looks like this might get complicated, since
 the function doesn't return one of the usual foreign types, so I'd need
 to mess around to get the result into an Integer, which is what I need.
 
 Is there an easy way to do this? It might also be faster to use a lookup
 table, since most of the time I'll be taking factorials of relatively
 small numbers. 

In addition to David's comments, note that there was a huge thread on
fast fibonaccis recently, including a FFI fibonacci..  Note that the
fastest haskell fibonacci was 3 LoC and only 25% slower than the one
in libgmp. 

http://haskell.org/pipermail/haskell-cafe/2007-February/022647.html

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


Re: [Haskell-cafe] QuickCheck testing of AST transformers

2007-04-23 Thread Thomas Schilling
Additionally, as a safety net, you might want to type-check the code  
that's being produced by your Arbitrary instances and state some  
invariants on your code.  Also, you'll likely want to limit your  
number of evaluation steps if your language allows non-terminating  
programs.


In any case, QuickCheck may not get you far enough to gain enough  
confidence, so proving properties by hand (after you made sure that  
QuickCheck doesn't find any counter-examples, of course) can give you  
interesting insights, since, this way, you have to take a look at all  
the possible cases yourself.


/Thomas


On 24 apr 2007, at 00.05, Lennart Augustsson wrote:

Without looking into your language and transformation in more  
detail it's hard to come up with concrete suggestions.  But here  
are some anyway:


Write an interpreter for each of your languages (original AST,  
transformed AST) etc, and then use a quickcheck property stating  
that well formed programs have the same denotation before and after  
transformation, i.e., the two interpreters give the same value  
(you might need some relaxed notion of same).


You transformations are trying to get rid of some language  
construct, I presume.  So you can have some properties stating that  
they will be gone in the transformed program..


-- Lennart


On Apr 23, 2007, at 22:46 , Joel Reymont wrote:

My previous post did not receive any replies so I thought I might  
try generalizing the problem a bit...


Suppose I'm parsing a language into a syntax tree and then  
transforming that tree into another AST representing a core  
language. The core language is a more general AST that should  
help with compiling to other languages.


My problem is how to best structure my AST transformations to be  
able to test them with QuickCheck. I suspect that I'm not going  
about it in the most optimal way so I thought I should ask for  
suggestions.


The transformation into the core AST applies operations to  
simplify, or desugar, the AST of the original language. Here's  
sample code in the source language which, incidentally, was  
recently highlighted at Lambda the Ultimate [1].


Array: MyArray[10](10 + 2);
Value1 = MyArray[5][10];

This declares an array of 10 elements and initializes each element  
to 12. Value1 (a built-in variable) is then initialized to the  
value of element #5 as of 10 bars ago. A bar is, basically, a  
stock quote. The code is invoked on every bar and so 5 bars ago  
can be treated as 5 invocations ago.


The syntax tree of the above code is a 1-1 mapping. We declare an  
array of integers of 10 elements. Initialize it to the sum of two  
integers and then assign to Value1.


[ ArrayDecs [ VarDecl (VarIdent MyArray) TyInt [Int 10]
  (Op Plus (Int 10) (Int 2)) ]
, Assign (VarIdent Value1) [] (Var (VarIdent MyArray) [Int 5]
 (BarsBack (Int 10))) ]

The desugared version does away with the array declaration  
statement and declares MyArray to be a variable of array type.  
Arrays in the core language do not remember values from one  
invocation to another but there's a data series type, so we  
declare a series variable to hold the value of element #5.


We must manually store the value of the array element in the data  
series and can then refer to the value of the series 10 data  
points ago.


vars = [ (MyArray, VarDecl (TyArray TyInt) [Int 10]
   (Just (Plus (Int 10) (Int 2
   , (series0, VarDecl (TySeries TyInt) [] Nothing)
   ]

code = [ AddToSeries (VarIdent series0) (Var (VarIdent  
MyArray) [Int 5])

   , Assign (Var (VarIdent Value1) [])
(Series (VarIdent series0) (Int 10))
   ]

The next step would be to take the above core syntax tree and  
transform it yet again into a C# (or other target language) AST.  
It's assumed that all target languages have a data series type.


The OCaml version of my code translated directly into the C# AST  
but I figured an intermediate syntax tree will help me translate  
into other languages such as Haskell, Erlang or OCaml.


The part I can't figure out is how to come up with a set of  
invariants for my transformations.


Should I, for example, state that every access to an array value  
in a previous invocation should introduce an extra variable to  
hold the series plus the appropriate assignment code?


Should I write the translator as a series of small transformers in  
the ST monad that can be threaded and tested separately?


Thanks in advance, Joel

[1] http://lambda-the-ultimate.org/node/2201

--
http://wagerlabs.com/





___
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] QuickCheck testing of AST transformers

2007-04-23 Thread Neil Mitchell

Hi

My experience is that generating correct AST's is hard to get right.
I've found regression testing to be more useful when doing program
transformation.

I would follow Lennarts solution of writing a function that
semantically evaluates each expression. I would then add a bit into
your program which automatically does this check after each
transformation. This way if your code goes wrong you'll find out
sooner.

Thanks

Neil


On 4/23/07, Joel Reymont [EMAIL PROTECTED] wrote:

My previous post did not receive any replies so I thought I might try
generalizing the problem a bit...

Suppose I'm parsing a language into a syntax tree and then
transforming that tree into another AST representing a core
language. The core language is a more general AST that should help
with compiling to other languages.

My problem is how to best structure my AST transformations to be able
to test them with QuickCheck. I suspect that I'm not going about it
in the most optimal way so I thought I should ask for suggestions.

The transformation into the core AST applies operations to simplify,
or desugar, the AST of the original language. Here's sample code in
the source language which, incidentally, was recently highlighted at
Lambda the Ultimate [1].

Array: MyArray[10](10 + 2);
Value1 = MyArray[5][10];

This declares an array of 10 elements and initializes each element to
12. Value1 (a built-in variable) is then initialized to the value of
element #5 as of 10 bars ago. A bar is, basically, a stock quote. The
code is invoked on every bar and so 5 bars ago can be treated as 5
invocations ago.

The syntax tree of the above code is a 1-1 mapping. We declare an
array of integers of 10 elements. Initialize it to the sum of two
integers and then assign to Value1.

[ ArrayDecs [ VarDecl (VarIdent MyArray) TyInt [Int 10]
   (Op Plus (Int 10) (Int 2)) ]
, Assign (VarIdent Value1) [] (Var (VarIdent MyArray) [Int 5]
  (BarsBack (Int 10))) ]

The desugared version does away with the array declaration
statement and declares MyArray to be a variable of array type. Arrays
in the core language do not remember values from one invocation to
another but there's a data series type, so we declare a series
variable to hold the value of element #5.

We must manually store the value of the array element in the data
series and can then refer to the value of the series 10 data points ago.

vars = [ (MyArray, VarDecl (TyArray TyInt) [Int 10]
(Just (Plus (Int 10) (Int 2
, (series0, VarDecl (TySeries TyInt) [] Nothing)
]

code = [ AddToSeries (VarIdent series0) (Var (VarIdent MyArray)
[Int 5])
, Assign (Var (VarIdent Value1) [])
 (Series (VarIdent series0) (Int 10))
]

The next step would be to take the above core syntax tree and
transform it yet again into a C# (or other target language) AST. It's
assumed that all target languages have a data series type.

The OCaml version of my code translated directly into the C# AST but
I figured an intermediate syntax tree will help me translate into
other languages such as Haskell, Erlang or OCaml.

The part I can't figure out is how to come up with a set of
invariants for my transformations.

Should I, for example, state that every access to an array value in a
previous invocation should introduce an extra variable to hold the
series plus the appropriate assignment code?

Should I write the translator as a series of small transformers in
the ST monad that can be threaded and tested separately?

Thanks in advance, Joel

[1] http://lambda-the-ultimate.org/node/2201

--
http://wagerlabs.com/





___
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-23 Thread Rafael Almeida

All in all it doesn't really matter what system you run. What you
really need is a haskell compiler or interpreter installed, preferable
one compatible with the standard and latest version of programs you
may want to research. Use the system you alredy know how it works so
the OS won't bug you whenever you're writting your haskell code. Other
than that, you'll be able to install and use a good haskell compiler
or interpreter in any unix or windows (except maybe win98 and older).

Now, if you're polling the list, I usually do most of my development
on a debian linux box with the vim editor.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] COM and Haskell

2007-04-23 Thread Rafael

Hi, I don't read it, anyway you can try.

http://liinwww.ira.uka.de/cgi-bin/bibshow?e=Njtd0DjufTffs02::8%6015/fyqboefe%7d3352:26r=bibtexmode=intra
http://research.microsoft.com/%7esimonpj/Papers/com.ps.gz

att
Rafael Cabral


On 4/19/07, Justin Bailey [EMAIL PROTECTED] wrote:

All,

I'm interested in automating Excel using Haskell. I'm writing a little
program for my wife and it'd be nice to fill out an Excel spreadsheet for
her (with formatting so I don't think CSV will cut it). A bit of Googling
didn't turn up anything interesting.

Has any work been done on using Excel (or more generally, COM) from Haskell?

Thanks for any pointers!

Justin

p.s. I'm aware of the article Spreadsheet for Functional Programmers
article and Neil Mitchell's post about HsExcel - but those go the wrong way
:(

___
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] faster factorial function via FFI?

2007-04-23 Thread Dan Drake
On Mon, 23 Apr 2007 at 12:03PM -0700, David Roundy wrote:
 I'm curious: what is your application? I've never seen one in which
 factorials actually need be computed.  In physics, one factorial is
 generally divided by another (e.g. for combinatorics), so it's rarely
 wise to take the actual factorials.  And to be honest, we usually take
 the thermodynamic limit and then use Stirling's approximation.  I
 guess they also show up in Taylor expansions, but then we never go far
 enough for the factorial to be expensive.

This is combinatorics, so I can't just say oh, this is small and cross
it off like physicists do. :)

I'm finding the number of set partitions that correspond to a certain
integer partition. If p = p_1, p_2,...,p_k is an integer partition of n,
then there are

   n!
 --
 p_1! * p_2! * ... * p_k! * 1^c_1 * ... * k^c_k

set partitions of [1..n] with type p, where c_i is the number of i's
in p. Knuth, in his new Art of Computer Programming book, asks which
integer partition maximizes the number of set partitions. I'm trying to
figure it out.

Usings Ints everywhere isn't an option, because my final answers are
definitely Integers -- although I might try using Ints in some places. I
am still very new to Haskell and keep butting up against the type
system, so initially I made everything an Integer so that my code would
work!

Doing cancellation before computing the factorials is also an option,
but in general I'll have a lot of small numbers on the bottom, and would
need to do a lot of integer factoring on the top -- and my impression is
that integer factoring is quite slow, faster than integer multiplication
-- that's why RSA works, right?!

Dan

-- 
Ceci n'est pas une .signature.


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


Re: [Haskell-cafe] faster factorial function via FFI?

2007-04-23 Thread Stefan O'Rear
On Mon, Apr 23, 2007 at 06:25:39PM -0500, Dan Drake wrote:
 On Mon, 23 Apr 2007 at 12:03PM -0700, David Roundy wrote:
  I'm curious: what is your application? I've never seen one in which
  factorials actually need be computed.  In physics, one factorial is
  generally divided by another (e.g. for combinatorics), so it's rarely
  wise to take the actual factorials.  And to be honest, we usually take
  the thermodynamic limit and then use Stirling's approximation.  I
  guess they also show up in Taylor expansions, but then we never go far
  enough for the factorial to be expensive.
 
 This is combinatorics, so I can't just say oh, this is small and cross
 it off like physicists do. :)
 
 I'm finding the number of set partitions that correspond to a certain
 integer partition. If p = p_1, p_2,...,p_k is an integer partition of n,
 then there are
 
n!
  --
  p_1! * p_2! * ... * p_k! * 1^c_1 * ... * k^c_k

That formula isn't even correct.  Consider p = replicate n 1, that is
n partitions each of size 1.  There is only one way to do this - put
each element in its own partition.  However, your formula gives:

 n!
-
1! * 1! * 1! * 1! ... * 1^n * 2^0 * 3^0 * ...

==

n!
--
1

It might go faster if you used the right equation.

 set partitions of [1..n] with type p, where c_i is the number of i's
 in p. Knuth, in his new Art of Computer Programming book, asks which
 integer partition maximizes the number of set partitions. I'm trying to
 figure it out.
 
 Usings Ints everywhere isn't an option, because my final answers are
 definitely Integers -- although I might try using Ints in some places. I
 am still very new to Haskell and keep butting up against the type
 system, so initially I made everything an Integer so that my code would
 work!
 
 Doing cancellation before computing the factorials is also an option,
 but in general I'll have a lot of small numbers on the bottom, and would
 need to do a lot of integer factoring on the top -- and my impression is
 that integer factoring is quite slow, faster than integer multiplication
 -- that's why RSA works, right?!

Don't forget than n! is easily partially factored - it is 1 * 2 * 3 * ... * n

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


Re: [Haskell-cafe] faster factorial function via FFI?

2007-04-23 Thread Bryan O'Sullivan

Dan Drake wrote:


This is combinatorics, so I can't just say oh, this is small and cross
it off like physicists do. :)


Binary splitting is much faster than the naive approach, but still easy 
to understand.  That's fac1 in the attached file.


I ran out of time to write an efficient implementation using swing 
numbers, but my slow, crummy version is present as fac2, just as a data 
point.


b
{-# OPTIONS_GHC -fbang-patterns #-}

import Data.Bits (Bits, (..))
import System.Environment (getArgs)

fac0 :: Integral a = a - a

fac0 n = product [1..n]

fac1 :: Integral a = a - a

fac1 n = prod n 0
where prod a b = let d = a - b
 in if d  0
then 0
else case d of
   0 - 1
   1 - a
   2 - a * (a - 1)
   3 - a * (a - 1) * (a - 2)
   _ - let m = (a + b) `div` 2
in prod a m * prod m b


fac2 :: (Integral a, Bits a) = a - a

fac2 0 = 1
fac2 n = let f2 = fac2 (n `div` 2)
 in f2 * f2 * swing n
where swing n = let b = case n `mod` 4 of
  0 - 1
  1 - n `div` 2 + 1
  2 - 2
  3 - 2 * (n `div` 2 + 2)
z = 2 * (n - ((n + 1) .. 1))
in loop b z 1
  where loop !b !z !i
| i == n `div` 4 + 1 = b
| otherwise = let b' = (b * z) `div` i
  z' = z - 4
  in loop b' z' (i + 1)

fac :: (Integral a, Bits a) = a - a

fac n | n  500   = fac1 n
  | otherwise = fac2 n


main :: IO ()

main = do
  (f:ns) - getArgs
  let func = case f of
   0 - fac0
   1 - fac1
   2 - fac2
   _ - error Huh?
  print (map (odd . func . (read :: String - Integer)) ns)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] faster factorial function via FFI?

2007-04-23 Thread David Roundy
On Mon, Apr 23, 2007 at 06:25:39PM -0500, Dan Drake wrote:
 I'm finding the number of set partitions that correspond to a certain
 integer partition. If p = p_1, p_2,...,p_k is an integer partition of n,
 then there are
 
n!
  --
  p_1! * p_2! * ... * p_k! * 1^c_1 * ... * k^c_k
...
 Doing cancellation before computing the factorials is also an option,
 but in general I'll have a lot of small numbers on the bottom, and would
 need to do a lot of integer factoring on the top -- and my impression is
 that integer factoring is quite slow, faster than integer multiplication
 -- that's why RSA works, right?!

In many cases, cancelling out the largest factorial on the bottom should be
a win:

n!
x =  
 p_1! * p_2! * ... * p_k!

x n ps = product [max ps..n] / (product $ concat $ map (\p-[1..p]) $ delete 
(max ps) ps)

and yes, that's pseudocode... max has wrong type.

of course, this only helps if you've got a big p.  At least there's always
a biggest p.
-- 
David Roundy
Department of Physics
Oregon State University
___
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-23 Thread Albert Y. C. Lai

Albert Y. C. Lai wrote:
I try using WordSet = [String] (plus corresponding change in code) and 
get great speedup, actually way more than 3x. There was also a memory 
growth phenomenon using Set String, and replacement by [String] stops 
that too, now it's constant space (constant = 20M). It is possible to 
attribute part of the speedup to excellent rewrite rules in GHC 
regarding lists; however, I cannot explain the memory growth when using 
Set.


Now I see. The higher memory usage of the Set version is not growth or 
leak, just brutal. For each input word, a ton of derived words are 
generated, and an optimal one is chosen (by a criterion that's 
essentially a mapping from words to scores). There are two ways to do this.


You could put the derived words into a lazy list and then traverse it, 
and therefore they're generated, examined, and thrown away on demand. At 
most two words are ever going to be stored (the best one so far and the 
next candidate), maybe plus a couple of cons cells if the compiler does 
not optimize.


Or you could put all derived words into a set first (to avoid 
duplicates, but note that you still have to generate a ton, you only 
save by storing just half a ton), then traverse it. Storing a ton, or 
even just half a ton, of these words is going to clog up memory.
The perceived growth is only because some input words cause fewer 
derived words and some other input words encountered later cause more 
derived words. So, plotting memory over time, once in a while we have 
more derived words than before, so the heap grows for that; they are 
still thrown away correctly in due course. If you input the same input 
word over and over gain, space usage is still constant.

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


Re: [Haskell-cafe] COM and Haskell

2007-04-23 Thread Andrew Appleyard

On 24/04/2007, at 1:39 am, Justin Bailey wrote:
Give me a way to get to the .NET libraries and the world is my  
oyster ...


I second that :-)  Such access will probably become more important  
over time as Microsoft release more .NET-only libraries (like Windows  
Presentation Foundation and Windows Communication Foundation).


Hugs98.NET and GHC's Dotnet foreign calls already allow calling  
of .NET methods (although I haven't tried the latter).  These operate  
at a rather low-level though.


I'm working on a Haskell to .NET bridge, partially inspired by Lam's  
work on RubyCLR, for my undergraduate thesis this year.  Hopefully it  
will be a viable option when completed.


It's like he built an embedded DSL for interacting with .NET. I  
imagine the same could be done in Haskell, though it might involve  
some sort of code generation technique.


A core difficulty is the mismatch between the object-oriented type  
system of .NET and Haskell's.  This is something that RubyCLR didn't  
need to conquer, Ruby already having object-oriented concepts.


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


[Haskell-cafe] Re: haskell question

2007-04-23 Thread Greg Meredith

Oleg,

Many thanks. i also found some course notes from Advance Functional
Programming at Utrecht very useful. i have to wait until i have quality time
to go over this because the next step is to close the final loop to find the
fix point of

  - Process = Process(Nominate(Process))

i haven't worked out the correct instance syntax to express this idea. But,
i think the direction you pointed me in is the right one.

Best wishes,

--greg

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



 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.





--
L.G. Meredith
Managing Partner
Biosimilarity LLC
505 N 72nd St
Seattle, WA 98103

+1 206.650.3740

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


Re: [Haskell-cafe] faster factorial function via FFI?

2007-04-23 Thread Dan Weston
Why all the fuss? n! is in fact very easily *completely* factored into 
prime numbers (and this never changes, so you can just read in a binary 
lookup table). It took my machine only 3 seconds to find the prime 
factors of the first 1000 factorials:


Then you can do for example:

import List

binomCoeffFactors :: Int - Int - [Int]
binomCoeffFactors n k = let pfs = primeFactorials in
   (pfs !! n \\ pfs !! k)
 \\ pfs !! (n-k)

binomCoeff :: Int - Int - Int
binomCoeff n k = foldr (*) 1 (binomCoeffFactors n k)


-- List of primes. This is reasonably fast but doesn't have to be,
-- since we only need it this once to generate the lookup table
primes = (2 : [x | x - [3,5..], isPrime x])

-- Efficient test presupposes the existence of primes
-- This works because to determine whether p is prime you only need
-- to know the primes strictly less than p (except for 2 of course!)
isPrime x = null divisors
  where divisors  = [y | y - onlyUpToSqrtX primes, x `mod` y == 0]
onlyUpToSqrtX = fst . span (= sqrtX)
sqrtX = floor (sqrt (fromIntegral x))

primeFactor' :: [Int] - Int - [Int]
primeFactor' p@(h:t) n
   | n  2 = []
   | otherwise = let (d,m) = n `divMod` h in
 if m == 0 then h : primeFactor' p d
   else primeFactor' t n

primeFactors :: Int - [Int]
primeFactors = let p = primes in primeFactor' p

primeFactorial' :: (Int, [Int]) - (Int, [Int])
primeFactorial' (n,pfs) = (n1,ret)
  where pfn = primeFactors n1
ret = merge pfn pfs
n1  = n + 1

primeFactorials :: [[Int]]
primeFactorials = map snd . iterate primeFactorial' $ (0,[])

-- timingTest 1 takes only 3 seconds!
timingTest :: Int - Int
timingTest nMax = let pfs = primeFactorials in
sum . map sum . take nMax $ pfs

-- PRE : Args  are sorted
-- POST: Result is sorted union
merge as []  = as
merge []  bs = bs
merge aas@(a:as) bbs@(b:bs) | a  b = a : merge as  bbs
| otherwise = b : merge aas bs


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


Re: [Haskell-cafe] faster factorial function via FFI?

2007-04-23 Thread ajb
G'day all.

Quoting Dan Weston [EMAIL PROTECTED]:

 Why all the fuss? n! is in fact very easily *completely* factored into
 prime numbers [...]

It's even easier than that.

primePowerOf :: Integer - Integer - Integer
primePowerOf n p
  = (n - s p n) `div` (p-1)
  where
s p 0 = 0
s p n = let (q,r) = n `divMod` p in s p q + r

factorisedFactorial :: Integer - [(Integer,Integer)]
factorisedFactorial n = [ (p, primePowerOf n p) | p - primesUpTo n ]

factorial :: Integer - Integer
factorial = product . zipWith (^) . factorisedFactorial

(Implement primesUpTo using your favourite prime sieve.)

Manipulating prime factors like this is sometimes MUCH faster than
computing products for this kind of combinatorial work, because Integer
division is quite expensive.

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