Re: [Haskell-cafe] [IO Int] - IO [Int]

2007-05-05 Thread Thomas Hartman

Hoogle is also helpful

http://haskell.org/hoogle/?q=%5Bm+a%5D+-%3E+m+%5Ba%5D

2007/5/4, Phlex [EMAIL PROTECTED]:

Hello all,

I'm trying to learn haskell, so here's is my first newbie question.
I hope this list is appropriate for such help requests.

I'm trying to write a function with the signature [IO Int] - IO [Int]

Here is my first attempt :

conv :: [IO Int] - IO [Int]
conv l = do val - (head l)
return (val : (conv (tail l)))

This does not work as I'm consing an Int to an (IO [Int]).
So I tried this :

conv2 :: [IO Int] - IO [Int]
conv2 l = do val - (head l)
 rest - (conv2 (tail l))
 return (val : rest)

That works, but it won't work for infinite lists.
How could I achieve the desired result ?

Thanks in advance,
Sacha
___
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] Debugging

2007-05-05 Thread Monang Setyawan

On 5/5/07, Stefan O'Rear [EMAIL PROTECTED] wrote:

On Fri, May 04, 2007 at 10:44:15PM -0700, Ryan Dickie wrote:
 I've only written trivial applications and functions in haskell. But the
 title of this thread got me thinking.

 In an imperative language you have clear steps, states, variables to watch,
 etc.
 What techniques/strategies might one use for a functional language?

I personally most often use a divide-and-conquer approach.  I pick a
point about halfway down the call stack, and add trace calls.  If the
subproblems are handled correctly, narrow scope to higher levels;
otherwise narrow to lower levels.  Repeat until you have a single
misbehaving function.


Isn't that called binary search, instead of divide-and-conquer?

BTW, how about adding assertion in Haskell? Can it be done?
(I've searched in my GHC 6.4.2 library documentation, and can't find 'assert')

Is there any way to automatically clean all the mess I've done in
debugging/asserting (like removing all trace/assert expressions) when
I compile Haskell source code? Or should I create a simple program to
remove them?



Stefan




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


Re: [Haskell-cafe] Debugging

2007-05-05 Thread Donald Bruce Stewart
monang:
 On 5/5/07, Stefan O'Rear [EMAIL PROTECTED] wrote:
 On Fri, May 04, 2007 at 10:44:15PM -0700, Ryan Dickie wrote:
  I've only written trivial applications and functions in haskell. But the
  title of this thread got me thinking.
 
  In an imperative language you have clear steps, states, variables to 
 watch,
  etc.
  What techniques/strategies might one use for a functional language?
 
 I personally most often use a divide-and-conquer approach.  I pick a
 point about halfway down the call stack, and add trace calls.  If the
 subproblems are handled correctly, narrow scope to higher levels;
 otherwise narrow to lower levels.  Repeat until you have a single
 misbehaving function.
 
 Isn't that called binary search, instead of divide-and-conquer?
 
 BTW, how about adding assertion in Haskell? Can it be done?
 (I've searched in my GHC 6.4.2 library documentation, and can't find 
 'assert')

'assert' is in Control.Exception. there's also a couple of 3rd party
packages for assert-like behaviour:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/loch-0.2
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Safe-0.1

 
 Is there any way to automatically clean all the mess I've done in
 debugging/asserting (like removing all trace/assert expressions) when
 I compile Haskell source code? Or should I create a simple program to
 remove them?

Using a logging/writer monad might be a nice approach. 'assert's are
compiled out under -O, in G, too.

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


Re: [Haskell-cafe] Debugging

2007-05-05 Thread Monang Setyawan

Sorry, replying myself.

On 5/5/07, Monang Setyawan [EMAIL PROTECTED] wrote:


BTW, how about adding assertion in Haskell? Can it be done?
(I've searched in my GHC 6.4.2 library documentation, and can't find 'assert')


This can be done using Assertions. Lines below are taken from the docs.

Assertions

assert :: Bool - a - a
If the first argument evaluates to True, then the result is the second
argument. Otherwise an AssertionFailed exception is raised, containing
a String with the source file and line number of the call to assert.

Assertions can normally be turned on or off with a compiler flag (for
GHC, assertions are normally on unless optimisation is turned on with
-O or the -fignore-asserts option is given). When assertions are
turned off, the first argument to assert is ignored, and the second
argument is returned as the result.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Detect Either Windows or Linux environment

2007-05-05 Thread Duncan Coutts
On Fri, 2007-05-04 at 22:23 -0700, SevenThunders wrote:

  Prelude System.Info [os, arch]
  [darwin,powerpc]

 Thank you for your help.  I somehow missed that when I was browsing through
 the library documentation.
 On windows, interestingly the os function returns mingw

Yes, that's one of Neil's pet hates. It might change so something more
obvious some time.

Duncan

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


[Haskell-cafe] Re: Monad definition question

2007-05-05 Thread oleg

Ilya Tsindlekht wrote:
 Does the definition of monad silently assume that if f and f' are equal
 in the sense that they return the same value for any argument o correct
 type then m = f = m = f'

Of course NOT! Here's an example, in a State monad

f  x = put True
f' x = put False
Clearly, _by the definition above_, f and f' are the same -- for any
argument of correct type, they return the same value, namely,
(). However, if we perform the observation

execState (return 'a' = f) True
execState (return 'a' = f') True

we quite clearly see the difference. 

Robin Green wrote:
 How could it be otherwise? How are you going to distinguish between f
 and f' if they are indistinguishable functions, in Haskell?

Because f and f' are NOT referentially transparent functions. They are
NOT pure functions, their application may have _an effect_. And
comparing effectful computations is quite difficult. It's possible: I
believe (bi)simulation is the best approach; there are other
approaches.

It may be useful to relate to imperative programming:
m1 = (\x - m2)
is
let x = m1 in m2
Indeed, monadic 'bind' is *exactly* equivalent to 'let' of 
impure eager languages such as ML. The first monadic law
return x = f === f x
is trivial because in eager languages, any value (which is
an effectful-free computation) is by default injected into the world of
possibly effectful expressions: Any value is an expression. The second
law m = (\x - return x) === m 
becomes
let x = e in x  === e
and the third law
(m1 = (\x - m2)) = (\y - m3) === 
m1 = (\x - m2 = \y - m3)   provided x is not free in m3
becomes
let y = (let x = m1 in m2) in m3 ===
let x = m1 in let y = m2 in m3

So, `bind' is `let' and monadic programming is equivalent to
programming in the A-normal form. That is indeed all there is to
monads.

Here's the paragraph from the first page of Filinski's `Representing
Monads' (POPL94)

It is somewhat remarkable that monads have had no comparable impact on
``impure'' functional programming. Perhaps the main reason is that --
as clearly observed by Moggi, but perhaps not as widely appreciated in
the ``purely functional'' community -- the monadic framework is
already built into the semantic core of eager functional languages
with effects, and need not be expressed explicitly. ``Impure''
constructs, both linguistic (e.g., updatable state, exceptions, or
first-class continuations) and external to the language (I/O, OS
interface, etc.), all obey a monadic discipline. The only aspect that
would seem missing is the ability for programmers to use their own,
application-specific monadic abstractions -- such as nondeterminism or
parsers [31] -- with the same ease and naturality as built-in
effects.

Filinski then showed that the latter seemingly missing aspect
indeed only appears to be missing.


It is important to understand that once we come to monads, we lost
referential transparency. Monadic code is more difficult to reason
about -- as any imperative code. One often sees the slogan that
Haskell is the best imperative language. And with monad, it is. One
often forgets that 'best' here has the down-side. Haskell amplifies
both advantages _and_ disadvantages of imperative programming. At
least imperative programmers don't have to think about placing seq at
the right place to make sure a file is read from before it is closed,
and don't have to think about unsafeInterleaveIO. It seems the latter
has become so indispensable that it is recommended to Haskell novices
without a second thought. One may wonder if functional programming
still matters.

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


[Haskell-cafe] The Functional Pearls

2007-05-05 Thread Donald Bruce Stewart
I've created a wiki page collecting the 'functional pearl' papers that
have appeared in JFP and ICFP and other places over the last 20 odd
years.

http://haskell.org/haskellwiki/Research_papers/Functional_pearls

Lots of lovely functional programs there.

There's also a list on that page of pearls that don't appear to be
online. If you know where they live, please add the links!

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


[Haskell-cafe] Re: Monad definition question

2007-05-05 Thread Ilya Tsindlekht
On Sat, May 05, 2007 at 12:09:03AM -0700, [EMAIL PROTECTED] wrote:
 
 Ilya Tsindlekht wrote:
  Does the definition of monad silently assume that if f and f' are equal
  in the sense that they return the same value for any argument o correct
  type then m = f = m = f'
 
 Of course NOT! Here's an example, in a State monad
 
   f  x = put True
   f' x = put False
 Clearly, _by the definition above_, f and f' are the same -- for any
 argument of correct type, they return the same value, namely,
They aren't - they return different values of type State Bool ()
 (). However, if we perform the observation
 
   execState (return 'a' = f) True
   execState (return 'a' = f') True
 
 we quite clearly see the difference. 
Of course - because f 'a' and f' 'a' are different values.
(return 'a' = f is by laws of monad the same as f 'a')
 
 Robin Green wrote:
  How could it be otherwise? How are you going to distinguish between f
  and f' if they are indistinguishable functions, in Haskell?
 
 Because f and f' are NOT referentially transparent functions. They are
 NOT pure functions, their application may have _an effect_. And
They ARE pure functions (just as all Haskell functions)
They return values of monad type. 
 comparing effectful computations is quite difficult. It's possible: I
 believe (bi)simulation is the best approach; there are other
 approaches.
 
 It may be useful to relate to imperative programming:
   m1 = (\x - m2)
 is
   let x = m1 in m2
The analogy is not always straight-forward - try the list monad.
 Indeed, monadic 'bind' is *exactly* equivalent to 'let' of 
 impure eager languages such as ML. The first monadic law
   return x = f === f x
 is trivial because in eager languages, any value (which is
 an effectful-free computation) is by default injected into the world of
 possibly effectful expressions: Any value is an expression. The second
 law   m = (\x - return x) === m 
 becomes
   let x = e in x  === e
 and the third law
   (m1 = (\x - m2)) = (\y - m3) === 
   m1 = (\x - m2 = \y - m3)   provided x is not free in m3
 becomes
   let y = (let x = m1 in m2) in m3 ===
   let x = m1 in let y = m2 in m3
 
 So, `bind' is `let' and monadic programming is equivalent to
 programming in the A-normal form. That is indeed all there is to
 monads.
 
 Here's the paragraph from the first page of Filinski's `Representing
 Monads' (POPL94)
 
 It is somewhat remarkable that monads have had no comparable impact on
 ``impure'' functional programming. Perhaps the main reason is that --
 as clearly observed by Moggi, but perhaps not as widely appreciated in
 the ``purely functional'' community -- the monadic framework is
 already built into the semantic core of eager functional languages
 with effects, and need not be expressed explicitly. ``Impure''
 constructs, both linguistic (e.g., updatable state, exceptions, or
 first-class continuations) and external to the language (I/O, OS
 interface, etc.), all obey a monadic discipline. The only aspect that
 would seem missing is the ability for programmers to use their own,
 application-specific monadic abstractions -- such as nondeterminism or
 parsers [31] -- with the same ease and naturality as built-in
 effects.
 
 Filinski then showed that the latter seemingly missing aspect
 indeed only appears to be missing.
Would this require some kind of macros doing extensive pre-processing
of the code?
 
 
 It is important to understand that once we come to monads, we lost
 referential transparency. Monadic code is more difficult to reason
 about -- as any imperative code. One often sees the slogan that
 Haskell is the best imperative language. And with monad, it is. One
 often forgets that 'best' here has the down-side. Haskell amplifies
 both advantages _and_ disadvantages of imperative programming. At
 least imperative programmers don't have to think about placing seq at
 the right place to make sure a file is read from before it is closed,
 and don't have to think about unsafeInterleaveIO. It seems the latter
 has become so indispensable that it is recommended to Haskell novices
 without a second thought. One may wonder if functional programming
 still matters.
 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Detect Either Windows or Linux environment

2007-05-05 Thread Neil Mitchell

Hi


 Thank you for your help.  I somehow missed that when I was browsing through
 the library documentation.
 On windows, interestingly the os function returns mingw

Yes, that's one of Neil's pet hates. It might change so something more
obvious some time.


On Yhc the os function will return the name of the OS, on GHC and Hugs
it returns mingw even if you are using the native WinHugs build done
using Visual Studio and have never installed mingw...

And its still one of my pet hates!

Thanks

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


[Haskell-cafe] Re: Monad definition question

2007-05-05 Thread oleg

Ilya Tsindlekht wrote
  It may be useful to relate to imperative programming:
m1 = (\x - m2)
  is
let x = m1 in m2
 The analogy is not always straight-forward - try the list monad.

This equivalence holds even for the List Monad. Here is an example of
non-determinism:

http://caml.inria.fr/pub/ml-archives/caml-list/2007/02/1d4df471019050b89e20a002303a8498.en.html

and here's an excerpt from that message, showing lets (aka bind):

let numbers = List.map (fun n - (fun () - n)) [1;2;3;4;5];;
let pyth () = 
  let (v1,v2,v3) =
let i = amb numbers in
let j = amb numbers in
let k = amb numbers in
if i*i + j*j = k*k then (i,j,k) else failwith too bad
  in Printf.printf got the result (%d,%d,%d)\n v1 v2 v3;;

Here, 'amb' is like 'msum' and any error is mzero. If we replace 'let'
with 'do', and '=' with '-' in some places, it looks almost like
Haskell. Although the scheduler (the `run' function of the `monad')
described in the message accumulates all possible worlds, it returns
as soon as one `thread' made it successfully to the end.  It is
trivial to get the scheduler to run the remaining `treads' searching
for more answers (by threads I certainly don't mean OS threads). The
user code above stays as it is.

The implementation of amb has been extended to annotate choices (and
so possible worlds) with probabilities, which propagate in due
course. The result not merely lists the answers but also their
computed probabilities.


  Filinski then showed that the latter seemingly missing aspect
  indeed only appears to be missing.
 Would this require some kind of macros doing extensive pre-processing
 of the code?

Hopefully the code above showed that no macros and no preprocessing
required. In that code, addition, multiplication, if-then-else and all
other OCaml operations remain as they have always been, with no
modifications or redefinitions whatsoever. Delimited continuations
suffice for everything, as Filinski proved in his paper.

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


Re: [Haskell-cafe] The Functional Pearls

2007-05-05 Thread Dougal Stanton

On 05/05/07, Donald Bruce Stewart [EMAIL PROTECTED] wrote:

I've created a wiki page collecting the 'functional pearl' papers that
have appeared in JFP and ICFP and other places over the last 20 odd
years.

http://haskell.org/haskellwiki/Research_papers/Functional_pearls

Lots of lovely functional programs there.



That's wonderful. I only recently found out about them and was blown
away by the beauty of Richard Bird's sudoku solver. (The slides,
anyway.) Let's go straight to the intravenous injection of awesome
programs...

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


Re: [Haskell-cafe] Detect Either Windows or Linux environment

2007-05-05 Thread Andrew Coppin


 Thank you for your help.  I somehow missed that when I was browsing 
through

 the library documentation.
 On windows, interestingly the os function returns mingw

Yes, that's one of Neil's pet hates. It might change so something more
obvious some time.


On Yhc the os function will return the name of the OS, on GHC and Hugs
it returns mingw even if you are using the native WinHugs build done
using Visual Studio and have never installed mingw...

And its still one of my pet hates!


Presumably GHC is compiled under mingw. (Personally I'm not a fan of 
having to use a UNIX emulator when you're actually in M$ Windoze, but 
never mind...)


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


[Haskell-cafe] An interesting toy

2007-05-05 Thread Andrew Coppin




Greetings.

I have something which you might find mildly interesting. (Please don't
attempt the following unless you have some serious CPU power available,
and several hundred MB of hard drive space free.)

 darcs get http://www.orphi.me.uk/darcs/Chaos
 cd Chaos
 ghc -O2 --make System1
 ./System1

On my super-hyper-monster machine, the program takes an entire 15
minutes to run to completion. When it's done, you should have 500
images sitting in front of you. (They're in PPM format - hence the
several hundred MB of disk space!) The images are the frames that make
up an animation; if you can find a way to "play" this animation, you'll
be treated to a truely psychedelic light show! (If not then you'll just
have to admire them one at a time. The first few dozen frames are quite
boring by the way...)

If you want to, you can change the image size. For example, "./System1
800" will render at 800x800 pixels instead of the default 200x200. (Be
prepaired for big slowdowns!)

What is it?

Well, it's a physical simulation of a "chaos pendulum". That is, a
magnetic pendulum suspended over a set of magnets. The pendulum would
just swing back and forth, but the magnets perturb its path in complex
and unpredictable ways.

However, rather than simulate just 1 pendulum, the program simulates
40,000 of them, all at once! For each pixel, a pendulum is initialised
with a velocity of zero and an initial position corresponding to the
pixel coordinates. As the pendulums swing, each pixel is coloured
according to the proximity of the corresponding pendulum to the tree
magnets.

Help requested...

Can anybody tell me how to make the program go faster?

I already replaced all the lists with IOUArrays, which resulted in big,
big speedups (and a large decrease in memory usage). But I don't know
how to make it go any faster. I find it worrying that the process of
converting pendulum positions to colours appears to take significantly
longer than the much more complex task of performing the numerical
integration to discover the new pendulum positions. Indeed, using GHC's
profiling tools indicates that the most time is spent executing the
function "quant8". This function is defined as:

 quant8 :: Double - Word8
 quant8 = floor . (0xFF *)

I can't begin to imagine how this can be the most
compute-intensive part of the program when I've got all sorts of heavy
metal maths going on with the numerical integration and so forth...!
Anyway, if anybody can tell me how to make it run faster, I'd be most
appriciative!

Also, is there an easy way to make the program use both of the
CPUs in my PC? (Given that the program maps two functions over two big
IOUArrays...)

Finally, if anybody has any random comments about the [lack of] qualify
in my source code, feel free...



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


Re: [Haskell-cafe] Is Excel a FP language?

2007-05-05 Thread Andrew Coppin




I just had a thought... Why doesn't somebody implement a
spreadsheet where Haskell is the formula language?  8-) 

I have already been struggling (unsuccessfully) to write a program to
graph functions, but why not go the whole hog and make an entire
spreadsheet program?

Possibly one of the most depressing things about Haskell is that there
isn't one single large application anywhere that you can point to and
say "this was made with Haskell". Maybe this could be that app?



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


Re: [Haskell-cafe] Is Excel a FP language?

2007-05-05 Thread Donald Bruce Stewart
andrewcoppin:
 
I just had a thought... Why doesn't somebody implement a
spreadsheet where Haskell is the formula language? 8-)
I have already been struggling (unsuccessfully) to write a
program to graph functions, but why not go the whole hog and
make an entire spreadsheet program?
Possibly one of the most depressing things about Haskell is
that there isn't one single large application anywhere that
you can point to and say this was made with Haskell. Maybe
this could be that app?

pugs?
darcs?
ghc?
xmonad? (ok, not big)

Lots on haskell.org to point to. pick your favourite one :-)

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


Re: [Haskell-cafe] Is Excel a FP language?

2007-05-05 Thread David House

On 05/05/07, Andrew Coppin [EMAIL PROTECTED] wrote:

 I just had a thought... Why doesn't somebody implement a spreadsheet where
Haskell is the formula language? 8-)


http://sigfpe.blogspot.com/2006/11/from-l-theorem-to-spreadsheet.html
may interest.

--
-David House, [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is Excel a FP language?

2007-05-05 Thread Andrew Coppin


 I just had a thought... Why doesn't somebody implement a spreadsheet 
where

Haskell is the formula language? 8-)


http://sigfpe.blogspot.com/2006/11/from-l-theorem-to-spreadsheet.html
may interest.


...ok, and now my head hurts...

(Haskell seems to do that lots. I'm not sure why.)

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


[Haskell-cafe] a question concerning type constructors

2007-05-05 Thread Eric

Hi all,

In Haskell, is it possible to declare a type constructor with a variable 
number of type variables e.g.


data Tuple * 

allowing the following declarations:

t: Tuple
u: Tuple Bool
v: Tuple Bool Int
w: Tuple Bool Int Char

?

E.


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


Re: [Haskell-cafe] a question concerning type constructors

2007-05-05 Thread Stefan O'Rear
On Sat, May 05, 2007 at 02:26:45PM +0100, Eric wrote:
 Hi all,
 
 In Haskell, is it possible to declare a type constructor with a variable 
 number of type variables e.g.
 
 data Tuple * 
 
 allowing the following declarations:
 
 t: Tuple
 u: Tuple Bool
 v: Tuple Bool Int
 w: Tuple Bool Int Char

No.

(nor is it possible to be kind-polymorphic at all)

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


[Haskell-cafe] c2hs errors when compiling hsGnuTls

2007-05-05 Thread David House

Hey there,

I'm getting the following errors when I try to compile hsGnuTls [1]:

~/hs/sandbox/hsgnutls $ c2hs --version
C-Haskell Compiler, version 0.14.5 Travelling Lightly, 12 Dec 2005
 build platform is i486-pc-linux-gnu 1, True, True, 1
~/hs/sandbox/hsgnutls $ runhaskell Setup.lhs build
Setup.lhs: Warning: The field hs-source-dir is deprecated, please
use hs-source-dirs.
Preprocessing library hsgnutls-0.2.3...
c2hs: Error in C header file.

/usr/include/bits/pthreadtypes.h:69: (column 6) [FATAL]
  Syntax error!
 The symbol `;' does not fit here.

Setup.lhs: got error code while preprocessing: Network.GnuTLS.GnuTLS

c2hs version:

I've attached the file it references in case that's relevant. Any tips
on how I might address this?

Thanks in advance,

-David House, [EMAIL PROTECTED]
/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

#ifndef _BITS_PTHREADTYPES_H
#define _BITS_PTHREADTYPES_H	1

#define __SIZEOF_PTHREAD_ATTR_T 36
#define __SIZEOF_PTHREAD_MUTEX_T 24
#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
#define __SIZEOF_PTHREAD_COND_T 48
#define __SIZEOF_PTHREAD_COND_COMPAT_T 12
#define __SIZEOF_PTHREAD_CONDATTR_T 4
#define __SIZEOF_PTHREAD_RWLOCK_T 32
#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
#define __SIZEOF_PTHREAD_BARRIER_T 20
#define __SIZEOF_PTHREAD_BARRIERATTR_T 4


/* Thread identifiers.  The structure of the attribute type is not
   exposed on purpose.  */
typedef unsigned long int pthread_t;


typedef union
{
  char __size[__SIZEOF_PTHREAD_ATTR_T];
  long int __align;
} pthread_attr_t;


typedef struct __pthread_internal_slist
{
  struct __pthread_internal_slist *__next;
} __pthread_slist_t;


/* Data structures for mutex handling.  The structure of the attribute
   type is not exposed on purpose.  */
typedef union
{
  struct __pthread_mutex_s
  {
int __lock;
unsigned int __count;
int __owner;
/* KIND must stay at this position in the structure to maintain
   binary compatibility.  */
int __kind;
unsigned int __nusers;
__extension__ union
{
  int __spins;
  __pthread_slist_t __list;
};
  } __data;
  char __size[__SIZEOF_PTHREAD_MUTEX_T];
  long int __align;
} pthread_mutex_t;

typedef union
{
  char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
  long int __align;
} pthread_mutexattr_t;


/* Data structure for conditional variable handling.  The structure of
   the attribute type is not exposed on purpose.  */
typedef union
{
  struct
  {
int __lock;
unsigned int __futex;
__extension__ unsigned long long int __total_seq;
__extension__ unsigned long long int __wakeup_seq;
__extension__ unsigned long long int __woken_seq;
void *__mutex;
unsigned int __nwaiters;
unsigned int __broadcast_seq;
  } __data;
  char __size[__SIZEOF_PTHREAD_COND_T];
  __extension__ long long int __align;
} pthread_cond_t;

typedef union
{
  char __size[__SIZEOF_PTHREAD_CONDATTR_T];
  long int __align;
} pthread_condattr_t;


/* Keys for thread-specific data */
typedef unsigned int pthread_key_t;


/* Once-only execution */
typedef int pthread_once_t;


#if defined __USE_UNIX98 || defined __USE_XOPEN2K
/* Data structure for read-write lock variable handling.  The
   structure of the attribute type is not exposed on purpose.  */
typedef union
{
  struct
  {
int __lock;
unsigned int __nr_readers;
unsigned int __readers_wakeup;
unsigned int __writer_wakeup;
unsigned int __nr_readers_queued;
unsigned int __nr_writers_queued;
/* FLAGS must stay at this position in the structure to maintain
   binary compatibility.  */
unsigned int __flags;
int __writer;
  } __data;
  char __size[__SIZEOF_PTHREAD_RWLOCK_T];
  long int __align;
} pthread_rwlock_t;

typedef union
{
  char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
  long int __align;
} pthread_rwlockattr_t;
#endif


#ifdef __USE_XOPEN2K
/* POSIX spinlock data type.  */
typedef volatile int pthread_spinlock_t;


/* POSIX barriers data type.  The structure of the type is
   deliberately not exposed.  */
typedef union
{
  char __size[__SIZEOF_PTHREAD_BARRIER_T];
  long int __align;
} pthread_barrier_t;

typedef union
{
  char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
  int 

Re: [Haskell-cafe] a question concerning type constructors

2007-05-05 Thread Joshua Ball

I'm not sure what you want to accomplish, but if you like type
hackery, this might be helpful:

http://okmij.org/ftp/Haskell/types.html#polyvar-fn

On 5/5/07, Eric [EMAIL PROTECTED] wrote:

Hi all,

In Haskell, is it possible to declare a type constructor with a variable
number of type variables e.g.

data Tuple * 

allowing the following declarations:

t: Tuple
u: Tuple Bool
v: Tuple Bool Int
w: Tuple Bool Int Char

?

E.


___
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] Problems with Hs-Plugins

2007-05-05 Thread Philipp Volgger

I tried following very simple program:

module Main where
import System.Eval.Haskell

main = do i - eval 1 + 6 :: Int [] :: IO (Maybe Int)
  if isJust i then putStrLn (show (fromJust i)) else return ()

I compile it with ghc -c Main.hs and everything seems fine.
When I run it with ghc Main.o I get following message:
Main.o(.text+0x48):fake: undefined reference to 
`AltDataziTypeable_zdfTypeableInt_closure'
Main.o(.text+0x4d):fake: undefined reference to 
`SystemziEvalziHaskell_eval_closure'
Main.o(.text+0x36f):fake: undefined reference to 
`__stginit_SystemziEvalziHaskell_'
Main.o(.rodata+0x0):fake: undefined reference to 
`SystemziEvalziHaskell_eval_closure'
Main.o(.rodata+0x4):fake: undefined reference to 
`AltDataziTypeable_zdfTypeableInt_closure'

collect2: ld returned 1 exit status

When I run it with runhaskell Main I get:



GHCi runtime linker: fatal error: I found a duplicate definition for 
symbol

   _GHCziWord_fromEnum1_closure
whilst processing object file
   c:/ghc/ghc-6-4-2/ghc-6.4.2/HSbase1.o
This could be caused by:
   * Loading two different object files which export the same symbol
   * Specifying the same object file twice on the GHCi command line
   * An incorrect `package.conf' entry, causing some object to be
 loaded twice.
GHCi cannot safely continue in this situation.  Exiting now.  Sorry.

So I did probably something totally wrong, but what?


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


Re: [Haskell-cafe] Problems with Hs-Plugins

2007-05-05 Thread Donald Bruce Stewart
pvolgger:
 I tried following very simple program:
 module Main where
 import System.Eval.Haskell
 
 main = do i - eval 1 + 6 :: Int [] :: IO (Maybe Int)
   if isJust i then putStrLn (show (fromJust i)) else return ()
 I compile it with ghc -c Main.hs and everything seems fine.
 When I run it with ghc Main.o I get following message:
 Main.o(.text+0x48):fake: undefined reference to 
 `AltDataziTypeable_zdfTypeableInt_closure'
 Main.o(.text+0x4d):fake: undefined reference to 
 `SystemziEvalziHaskell_eval_closure'
 Main.o(.text+0x36f):fake: undefined reference to 
 `__stginit_SystemziEvalziHaskell_'
 Main.o(.rodata+0x0):fake: undefined reference to 
 `SystemziEvalziHaskell_eval_closure'
 Main.o(.rodata+0x4):fake: undefined reference to 
 `AltDataziTypeable_zdfTypeableInt_closure'
 collect2: ld returned 1 exit status


You'll need to use --make to link aginst the 'plugins' package.
As in:

ghc --make Main.hs


 When I run it with runhaskell Main I get:


Won't work on windows. You're trying to dynamically link the dynamic
linker, when using 'runhaskell'. (this is ok on ELF systems).

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


[Haskell-cafe] Re: Displaying infered type signature of 'offside' functions

2007-05-05 Thread Georg Sauthoff
Simon Peyton-Jones [EMAIL PROTECTED] wrote:

Hi,

 The principal difficulties here are to do with what do we want rather the 
 implementation challenges.

yes, I thought that too (I mean a haskell compiler have to deal with 'the'
wanted information already for typechecking purposes etc.).

 1.  Should the compiler print the type of every declaration? 

With -tdump-types, yes.

 Should GHCi allow you to ask the type of a local decl?

Yes.

 2.  How should the variables be identified?  There may be many local bindings 
 for 'f', so you can't say just :t f.  Ditto if dumping all local bindings.

Well, for where-bound ones at least I would consider something like

:t f$g$h
or
:t f.g.h

as a useable command to identify this h:

f ... = ..
  where
g ... = ...
where
  h ... = ...

If the hierachy is not unique, :t could print all matches, and if the
user wants to be more specific, he could issue something like
:t f#2.h

for the last h in someting something like
f ... = ...
  where
h ... = ...
f ... = ...
  where
h .. = ...

Well, something like :t f.g.* would be nice, too, where * works like
in 'pattern globbing' (i.e. matching all decls local to  f.g).

 3.  Do you want all locally-bound variables (including those bound by lambda 
 or case), or just letrec/where bound ones?   I think 'all', myself, but there 
 are a lot of them.

I just thought about where/let bound ones. But I am not sure ;)

 4.  (This is the trickiest one.)  The type of a function may mention type 
 variables bound further out.  Consider
 f :: [a] - Int
 f xs = let v = head xs in ...

Have to think about it.

 These are all user-interface issues.  If some people would like to thrash out 
 a design, and put it on the Wiki, I think there is a good chance that someone 
 (possibly even me) would implement it.

Sounds great! I will wait a few days, if someone extends this thread and
then put the ideas from this thread on a wiki-page and post the link
(if not someone else do it first).


Best regards
Georg Sauthoff

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


Re: [Haskell-cafe] The Functional Pearls

2007-05-05 Thread Donald Bruce Stewart
ithika:
 On 05/05/07, Donald Bruce Stewart [EMAIL PROTECTED] wrote:
 I've created a wiki page collecting the 'functional pearl' papers that
 have appeared in JFP and ICFP and other places over the last 20 odd
 years.
 
 http://haskell.org/haskellwiki/Research_papers/Functional_pearls
 
 Lots of lovely functional programs there.
 
 
 That's wonderful. I only recently found out about them and was blown
 away by the beauty of Richard Bird's sudoku solver. (The slides,
 anyway.) Let's go straight to the intravenous injection of awesome
 programs...
 
 D.

Great. It was an idea that came up in #haskell this morning:

19:43:28 geezusfreeek any good articles/tutorials/whatever about
how to best go about actually designing a program in haskell (or
functional languages in general)?

19:48:09 geezusfreeek i have a mostly OO background, and i
want to avoid tainting my functional prog ramming experience
with the OO design patterns and habits i have

19:48:31 geezusfreeek and it's already clear to me that most of my
habits are going to lead me straight to confusion

19:54:48 dons geezusfreeek: possibly some of the functional pearl,
and design-ish, papers from ICFP would be a good read

19:55:10 dons basically replacing going to oxford or chalmers, and
having Richard Bird teach you how to think like a lambda :-)

So, what better way to steep yourself in the design cult(ure) of the
lambda, than to go through the pearls. :-)

-- Don


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


[Haskell-cafe] Re: The Functional Pearls

2007-05-05 Thread Jón Fairbairn
[EMAIL PROTECTED] (Donald Bruce Stewart) writes:

 I've created a wiki page collecting the 'functional pearl' papers that
 have appeared in JFP and ICFP and other places over the last 20 odd
 years.
 
 http://haskell.org/haskellwiki/Research_papers/Functional_pearls
 
 Lots of lovely functional programs there.
 
 There's also a list on that page of pearls that don't appear to be
 online. If you know where they live, please add the links!

The ones that appear in JFP are on line... in some
sense... it's just they want money for looking at them.  I
don't suppose we could somehow persuade CUP to make them
freely accessible after a year or two?

-- 
Jón Fairbairn [EMAIL PROTECTED]

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


Re: [Haskell-cafe] The Functional Pearls

2007-05-05 Thread Andrew Coppin




Donald Bruce Stewart wrote:

  So, what better way to steep yourself in the design cult(ure) of the
lambda, than to go through the pearls. :-)
  


Is there a black perl available?

Oh... damn... Sorry about that. God I can't wait for that film to be
released! _



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


Re: [Haskell-cafe] Re: The Functional Pearls

2007-05-05 Thread Donald Bruce Stewart
jon.fairbairn:
 [EMAIL PROTECTED] (Donald Bruce Stewart) writes:
 
  I've created a wiki page collecting the 'functional pearl' papers that
  have appeared in JFP and ICFP and other places over the last 20 odd
  years.
  
  http://haskell.org/haskellwiki/Research_papers/Functional_pearls
  
  Lots of lovely functional programs there.
  
  There's also a list on that page of pearls that don't appear to be
  online. If you know where they live, please add the links!
 
 The ones that appear in JFP are on line... in some
 sense... it's just they want money for looking at them.  I
 don't suppose we could somehow persuade CUP to make them
 freely accessible after a year or two?

I found that the vast majority are in fact online via the author's
websites. And in fact, JFP seems to have free access (temporary?) for
the Jan 07 JFP (only). 

Yes, it really does seem a shame not to have access to the back issues,
nor to work of authors who don't put their journal articles online.
I want to read Bird's sudoku solver!

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


Re: [Haskell-cafe] An interesting toy

2007-05-05 Thread Ryan Dickie

Sounds like a neat program. I'm on a laptop right now but i'll check it out
later.
The reason I am mailling is because you can use mencoder to convert a stream
of image files into a video file.

http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-enc-images.html

--ryan

On 5/5/07, Andrew Coppin [EMAIL PROTECTED] wrote:


 Greetings.

I have something which you might find mildly interesting. (Please don't
attempt the following unless you have some serious CPU power available, and
several hundred MB of hard drive space free.)

  darcs get http://www.orphi.me.uk/darcs/Chaos
  cd Chaos
  ghc -O2 --make System1
  ./System1

On my super-hyper-monster machine, the program takes an entire 15 minutes
to run to completion. When it's done, you should have 500 images sitting in
front of you. (They're in PPM format - hence the several hundred MB of disk
space!) The images are the frames that make up an animation; if you can find
a way to play this animation, you'll be treated to a truely psychedelic
light show! (If not then you'll just have to admire them one at a time. The
first few dozen frames are quite boring by the way...)

If you want to, you can change the image size. For example, ./System1
800 will render at 800x800 pixels instead of the default 200x200. (Be
prepaired for *big* slowdowns!)

*What is it?*

Well, it's a physical simulation of a chaos pendulum. That is, a
magnetic pendulum suspended over a set of magnets. The pendulum would just
swing back and forth, but the magnets perturb its path in complex and
unpredictable ways.

However, rather than simulate just 1 pendulum, the program simulates
40,000 of them, all at once! For each pixel, a pendulum is initialised with
a velocity of zero and an initial position corresponding to the pixel
coordinates. As the pendulums swing, each pixel is coloured according to the
proximity of the corresponding pendulum to the tree magnets.

*Help requested...*

Can anybody tell me how to make the program go faster?

I already replaced all the lists with IOUArrays, which resulted in big,
big speedups (and a large decrease in memory usage). But I don't know how to
make it go any faster. I find it worrying that the process of converting
pendulum positions to colours appears to take significantly longer than the
much more complex task of performing the numerical integration to discover
the new pendulum positions. Indeed, using GHC's profiling tools indicates
that the most time is spent executing the function quant8. This function
is defined as:

  quant8 :: Double - Word8
  quant8 = floor . (0xFF *)

I can't begin to *imagine* how *this* can be the most compute-intensive
part of the program when I've got all sorts of heavy metal maths going on
with the numerical integration and so forth...! Anyway, if anybody can tell
me how to make it run faster, I'd be most appriciative!

Also, is there an easy way to make the program use *both* of the CPUs in
my PC? (Given that the program maps two functions over two big IOUArrays...)

Finally, if anybody has any random comments about the [lack of] qualify in
my source code, feel free...


___
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] An interesting toy

2007-05-05 Thread Andrew Coppin

Ryan Dickie wrote:
Sounds like a neat program. I'm on a laptop right now but i'll check 
it out later.
The reason I am mailling is because you can use mencoder to convert a 
stream of image files into a video file.
Indeed, it is pretty neat. I'd post an image, but I'm not sure whether 
the other people on this list would appriciate a binary attachment. I'm 
hoping to make a DVD of various simulations - but that's kind of 
difficult when rendering full-size animations takes many hours! _ 
Hence the request for optimisation help... ;-)


Mencoder works on Linux, IrfanView + VirtualDub does it nicely on 
Windoze, I'm sure MacOS has something that can stitch PPM images 
together too. Use whatever you have on your platform. :-D


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


Re: [Haskell-cafe] An interesting toy

2007-05-05 Thread Stefan O'Rear
On Sat, May 05, 2007 at 09:17:50PM +0100, Andrew Coppin wrote:
 Ryan Dickie wrote:
 Sounds like a neat program. I'm on a laptop right now but i'll check 
 it out later.
 The reason I am mailling is because you can use mencoder to convert a 
 stream of image files into a video file.
 Indeed, it is pretty neat. I'd post an image, but I'm not sure whether 
 the other people on this list would appriciate a binary attachment. I'm 

AFAIK, nobody cares about binaryness per se.  It's merely the fact
that images tend to be rather large...  Is it =50kb? (typical maximum
size of a 1-line patch that has been bloated by darcs' ultra low
density context format)

 hoping to make a DVD of various simulations - but that's kind of 
 difficult when rendering full-size animations takes many hours! _ 
 Hence the request for optimisation help... ;-)
 
 Mencoder works on Linux, IrfanView + VirtualDub does it nicely on 
 Windoze, I'm sure MacOS has something that can stitch PPM images 
 together too. Use whatever you have on your platform. :-D

I've had success with ffmpeg years ago (linux)

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


Re: [Haskell-cafe] An interesting toy

2007-05-05 Thread Derek Elkins

Andrew Coppin wrote:

Greetings.

I have something which you might find mildly interesting. (Please don't 
attempt the following unless you have some serious CPU power available, 
and several hundred MB of hard drive space free.)


  darcs get http://www.orphi.me.uk/darcs/Chaos
  cd Chaos
  ghc -O2 --make System1
  ./System1

On my super-hyper-monster machine, the program takes an entire 15 
minutes to run to completion. When it's done, you should have 500 images 
sitting in front of you. (They're in PPM format - hence the several 
hundred MB of disk space!) The images are the frames that make up an 
animation; if you can find a way to play this animation, you'll be 
treated to a truely psychedelic light show! (If not then you'll just 
have to admire them one at a time. The first few dozen frames are quite 
boring by the way...)


If you want to, you can change the image size. For example, ./System1 
800 will render at 800x800 pixels instead of the default 200x200. (Be 
prepaired for /big/ slowdowns!)


*What is it?*

Well, it's a physical simulation of a chaos pendulum. That is, a 
magnetic pendulum suspended over a set of magnets. The pendulum would 
just swing back and forth, but the magnets perturb its path in complex 
and unpredictable ways.


However, rather than simulate just 1 pendulum, the program simulates 
40,000 of them, all at once! For each pixel, a pendulum is initialised 
with a velocity of zero and an initial position corresponding to the 
pixel coordinates. As the pendulums swing, each pixel is coloured 
according to the proximity of the corresponding pendulum to the tree 
magnets.


*Help requested...*

Can anybody tell me how to make the program go faster?

I already replaced all the lists with IOUArrays, which resulted in big, 
big speedups (and a large decrease in memory usage). But I don't know 
how to make it go any faster. I find it worrying that the process of 
converting pendulum positions to colours appears to take significantly 
longer than the much more complex task of performing the numerical 
integration to discover the new pendulum positions. Indeed, using GHC's 
profiling tools indicates that the most time is spent executing the 
function quant8. This function is defined as:


  quant8 :: Double - Word8
  quant8 = floor . (0xFF *)

I can't begin to /imagine/ how /this/ can be the most compute-intensive 
part of the program when I've got all sorts of heavy metal maths going 
on with the numerical integration and so forth...! Anyway, if anybody 
can tell me how to make it run faster, I'd be most appriciative!


Also, is there an easy way to make the program use /both/ of the CPUs in 
my PC? (Given that the program maps two functions over two big IOUArrays...)


Finally, if anybody has any random comments about the [lack of] qualify 
in my source code, feel free...


Try adding strictness annotations to all the components of all your data 
structures (i.e. put a ! before the type).  Not all of the need it, but I doubt 
any need to be lazy either.  Probably the reason quant8 seems to be taking so 
much time is that it is where a lot of stuff finally gets forced.  Certainly, 
for things that are primitive like Colour and Vector you want the components 
to be strict, in general.


I did this for the program and ran System1 100 and it took maybe a couple of 
minutes, it seemed to be going at a decent clip.  200x200 should take 4 times 
longer, I assume, and I still don't see that taking 15 minutes. This is on a 
laptop running on a Mobile AMD Sempron 3500+.  Also, you have many many 
superfluous parentheses and use a different naming convention from 
representative Haskell code (namely camelCase).

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


Re: [Haskell-cafe] Is Excel a FP language?

2007-05-05 Thread Bjorn Lisper
  I just had a thought... Why doesn't somebody implement a spreadsheet 
 where
 Haskell is the formula language? 8-)

 http://sigfpe.blogspot.com/2006/11/from-l-theorem-to-spreadsheet.html
 may interest.

...ok, and now my head hurts...

(Haskell seems to do that lots. I'm not sure why.)

Well, check out http://www.mrtc.mdh.se/index.php?choice=projectsid=0041

This might ease the headache a little. It is basically the result of a MSc
thesis project that a student did for me a couple of years ago.

Björn Lisper

PS. Also check out http://www.cs.kent.ac.uk/projects/vital/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] An interesting toy

2007-05-05 Thread Stefan O'Rear
On Sat, May 05, 2007 at 03:33:03PM -0500, Derek Elkins wrote:
 Try adding strictness annotations to all the components of all your data 
 structures (i.e. put a ! before the type).  Not all of the need it, but I 
 doubt any need to be lazy either.  Probably the reason quant8 seems to be 
 taking so much time is that it is where a lot of stuff finally gets forced. 
 Certainly, for things that are primitive like Colour and Vector you want 
 the components to be strict, in general.

(In theory at least) That would not be an issue at all - the GHC
profiler uses lexical, *not dynamic*, call stacks.

 I did this for the program and ran System1 100 and it took maybe a couple 
 of minutes, it seemed to be going at a decent clip.  200x200 should take 4 
 times longer, I assume, and I still don't see that taking 15 minutes. This 
 is on a laptop running on a Mobile AMD Sempron 3500+.  Also, you have many 
 many superfluous parentheses and use a different naming convention from 
 representative Haskell code (namely camelCase).

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


Re: [Haskell-cafe] An interesting toy

2007-05-05 Thread Andrew Coppin


Try adding strictness annotations to all the components of all your 
data structures (i.e. put a ! before the type).  Not all of the need 
it, but I doubt any need to be lazy either.  Probably the reason 
quant8 seems to be taking so much time is that it is where a lot of 
stuff finally gets forced.  Certainly, for things that are primitive 
like Colour and Vector you want the components to be strict, in general.
Yes, originally the profile was showing quant8 taking something absurd 
like 80% of the CPU time. When I changed the framebuffer to an IOUArray, 
the time spent in quant8 dropped *drastically*. (Because now the 
framebuffer is strict, and that's forcing the evaluation sooner.)


I could certainly try making vectors, colours and arrays strict and see 
if that does something... (Thinking about it, the colour computation has 
a square root in it, and I bet that doesn't get forced until it hits 
quant8... Square root is an expensive operation on currentl hardware 
isn't it?)
 Also, you have many many superfluous parentheses and use a different 
naming convention from representative Haskell code (namely camelCase).
This is a pet hate of mine. NamesLikeThis are fine. names_like_this are 
fine too. But for the love of God, namesLikeThis just looks stupid and 
annoying! So I generally use camel case for stuff which has to start 
uppercase, and underscores for stuff that has to start lowercase. It's a 
system, and it works. Unfortunately it's not the standard convention in 
Haskell. (And I doubt I will convince anybody to change it...)


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


Re: [Haskell-cafe] An interesting toy

2007-05-05 Thread Andrew Coppin


Try adding strictness annotations to all the components of all your 
data structures (i.e. put a ! before the type).  Not all of the need 
it, but I doubt any need to be lazy either.  Probably the reason 
quant8 seems to be taking so much time is that it is where a lot of 
stuff finally gets forced.  Certainly, for things that are primitive 
like Colour and Vector you want the components to be strict, in general.


I just did that. Gives a few percent speed increase. (Turns out on my 
machine System1 with default options actually takes 5 minutes, not 15. 
And with the extra strictness, it completes about 40 seconds faster. So 
not a vast speedup - but worth having!)


Also tried playing with GHC options. I found the following:

-fexcess-precision: No measurable effect.
-funbox-strict-fields: Roughly 40 seconds faster again.
-fno-state-hack: Makes the program somewhat *slower*.
-funfolding-update-in-place: No measurable effect.

Hmm, I suppose if I get *really* desperate, I could always try compiling 
with GHC 6.6.1 instead of 6.6... ;-)


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


[Haskell-cafe] Re: (Chaos) [An interesting toy]

2007-05-05 Thread jerzy . karczmarczuk
Andrew Coppin shares with us his Chaos program. 


I confirm that on my HP laptop it was faster than 15 minutes, but
I won't speculate how to optimize it. I appreciated the elegance of
overloading, the usage of Num classes, etc, which makes it more readable,
although somewhat slower. Actually it took slightly less than 10 minutes
for 300x300. I wonder whether making some constants global (such as dt)
would change anything.
For those who don't have patience to execute the program, I converted the
ppms to a XVID coded AVI file. Thanks, Andrew
http://users.info.unicaen.fr/~karczma/Work/Chaos0.avi 


What I didn't appreciate was the use of simple extrapolating Euler's
method which for oscillating systems is known to be unstable, so the results
of the simulation may be far from the reality. Well, one chaos is worth
another one, and the sin is not as mortal as in the case of truly periodic
systems, but it may be the cause that it is difficult to see the classical
fractal structure of the attraction domains on the generated images. Try
to use leapfrog Verlet...  It will require to keep not only p and v for
each frame, but also the acceleration, but the corrections are minor. Of
course it will be slower, but then, why not increase dt? 

Jerzy Karczmarczuk 



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


[Haskell-cafe] Any Haskellers in St Louis, MO?

2007-05-05 Thread Aditya Siram

Hi there..
Are there any Haskellers in St Louis , MO? Is there an active group here? 
Want to start one?


Thanks...
Deech

_
Exercise your brain! Try Flexicon. 
http://games.msn.com/en/flexicon/default.htm?icid=flexicon_hmemailtaglineapril07


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


[Haskell-cafe] Any Haskellers anywhere? (was Re: Any Haskellers in St Louis, MO?)

2007-05-05 Thread Mark T.B. Carroll
Maybe we could use a page on the wiki to note who'd be interested in
meeting up and where they all live?

-- Mark

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


Re: [Haskell-cafe] Any Haskellers anywhere? (was Re: Any Haskellers in St Louis, MO?)

2007-05-05 Thread Rob Hoelz
Sounds like a good idea to me.  I'd like to see if any Haskellers are
in Madison.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Any Haskellers anywhere?

2007-05-05 Thread Gabor Greif

Am 06.05.2007 um 03:52 schrieb Rob Hoelz:


Sounds like a good idea to me.  I'd like to see if any Haskellers are
in Madison.


Doesn't Google have a service for visualizing locations on a map?
The wiki could point there, for example...

Gabor


___
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] Any Haskellers anywhere?

2007-05-05 Thread Rob Hoelz
Gabor Greif [EMAIL PROTECTED] wrote:

 Am 06.05.2007 um 03:52 schrieb Rob Hoelz:
 
  Sounds like a good idea to me.  I'd like to see if any Haskellers
  are in Madison.
 
 Doesn't Google have a service for visualizing locations on a map?
 The wiki could point there, for example...
 
   Gabor

I bet Google does have one, but first thing that came to my mind is
Frappr: http://www.frappr.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Any Haskellers anywhere?

2007-05-05 Thread Donald Bruce Stewart
hoelz:
 Gabor Greif [EMAIL PROTECTED] wrote:
 
  Am 06.05.2007 um 03:52 schrieb Rob Hoelz:
  
   Sounds like a good idea to me.  I'd like to see if any Haskellers
   are in Madison.
  
  Doesn't Google have a service for visualizing locations on a map?
  The wiki could point there, for example...
  
  Gabor
 
 I bet Google does have one, but first thing that came to my mind is
 Frappr: http://www.frappr.com/

We have an old map of irc user locations, here, you could start with
that:

http://haskell.org/hawiki/HaskellUserLocations

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


Re: [Haskell-cafe] Any Haskellers anywhere? (was Re: Any Haskellers in St Louis, MO?)

2007-05-05 Thread Ricardo Herrmann

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

On 5/5/07, Mark T.B. Carroll [EMAIL PROTECTED] wrote:


Maybe we could use a page on the wiki to note who'd be interested in
meeting up and where they all live?

-- Mark

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





--
Ricardo Guimarães Herrmann
You never change things by fighting the existing reality. To change
something, build a new model that makes the existing model obsolete - R.
Buckminster Fuller
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Any Haskellers anywhere?

2007-05-05 Thread Ricardo Herrmann

Try this ... Google Maps - My Maps - Haskellers

http://maps.google.com/maps/ms?f=qhl=ent=kie=UTF8om=1msa=0ll=-23.553838,-46.656811spn=0.004386,0.006738z=18

On 5/5/07, Rob Hoelz [EMAIL PROTECTED] wrote:


Gabor Greif [EMAIL PROTECTED] wrote:

 Am 06.05.2007 um 03:52 schrieb Rob Hoelz:

  Sounds like a good idea to me.  I'd like to see if any Haskellers
  are in Madison.

 Doesn't Google have a service for visualizing locations on a map?
 The wiki could point there, for example...

   Gabor

I bet Google does have one, but first thing that came to my mind is
Frappr: http://www.frappr.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe





--
Ricardo Guimarães Herrmann
You never change things by fighting the existing reality. To change
something, build a new model that makes the existing model obsolete - R.
Buckminster Fuller
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe