[Haskell-cafe] Re: What I learned from my first serious attempt low-level Haskell programming

2007-04-11 Thread Lennart Augustsson

OK, so there are few extra costs for unknown tail calls.
First, there might be a pipeline stall if the jump address isn't  
loaded into a register far enough in advance before the jump.
Second, you need to pass information about the number of arguments in  
the caller.

And finally, you need to test the number of arguments in the callee.

Under the best of circumstances the argument check costs a load  
immediate, a compare, and a non-taken branch.  But looking at the  
output from ghc I doubt this is the case.


-- Lennart

On Apr 10, 2007, at 23:13 , Stefan O'Rear wrote:


On Tue, Apr 10, 2007 at 07:59:04PM +0100, Lennart Augustsson wrote:

So then tail calls should be very cheap when most of the arguments
don't change.

On Apr 10, 2007, at 10:17 , Simon Marlow wrote:


Lennart Augustsson wrote:

It's not that hard to figure out an order to permute the arguments
on the stack before a tail call that minimizes that number of
moves and temporary locations.  Lmlc did this 20 years ago. :)


Right, and that's what GHC does too, with a strongly-connected-
component analysis of the dependencies between assignments of the
args for the tail call.

Cheers,
Simon


The tailcall in question is NOT statically known (it is a variant of
CPS), so simpleminded tail recursion optimizations will not help much.

Stefan


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


Re: [Haskell-cafe] Compiling GHC

2007-04-11 Thread Andrew Appleyard

On 30/03/2007, at 4:36 pm, Chris Witte wrote:

cp -rp ./../include/* /usr/local/include/mingw
cp: cannot stat `./../include/*': No such file or directory


The source paths for these copies are derived from the path of the  
gcc binary ($GccDir).  Did you call configure with '--with-gcc=C:/ 
Mingw/bin/gcc.exe'?  I received those errors when I forgot to do that.


Loading package base ... linking ... ghc.exe: unable to load  
package `base'

ghc.exe:
C:/msys/1.0/local/HSbase.o: unknown symbol `_gettimeofday'


I think that 'gettimeofday' is statically linked into the ghc  
executable, so it's just that GHCi doesn't know about it.  Adding a:


  Sym(gettimeofday) \

line to the RTS_MINGW_ONLY_SYMBOLS #define in rts/Linker.c (from line  
265) seemed to fix the problem for me.


I'm not sure if this is a GHCi bug or something else being awry.   
'gettimeofday' was added to the mingwex library in mingw- 
runtime-3.10, which was released in July last year, so I would have  
expected this problem to have come up before now...


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


[Haskell-cafe] Re: What I learned from my first serious attempt low-level Haskell programming

2007-04-11 Thread Simon Marlow

Lennart Augustsson wrote:
So then tail calls should be very cheap when most of the arguments don't 
change.


Yes, but the problem tends to be the arguments that change, and the fact that 
they are passed on the stack.  A C loop would keep the loop-carried variables in 
registers.  On x86_64 you get better code becuase some of the args are passed in 
registers, but it's not really proper loop optimisation.


We know what needs to be done, and we plan to make progress on this soon, 
hopefully over the summer.


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


[Haskell-cafe] Re: Weaving fun

2007-04-11 Thread Bas van Dijk

Thanks for all the wonderful solutions. I put them into one module so
other people can try it out: http://hpaste.org/1338

Thanks,

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


[Haskell-cafe] Re: hackage.haskell.org

2007-04-11 Thread Simon Marlow

David Waern wrote:


I'd like to set up a Trac for Haddock on hackage.haskell.org. Who should I
contact?


Let's hold off on this for now.  I don't think Haddock warrants a full Trac of 
its own just yet, the overheads of managing a Trac are pretty high compared to 
editing the text file called TODO in the root of the Haddock source tree :-)


Cheers,
Simon

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


Re: [Haskell-cafe] Compiling GHC

2007-04-11 Thread Chris Witte

On 4/11/07, Andrew Appleyard [EMAIL PROTECTED] wrote:


The source paths for these copies are derived from the path of the
gcc binary ($GccDir).  Did you call configure with '--with-gcc=C:/
Mingw/bin/gcc.exe'?  I received those errors when I forgot to do that.



Yep that fixed that. Thanks.



I think that 'gettimeofday' is statically linked into the ghc
executable, so it's just that GHCi doesn't know about it.  Adding a:

   Sym(gettimeofday) \

line to the RTS_MINGW_ONLY_SYMBOLS #define in rts/Linker.c (from line
265) seemed to fix the problem for me.

I'm not sure if this is a GHCi bug or something else being awry.
'gettimeofday' was added to the mingwex library in mingw-
runtime-3.10, which was released in July last year, so I would have
expected this problem to have come up before now...


I made this change but I still get the error
unknown symbol `_gettimeofday'
I'm using mingw 5.1.3 which as far as i can tell should use the 3.11 runtime.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Weaving fun

2007-04-11 Thread Chris Kuklewicz
I have a simply recursive solution that operates efficiently...

Bas van Dijk wrote:
 Hello,
 
 For my own exercise I'm writing a function 'weave' that weaves a
 list of lists together. For example:
 
  weave [[1,1,1], [2,2,2], [3,3]] == [1,2,3,1,2,3,1,2]
  weave [[1,1,1], [2,2], [3,3,3]] == [1,2,3,1,2,3,1]
 
 Note that 'weave' stops when a list is empty.

This version of weave works without Data.Sequence or using reverse, (++), or 
concat:

 weave :: [[a]] - [a]
 weave [] = []
 weave xss = weave' id xss
   where weave' _rest ([]:_) = [] -- end when any list is empty
 weave' rest [] = weave (rest []) -- goto next, check for (weave [])
 weave' rest ((x:xs):xss) = x : weave' (rest . (xs:)) xss

The first parameter of weave' is the usual difference list trick to allow
efficient append with simple lists.

It works lazily and handles infinite lists.  Though if you weave an infinite
number of lists together you will get unbounded memory usage.

Here it terminates when there is no element after the 15 in the second list:

*Main weave [[1..],[11..15],[300..]]
[1,11,300,2,12,301,3,13,302,4,14,303,5,15,304,6]

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


Re: [Haskell-cafe] A convenient way to deal with conditional function composition?

2007-04-11 Thread Maxime Henrion
Chris Kuklewicz wrote:
 Nicolas Frisby wrote:
  Not portably.
 
  [EMAIL PROTECTED]:~$ ghc-6.4.2 -e '(  (foo++) `Data.Monoid.mappend`
  (bar++) ) END'
  foobarEND
  [EMAIL PROTECTED]:~$ ghc-6.6 -e '(  (foo++) `Data.Monoid.mappend`
  (bar++) ) END'
  fooENDbarEND
 
 
  -- 6.6 sources
  instance Monoid b = Monoid (a - b) where
  mempty _ = mempty
  mappend f g x = f x `mappend` g x
 
 
  Stefan
 
 Thanks for the reminder.  So the fixed 6.6 code is
 
  import Control.Monad(when)
  import Control.Monad.Writer(Writer,tell,execWriter)
  import Data.Monoid(Endo(..))
  
  type Writes = Writer (Endo String) ()
  
  data PieceType = Pawn | Other deriving (Eq,Show)
  type File = Int
  type Square = Int
  
  data Move = Move {
   movePiece :: PieceType,
   moveFile  :: Maybe File,
   moveTarget:: Square,
   moveIsCapture :: Bool
   --movePromotion :: Maybe PieceType
 }
deriving (Eq)
  
  instance Show Move where showsPrec = showsPrec_Move
  
  tShow :: Show a = a - Writes
  tShow = tell . Endo . shows
  
  tChar :: Char - Writes
  tChar = tell . Endo . (:)
  
  tString :: String - Writes
  tString = tell . Endo . (++)
  
  showsPrec_Move :: Int - Move - ShowS
  showsPrec_Move _ Move { movePiece = p
, moveFile  = f
, moveTarget= s
, moveIsCapture = c } = appEndo . execWriter $ do
when (p/=Pawn) (tShow p)
maybe (return ()) tShow f
when c (tChar 'x')
tShow s
  
  testMove = Move Other (Just 6) 10 True

Thanks a lot for all the nice answers, guys.

I have a few remaining questions if you don't mind though.  Should
I expect significant performance reduction by using the Writer monad
here, as opposed to the version I wrote?  And, most importantly,
I'd like to know how *you* would write this if you had to :-).
Would you juse the Writer monad version?

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


[Haskell-cafe] GHC 6.6 hangs

2007-04-11 Thread Gleb Alexeyev

Dmitry Antonyuk (lomeo) came up with a piece of code that hung GHC 6.6:

newtype Foo a = Foo (Foo a - a)
bar x@(Foo f) = f x
baz = bar (Foo bar)

See the original discussion (in Russian) at:
http://lomeo.livejournal.com/35674.html

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


Re: [Haskell-cafe] GHC 6.6 hangs

2007-04-11 Thread Neil Mitchell

Hi


Dmitry Antonyuk (lomeo) came up with a piece of code that hung GHC 6.6:


It's a documented bug in GHC:

http://www.haskell.org/ghc/docs/latest/html/users_guide/bugs.html#bugs-ghc

GHC's inliner can be persuaded into non-termination using the
standard way to encode recursion via a data type

Thanks

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


[Haskell-cafe] Re: hackage.haskell.org

2007-04-11 Thread David Waern
 David Waern wrote:

 I'd like to set up a Trac for Haddock on hackage.haskell.org. Who should
 I
 contact?

 Let's hold off on this for now.  I don't think Haddock warrants a full
 Trac of
 its own just yet, the overheads of managing a Trac are pretty high
 compared to
 editing the text file called TODO in the root of the Haddock source tree
 :-)

What do you think of the Google bug tracker? Neil and I created a project
for Haddock at http://code.google.com/p/haddock/

I'd like to pre-release haddock.ghc and it would be nice to have some
place for users to report bugs.

/David

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


Re: [Haskell-cafe] Re: hackage.haskell.org

2007-04-11 Thread Neil Mitchell

 Let's hold off on this for now.  I don't think Haddock warrants a full
 Trac of
 its own just yet, the overheads of managing a Trac are pretty high
 compared to
 editing the text file called TODO in the root of the Haddock source tree
 :-)

What do you think of the Google bug tracker? Neil and I created a project
for Haddock at http://code.google.com/p/haddock/


For reference, it took well under a minute for me to create a new
Google Code project, and is unlikely to need maintenance ever.

Google rules!

Thanks

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


[Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread kynn

Perl is a large, ugly, messy language filled with quirks and eccentricities,
while Haskell is an extremely elegant language whose design is guided by a
few overriding ideas.  (Or so I'm told.)

Based on this one would think that it would be much easier to learn Haskell
than to learn Perl, but my experience is exactly the opposite.

I've been wanting to learn Haskell for years, literally, but it has been a
case of Sisyphus and the Rock.  Despite my efforts, I never get to the level
of expertise that would make Haskell useful to me.  (I don't need elegant
factorial or Fibonacci functions in my everyday work.)  Sooner or later life
intervenes: big project due, long trip abroad, etc., and when I finally
return to learning Haskell, I have forgotten almost everything I learned and
I have to start all over again.  (BTW, I've heard similar stories from many
wannabe Haskell programmers.)

Arguably, this experience means that I have no business learning Haskell,
because it's just not relevant to my work.  Maybe so, but I still cling to
the fanciful notion that if I knew Haskell well enough, I would find plenty
of stuff to do with it in my daily work...

Anyway, in contrast to my struggle with Haskell, I learned Perl
incrementally over the years, by using it in daily little projects, ranging
at first from command-line snippets to 100-line self-contained scripts, and
moving on to larger, hairier projects.  This daily reinforcement of the
little bits of Perl I was picking up was crucial to my being able to retain
it and move forward.

Perhaps Haskell will never lend itself to something like a Perl one-liner,
but still I wish that there were books on Haskell that focused on making
Haskell useful to the learner as quickly as possible...  If such already
exist and I've missed it, please let me know.

Or I can always wait until I retire; then I'll probably have a sufficiently
long stretch of free time in my hands (barring any operations, strokes,
heart attacks, hip fractures, etc.).  I bet I could start a Haskell Wannabes
Club at the nursing home...

kj

-- 
View this message in context: 
http://www.nabble.com/Why-Perl-is-more-learnable-than-Haskell-tf3559193.html#a9938938
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread Donald Bruce Stewart
kynnjo:
 Perhaps Haskell will never lend itself to something like a Perl one-liner,
 but still I wish that there were books on Haskell that focused on making
 Haskell useful to the learner as quickly as possible...  If such already
 exist and I've missed it, please let me know.

There's some things in the works, but for now you can perhaps find
something relevant to what you're trying to do here,

http://haskell.org/haskellwiki/Blog_articles

There's a good breadth of topics covered.

Also, I recommend hanging out on #haskell, you'll just see so many
interesting haskell snippets, have people to help answer questions, and
of course, the lambdabot, that you can't help but learn haskell by
osmosis!

http://haskell.org/haskellwiki/IRC_channel

Good luck. Hope to see you online.

-- Don

P.S. Have a fix point!  Control.Monad.Fix.fix ((1:) . scanl (+) 1)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread riccardo cagnasso

My opinion is that learnin haskell is difficult is just for the fact that
when you learn programming, you probably begin with C / C++ or some other
procedural/OO programming language, so you get used to think in these ways,
and when you have to switch to functional paradigm, you find it difficoult.

If you first language is LISP probably you find easy Haskell and difficult
pearl.

2007/4/11, kynn [EMAIL PROTECTED]:



Perl is a large, ugly, messy language filled with quirks and
eccentricities,
while Haskell is an extremely elegant language whose design is guided by a
few overriding ideas.  (Or so I'm told.)

Based on this one would think that it would be much easier to learn
Haskell
than to learn Perl, but my experience is exactly the opposite.

I've been wanting to learn Haskell for years, literally, but it has been a
case of Sisyphus and the Rock.  Despite my efforts, I never get to the
level
of expertise that would make Haskell useful to me.  (I don't need elegant
factorial or Fibonacci functions in my everyday work.)  Sooner or later
life
intervenes: big project due, long trip abroad, etc., and when I finally
return to learning Haskell, I have forgotten almost everything I learned
and
I have to start all over again.  (BTW, I've heard similar stories from
many
wannabe Haskell programmers.)

Arguably, this experience means that I have no business learning Haskell,
because it's just not relevant to my work.  Maybe so, but I still cling to
the fanciful notion that if I knew Haskell well enough, I would find
plenty
of stuff to do with it in my daily work...

Anyway, in contrast to my struggle with Haskell, I learned Perl
incrementally over the years, by using it in daily little projects,
ranging
at first from command-line snippets to 100-line self-contained scripts,
and
moving on to larger, hairier projects.  This daily reinforcement of the
little bits of Perl I was picking up was crucial to my being able to
retain
it and move forward.

Perhaps Haskell will never lend itself to something like a Perl one-liner,
but still I wish that there were books on Haskell that focused on making
Haskell useful to the learner as quickly as possible...  If such already
exist and I've missed it, please let me know.

Or I can always wait until I retire; then I'll probably have a
sufficiently
long stretch of free time in my hands (barring any operations, strokes,
heart attacks, hip fractures, etc.).  I bet I could start a Haskell
Wannabes
Club at the nursing home...

kj

--
View this message in context:
http://www.nabble.com/Why-Perl-is-more-learnable-than-Haskell-tf3559193.html#a9938938
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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





--
I invented the term Object-Oriented, and I can tell you I did not have C++
in mind. (Alan Kay)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: GHC 6.6 hangs

2007-04-11 Thread Gleb Alexeyev

Neil Mitchell wrote:


It's a documented bug in GHC:

http://www.haskell.org/ghc/docs/latest/html/users_guide/bugs.html#bugs-ghc

GHC's inliner can be persuaded into non-termination using the
standard way to encode recursion via a data type



Thanks Neil!
Sorry for the noise, I should have checked GHC docs before posting.

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


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread Mark T.B. Carroll
Sorry to hear of your struggles. There has been a lot of work lately on
writing Haskell tutorials but there's still a long way to go,
unfortunately, as I discovered when I tried recently to find the
collection of sample code fragments on the wiki that I'm sure are around
somewhere.

I had the advantage of coming to Haskell after already having used ML
and Common Lisp. But, FWIW, I found it worth persevering: I liked a lot
of my legacy Perl scripts more after I ported them to Haskell and now I
use Haskell for the sort of thing I might have used bash or perl for
previously. (For instance, on the way home last night my GPS' NMEA-0183
data was odd enough that I used Haskell to write a simple daemon that
sits between clients and my gpsd and rewrites their conversation;
previously, I'd have used Perl for that.)

Though, it helps if you get on well with Perl. It didn't suit me very
well so I had more motivation to switch than you might. But, now, by
choice, I do use Haskell for the kind of thing I'd have previously used
a short script for instead, so there might still be light at the end of
the tunnel for you.

-- Mark

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


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread Thomas Hartman

I am also coming at haskell from a perl background.

While there is some truth to what you say, I do think haskell can be
used for keeping simple things simple in a way similar to perl.
Though you have to search harder since the documentation / tutorials
seem to be more optimized for making hard things possible. (And in
fact, much easier than in perl.)

But back to the easy, here is a thread concerning one liners in haskell

http://groups.google.de/group/fa.haskell/browse_thread/thread/e948ff0ad4d7c0c9/ac0a46d1f841db59?lnk=stq=haskell+one+linersrnum=1hl=en#ac0a46d1f841db59

I think if you really have desire the best route is to complement
googling around with asking on #haskell and the newsgroups. It's a
*very* friendly community.

hope this helps!

2007/4/11, kynn [EMAIL PROTECTED]:


Perl is a large, ugly, messy language filled with quirks and eccentricities,
while Haskell is an extremely elegant language whose design is guided by a
few overriding ideas.  (Or so I'm told.)

Based on this one would think that it would be much easier to learn Haskell
than to learn Perl, but my experience is exactly the opposite.

I've been wanting to learn Haskell for years, literally, but it has been a
case of Sisyphus and the Rock.  Despite my efforts, I never get to the level
of expertise that would make Haskell useful to me.  (I don't need elegant
factorial or Fibonacci functions in my everyday work.)  Sooner or later life
intervenes: big project due, long trip abroad, etc., and when I finally
return to learning Haskell, I have forgotten almost everything I learned and
I have to start all over again.  (BTW, I've heard similar stories from many
wannabe Haskell programmers.)

Arguably, this experience means that I have no business learning Haskell,
because it's just not relevant to my work.  Maybe so, but I still cling to
the fanciful notion that if I knew Haskell well enough, I would find plenty
of stuff to do with it in my daily work...

Anyway, in contrast to my struggle with Haskell, I learned Perl
incrementally over the years, by using it in daily little projects, ranging
at first from command-line snippets to 100-line self-contained scripts, and
moving on to larger, hairier projects.  This daily reinforcement of the
little bits of Perl I was picking up was crucial to my being able to retain
it and move forward.

Perhaps Haskell will never lend itself to something like a Perl one-liner,
but still I wish that there were books on Haskell that focused on making
Haskell useful to the learner as quickly as possible...  If such already
exist and I've missed it, please let me know.

Or I can always wait until I retire; then I'll probably have a sufficiently
long stretch of free time in my hands (barring any operations, strokes,
heart attacks, hip fractures, etc.).  I bet I could start a Haskell Wannabes
Club at the nursing home...

kj

--
View this message in context: 
http://www.nabble.com/Why-Perl-is-more-learnable-than-Haskell-tf3559193.html#a9938938
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.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] Why Perl is more learnable than Haskell

2007-04-11 Thread Dave Feustel


-Original Message-
From: Mark T.B. Carroll [EMAIL PROTECTED]
Sent: Apr 11, 2007 10:18 AM
To: kynn [EMAIL PROTECTED]
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] Why Perl is more learnable than Haskell

Sorry to hear of your struggles. There has been a lot of work lately on
writing Haskell tutorials but there's still a long way to go,
unfortunately, as I discovered when I tried recently to find the
collection of sample code fragments on the wiki that I'm sure are around
somewhere.

A serious omission in Haskell tutorials is a collection of examples of how to 
write Haskell solutions for problems that would use arrays in any imperative 
language.
I see that arrays can be defined in Haskell, but I don't see their use as
computationally efficient in Haskell.



http://RepublicBroadcasting.org - Because You CAN Handle The Truth!
http://iceagenow.com - Because Global Warming Is A Scam!


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


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread brad clawsie
On Wed, Apr 11, 2007 at 05:55:08AM -0700, kynn wrote:
 
 Perl is a large, ugly, messy language filled with quirks and eccentricities,
 while Haskell is an extremely elegant language whose design is guided by a
 few overriding ideas.  (Or so I'm told.)

i find that don's haskell hacking blog has been written with the daily
hacker in mind:

http://cgi.cse.unsw.edu.au/~dons/blog

my own experience is that i would gladly replace perl for many tasks
if haskell's libraries were *easier to use*. for common and simple tasks
like reading data from a network resource (http, ftp), querying a
database, accessing xml (dom, etc), its more important to me to have
an api that is simple to use than one that takes an interesting
approach. perl's apis for these tasks tend to be very simple.

hackage seems to be on track to deliver the advantages of the cpan
tool and repository, so in that sense i think one of the key
advantages of perl has been adopted by the haskell community.

both languages have great communities!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread riccardo cagnasso

The post on dons' blog about the cpu scaler is a great example on how
haskell can easily used in the day-to-day hacking!


2007/4/11, brad clawsie [EMAIL PROTECTED]:


i find that don's haskell hacking blog has been written with the daily
hacker in mind:

http://cgi.cse.unsw.edu.au/~dons/bloghttp://cgi.cse.unsw.edu.au/%7Edons/blog
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe





--
I invented the term Object-Oriented, and I can tell you I did not have C++
in mind. (Alan Kay)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread Alex Queiroz

Hallo,

On 4/11/07, riccardo cagnasso [EMAIL PROTECTED] wrote:

The post on dons' blog about the cpu scaler is a great example on how
haskell can easily used in the day-to-day hacking!



Just read it, it's a very nice post. I'm not afraid of math, but
it's a relief to see some code I can relate with. :-)

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


[Haskell-cafe] Left-factoring with Parsec

2007-04-11 Thread Joel Reymont

Suppose I have expr = expr : expr : expr.

Can the above be left-factored to fail on empty input so that my  
parser doesn't go into a loop?


Thanks, Joel

--
http://wagerlabs.com/





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


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread John Velman
On Wed, Apr 11, 2007 at 05:55:08AM -0700, kynn wrote:
 
 Perl is a large, ugly, messy language filled with quirks and eccentricities,
 while Haskell is an extremely elegant language whose design is guided by a
 few overriding ideas.  (Or so I'm told.)
 
 Based on this one would think that it would be much easier to learn Haskell
 than to learn Perl, but my experience is exactly the opposite.
 Haskell useful to the learner as quickly as possible...  If such already
snip

 exist and I've missed it, please let me know.
 
 Or I can always wait until I retire; then I'll probably have a sufficiently
 long stretch of free time in my hands (barring any operations, strokes,
 heart attacks, hip fractures, etc.).  I bet I could start a Haskell Wannabes
 Club at the nursing home...
 
 kj

My experience is a lot like yours, except I retired 5 years ago, and still
haven't learned Haskell.  Unfortunately, I've had lots of interruptions
that have kept me away from the keyboard.  I've got a few unfinished
projects, including one I started in Perl years ago, moved to Python, then
moved to Haskell.  The only useful thing I've programmed since I retired
was a program to update my checkbook/bank statement postgresql database
using Prolog for parsing entries the way I like to write them in a text
file.  Someday I'll move this to Haskell :-).  I've sworn off other
languages since I don't have any deadlines except my own.

I never really learned Perl, but I used it a lot for simple one to thirty
liners.  The thing was, any thing I wanted to do I could find the bits and
pieces of in Learning Perl, Programming Perl, or Learning Perl/TK.

I have on my shelf Haskell: The craft..., The Haskell school of
expression, and The Haskell road to Logic  I've read them.  I know
I should sit down with each one at the computer and work through the
exercises.  But..,.

When my current spate of unavoidable interruptions is over, I'll look into
the email on Haskell one-liners, and some of the new tutorials to try to
come back up to speed.  Not in a nursing home yet!

Good luck,

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


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread David Tolpin


If you first language is LISP probably you find easy Haskell and difficult
pearl.




Hi,

my first programming language is lisp (that is, the language I am most
fluent in -- recently Common Lisp, earlier Scheme) and I find Haskell a
problematic programming language (this is a fresh experience -- I am writing
a syndrome-networks based DSS in Haskell now) because it is not a language.
Lisp is a language and Haskell is not, in the sense that lisp allows to
write programs that can be read aloud and understood from reading the code.

Haskell is a notation that is not a literature by itself, and for Haskell,
literate programming, that is, writing more comments than code, is a must;
while for lisp it is a rather exotic practice.

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


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread jim burton



kynn wrote:
 
 Perl is a large, ugly, messy language filled with quirks and
 eccentricities, while Haskell is an extremely elegant language whose
 design is guided by a few overriding ideas.  (Or so I'm told.)
 
 [snip]
 
 
May I ask why you want to learn it so much, if you find it so hard? I'm sure
most would disagree with me but maybe you'd be better off with perl for your
one liners and scripts if it serves your purpose well. You say that you've
heard Haskell is extremely elegant, but is that really the reason you want
to start using it as your general purpose and scripting language? I'm also
interested in it myself because of it's elegance, and in order to learn
different paradigms, to explore the strength of the type system etc etc, but
I'm not in a particular rush to be able to use it as the one true language
for scripting or web applications, or xyz, as quite a few people lately seem
to be asking about. Just curious.
-- 
View this message in context: 
http://www.nabble.com/Why-Perl-is-more-learnable-than-Haskell-tf3559193.html#a9946886
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Left-factoring with Parsec

2007-04-11 Thread Lennart Augustsson
I presume your grammar has other clauses for expr, otherwise the loop  
is inevitable.

Assuming you have other clauses you can always left-factor.

Here's how those of us with weak memory can remember how to do it:

Say that you have

  expr ::= expr : expr : expr
 | b
Let's call the part from the first : a, since it doesn't matter  
what it is.  So we have

  expr ::= expr a | b
Let's call expr x, and just change notation slightly
  x = x a + b
Now use high school algebra
  x = x*a + b
  x - x*a = b
  x*(1-a) = b
  x = b / (1-a)
  x = b * 1/(1-a)
Now you have to remember that the Taylor series expansion of 1/(1-a) is
  1/(1-a) = 1 + a + a^2 + a^3 + a^4 + ...

OK, now put your grammar hat back on.  What's
  1 | a | aa | aaa |  | ...
it's just an arbitrary number of a:s, i.e., a* (or 'many a' in parsec).
So finally
  expr = b a*

-- Lennart

On Apr 11, 2007, at 18:15 , Joel Reymont wrote:


Suppose I have expr = expr : expr : expr.

Can the above be left-factored to fail on empty input so that my  
parser doesn't go into a loop?


Thanks, Joel

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


[Haskell-cafe] Skipping keywords with Parsec

2007-04-11 Thread Joel Reymont
Is there a way to have any Parsec combinator skip a certain set of  
keywords?


I tried lexeme = P.lexeme lexer . (skip ) but I don't think lexeme  
is called for every keyword.


Thanks, Joel

--
http://wagerlabs.com/





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


[Haskell-cafe] Re: Skipping keywords with Parsec

2007-04-11 Thread Joel Reymont
Just in case I wasn't clear enough, I'm asking about skipping  
keywords represented by the skip combinator that can be located  
anywhere within the input.


I do know about skipMany and skipMany1, in fact skip is defined in  
terms of these.


On Apr 11, 2007, at 9:04 PM, Joel Reymont wrote:

Is there a way to have any Parsec combinator skip a certain set of  
keywords?


I tried lexeme = P.lexeme lexer . (skip ) but I don't think  
lexeme is called for every keyword.


--
http://wagerlabs.com/





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


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread Brandon Michael Moore
On Wed, Apr 11, 2007 at 02:21:41PM +0100, Will Newton wrote:
 On 4/11/07, kynn [EMAIL PROTECTED] wrote:
 
 Perl is a large, ugly, messy language filled with quirks and 
 eccentricities,
 while Haskell is an extremely elegant language whose design is guided by a
 few overriding ideas.  (Or so I'm told.)
 
 Based on this one would think that it would be much easier to learn Haskell
 than to learn Perl, but my experience is exactly the opposite.
 
 I've been trying to learn Haskell for some time also, and I've learnt
 lots of various other languages in the past. I think one of the
 biggest problems is if there is a considerable learning curve, which
 Haskell undoubtedly has, there's a nagging question in the back of
 your head while you try and get a simple task accomplished in an
 unfamiliar language - why am I bothering with this, I could do it in
 5 minutes in Perl/Python/Ruby/...!.
 
 And for many simple tasks Perl is a really good fit - it's best to
 find a task that plays to Haskell's strengths so you get a bit of
 positive reinforcement while you work. I have been working with Parsec
 to do some parsing recently and I can definitely recommend it. I don't
 think I've used such a capable and easy to use parsing framework in
 any language and it's really kept me going with Haskell where I might
 have just done it in Python in the past.

Writing interpreters is one task where Haskell is really nice.
I suggest Unlambda, it makes a nice toy language. The syntax
is easy to work with, and continuations make the semantics
interesting enough that you can't just rely on the host language
acting the same way, like you generally can with mutable state,
sequential evaluation and so on (unless you're using something
like scheme or ml, but then you probably wouldn't have trouble
with Haskell).

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


[Haskell-cafe] Weaving fun

2007-04-11 Thread Dominic Steinitz
I've been dying to do this all day but work and then family intervened.

Dominic.

import Data.List

weave =
   unfoldr f
  where
 f ([],_,_) = Nothing
 f (x:xs,[],zs) = Just (x,([],[],[]))
 f (x:xs,ys,zs) = Just (x,(ys,zs,xs))

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


Re: [Haskell-cafe] Weaving fun

2007-04-11 Thread Chris Kuklewicz
You are correct, my weave did hide the list in the explicit composition of 
closure(s).
I can be even more declarative and let the closure construction be implicit in 
weave' below...
(and this message should be literate Haskell)

weave' uses a fixed point and pairs to tie the knot declaratively:

 import Data.List

 weave' :: [[a]] - [a]
 weave' [] = []
 weave' xss = let (ans,rest) = helper rest xss in ans
   where helper :: [[a]] - [[a]] - ([a],[[a]])
 helper _rest ([]:_xss) = ([],[])
 helper rest  [] = (weave' rest,[])
 helper rest ((x:xs):xss) = let (ans,rest') = helper rest xss
in (x:ans,xs:rest')

The next case might be an optimization, since we know that nothing
after the [] will be used in the next pass:

 --   helper rest ((x:[]):xss) = let (ans,_) = helper rest xss
 --  in (x:ans,[]:[])

My previous weave, uses composition of (xs:) thunks instead of pairs:

 weave :: [[a]] - [a]
 weave [] = []
 weave xss = helper id xss
   where helper :: ([[a]] - [[a]]) - [[a]] - [a]
 helper _rest ([]:_xss) = [] -- done
 helper rest [] = weave (rest [])
 helper rest ((x:xs):xss) = x : helper (rest . (xs:)) xss

One might imagine an 'optimized' case like in weave':

 --  helper rest ((x:[]):xss) = let yss = rest ([]:[])
 -- in  x : helper (const yss) xss

Some simple tests such that check should be True

 check = (ans == test 20 weave)  (ans == test 20 weave')

 test n w = map (take n . w) $
 [] :
 [[]] :
 [[],[]] :
 [[1..10]] :
 [[1,3..10],[2,4..10]] :
 [[1..],[11..15],[301..],[11..15]] :
 [[1..],[11..15],[301..]] :
 [[1..],[11..15],[301..],[]] :
 [[1..],[11..15],[],[301..]] :
 [[1..],[],[11..15],[],[301..]] :
 [[],[1..],[11..15],[],[301..]] :
 testInf :
 []
 testInf = map enumFrom [1..]
 ans = [[],[],[],[1,2,3,4,5,6,7,8,9,10],[1,2,3,4,5,6,7,8,9,10]
   ,[1,11,301,11,2,12,302,12,3,13,303,13,4,14,304,14,5,15,305,15]
   ,[1,11,301,2,12,302,3,13,303,4,14,304,5,15,305,6]
   ,[1,11,301],[1,11],[1],[]
   ,[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]]

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


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread David Tolpin

Hi,

I'm guessing you're not doing it the right way.


cvs -d :pserver:[EMAIL PROTECTED]:/srv/CVSROOT co SYRENE/src




By using types, you implementation becomes a lot more readable.



Being readable is not enough for being readable aloud.

And I think a lot of people here will disagree with you...



That's good news.  I would not bother to express my option if I thought that
there would not be a lot of people who would disagree.

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


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread Tomasz Zielonka
On Wed, Apr 11, 2007 at 05:55:08AM -0700, kynn wrote:
 Perl is a large, ugly, messy language filled with quirks and eccentricities,
 while Haskell is an extremely elegant language whose design is guided by a
 few overriding ideas.  (Or so I'm told.)
 
 Based on this one would think that it would be much easier to learn Haskell
 than to learn Perl, but my experience is exactly the opposite.

Perhaps it's just that being more elegant doesn't make it easier to
learn. There are almost no overriding ideas in SKI combinator calculus,
but I wouldn't say it's a nice and easy programming language (Well, OK,
I didn't try to master it, so maybe I'm wrong).

The biggest problem with Haskell is that not only you can do things
differently (than in other languages) - you have to! Also, some tasks
are only easy when you know some advanced programming techniques, like
parsing with parser combinators. There is also the problem that
fundamental concepts are quite entangled, and it's difficult to choose
the starting point when learning or teaching.

The language also seems a bit schizophrenic. For example, you can say
that it has side-effects and that it has no side-effects, and both
statements are true in some sense (expression evaluation has no
side-effects but there are features like IO, mutable arrays, etc. - it's
quite difficult to explain to beginners why there is no contradiction,
or where is the trick, in other words).

Actually, I don't know which is the biggest problem... and there are
more of them.

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


[Haskell-cafe] Re: Why Perl is more learnable than Haskell

2007-04-11 Thread Ryan Dickie

I thought I could resist this thread but I'll bite =:-()

The first language i learned was basic. No real functions, simple step by
step instructions. I then learned hypercard, c, c++, python, assembly, vhdl,
and too many others!

Now i've decided to learn haskell. I view it as a mathematicians language. I
do research in the field of medical imaging.. particularly processing large
cardiac data sets to figure out characteristics, diseases, etc. Why workflow
generally starts out as 1) mathematical idea 2) turn that pure equation into
a numerical recipe 3) implement, debug 5) analyze 6) goto step 1. I find
doing my thinking in the continous domain makes things a lot easier.

But here's where i differ from everyone else. I already have the
mathematical relationships all nice and tidy (hopefully!) in my head before
i start. I literally just implement it. I don't want to care about
threading, IO, message passing, or numerical stability. I have to care about
performance but only so far as it hampers my productivity. Preferably the
language will do it implicitly.

Your average programmer wants a language to do tasks. Having to think about
the math and relationships behind it all is rather sickening to them (and me
too!).

I am a new haskell programmer (basically a week into it!). It is by far the
hardest language i've had to pick up. A lot of my code could be structured
in a functional way.. but almost all reply on looping techniques (would take
a lot of work to rethink my gradient descent method and make it fast!).
Regardless of actually using haskell.. i like to transfer these techniques
to c++. Before i even knew of haskell i knew some FP methods and i found
that using these shrunk my code, shrunk the bugs, and did nice things for
performance + concurrency. In fact, I just read a google paper on their
batch system. They use to functions: map and reduce. They can easily split
it up over their cluster etc... these are the ideas of FP that i like! That
and the set-builder notation.

I also hate matlab to death. Is there any possibility of using haskell as a
replacement using ghci? Mostly i care about linalg when it comes to using
matlab.

ps: sorry if gmail butchered this reply. I had subscribed to the digest and
turns out that was a mistake :D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Google SoC - student allocations

2007-04-11 Thread Malcolm Wallace
Although there is still about one hour before Google officially publish
the final tally of accepted Summer of Code projects, I think I now can
safely reveal the 9 projects chosen for haskell.org, since we have no
outstanding conflicts with other mentoring orgs.

We received 64 proposals in total.  Some students made several
proposals.  Of those proposals, we wanted to mentor about 22 individual
students, but Google only gave us funding for 9, so if you weren't
accepted, that doesn't mean your proposal was bad, just that the
competition was stiff.  Also, the mentors group tended to place
language- and community-infrastructure projects at a higher priority
than just plain application-oriented libraries.

(By the way, several students who applied to haskell.org also applied to
other organisations, and may well have been accepted by them instead of
us.)

So here they are!  The list states
* project title,
* the student who will be funded,
* the primary mentor from haskell.org,
* and a set of backup mentors who have expressed interest in looking
  after things too.  (These sets may continue to grow.)

  ---
  Darcs Conlict Handling
 Jason Dagit,
 David Roundy
 { Igloo, Patrik Janssen }
  Hackage Web Interface, Doc-Browser
 Sascha B?hme,
 Ross Paterson
 { Simon Marlow, BryanOS, Bjorn Bringert }
  Rewrite the typechecker for YHC and nhc98
 Mathieu Boespflug,
 Malcolm Wallace
 { Neil Mitchell }
  Cabal Configurations
 Thomas Schilling,
 Michael Isaac Jones
 { Bjorn Bringert, BryanOS, PatrikJ, Simon Marlow, Ross }
  Update the Hat tracer
 Kenn Knowles,
 Malcolm Wallace
 { PatrikJ, BryanOS }
  Generalizing Parsec to ParsecT and arbitrary input (ByteStrings)
 Paolo Martini,
 Philippa Jane Cowderoy
 { Don Stewart, Dmitry Astapov, BryanOS, Bjorn Bringert }
  Shared Libraries for GHC
 Clemens Fruhwirth,
 Simon Marlow
 { BryanOS }
  HTTP Library Replacement
 Mieczys?aw B?k,
 Bryan O'Sullivan
 { Shae Erisson, Dmitry Astapov, Don Stewart, Bulat Ziganshin,
   Bjorn Bringert }
  Extending GuiHaskell: An IDE for Haskell Hackers
 Asumu Takikawa,
 Neil David Mitchell
 { Duncan Coutts, Bulat Ziganshin }
  ---

Congratulations if you got accepted.  Commiserations if you didn't.  The
official start date of the SoC (when students begin to receive their
initial payments) is 28th May.  Until then, the students have courses
and exams (no doubt), but also (we hope) some time to familiarise
themselves with the existing codebase and background of their project.

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


[Haskell-cafe] Matlab in Haskell

2007-04-11 Thread oleg

Ryan Dickie wrote:
 I also hate matlab to death. Is there any possibility of using haskell as a
 replacement using ghci?

Yes. The strongly typed linear algebra project (Vectro) does exactly
that. With an added guarantee that attempting to add or multiply
matrices of inappropriate sizes is a type error. Thus typical errors
like forgetting to transpose a matrix/vector are reported before the
computation starts. The paper shows a few examples, including a larger
example of a learning algorithm.

http://ofb.net/~frederik/stla/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Why Perl is more learnable than Haskell

2007-04-11 Thread Dan Mead

Ah... there really needs to be more literature written on switching to the
functional paradigm, IMHO.

That is really these guys haven't had an easy time with it.

On 4/11/07, Ryan Dickie [EMAIL PROTECTED] wrote:


I thought I could resist this thread but I'll bite =:-()

The first language i learned was basic. No real functions, simple step by
step instructions. I then learned hypercard, c, c++, python, assembly, vhdl,
and too many others!

Now i've decided to learn haskell. I view it as a mathematicians language.
I do research in the field of medical imaging.. particularly processing
large cardiac data sets to figure out characteristics, diseases, etc. Why
workflow generally starts out as 1) mathematical idea 2) turn that pure
equation into a numerical recipe 3) implement, debug 5) analyze 6) goto step
1. I find doing my thinking in the continous domain makes things a lot
easier.

But here's where i differ from everyone else. I already have the
mathematical relationships all nice and tidy (hopefully!) in my head before
i start. I literally just implement it. I don't want to care about
threading, IO, message passing, or numerical stability. I have to care about
performance but only so far as it hampers my productivity. Preferably the
language will do it implicitly.

Your average programmer wants a language to do tasks. Having to think
about the math and relationships behind it all is rather sickening to them
(and me too!).

I am a new haskell programmer (basically a week into it!). It is by far
the hardest language i've had to pick up. A lot of my code could be
structured in a functional way.. but almost all reply on looping techniques
(would take a lot of work to rethink my gradient descent method and make it
fast!).  Regardless of actually using haskell.. i like to transfer these
techniques to c++. Before i even knew of haskell i knew some FP methods and
i found that using these shrunk my code, shrunk the bugs, and did nice
things for performance + concurrency. In fact, I just read a google paper on
their batch system. They use to functions: map and reduce. They can easily
split it up over their cluster etc... these are the ideas of FP that i like!
That and the set-builder notation.

I also hate matlab to death. Is there any possibility of using haskell as
a replacement using ghci? Mostly i care about linalg when it comes to using
matlab.

ps: sorry if gmail butchered this reply. I had subscribed to the digest
and turns out that was a mistake :D

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


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


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread Thomas Conway

On 4/11/07, riccardo cagnasso [EMAIL PROTECTED] wrote:

If you first language is LISP probably you find easy Haskell and difficult
pearl.


I must say I agree here. I spent 10 years programming in prolog before
I tried haskell. Most of my problems with haskell are because it has a
rather opaque performance model (e.g. when should you use tail
recursion, and when should you not). But I happily acknowledge that my
experience is probably atypical. ;-)

cheers,
T.
--
Dr Thomas Conway  You are beautiful; but learn to work,
[EMAIL PROTECTED] for you cannot eat your beauty.
 -- Congo proverb
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread kynn


riccardo cagnasso wrote:
 
 My opinion is that learnin haskell is difficult is just for the fact
 that
 when you learn programming, you probably begin with C / C++ or some other
 procedural/OO programming language...
 

Actually, my first language was Scheme; I loved it, and I aced the class,
but that was many years ago, and I never had to code real world
applications with Scheme.  My problems with Haskell are not conceptual, but
rather pragmatic.  I have not been able to find enough support in Haskell
for everyday tasks (e.g. read a stream from a socket; parse it into a simple
data structure; process the data in the structure; print out the results to
a socket; etc.), and unless I want to code large low-level libraries from
scratch just to get conceptually simple tasks done, I can't afford to use
Haskell (any more than I could afford to use barebones C, for that matter).

And even though my interest in learning Haskell is not a pragmatic one
(I'm quite productive with the tools I know; I just want to learn a new way
to program, by way of intellectual curiosity), my life is such that, unless
I can immediately make use of the language I'm attempting to learn, it just
won't stick!  The language needs it to be useful not because I need a tool,
but because unless it is useful my brain just won't absorb it!

kj

-- 
View this message in context: 
http://www.nabble.com/Why-Perl-is-more-learnable-than-Haskell-tf3559193.html#a9952211
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


[Haskell-cafe] Haskell Weekly News: April 12, 2007

2007-04-11 Thread Donald Bruce Stewart
---
Haskell Weekly News
http://sequence.complete.org/hwn/20070412
Issue 60 - April 12, 2007
---

   Welcome to issue 60 of HWN, a weekly newsletter covering developments
   in the [1]Haskell community.

   With the ICFP deadline passed, your Haskell Weekly News returns to its
   regularly scheduled programming. This week: a truckload of new
   libraries!

   1. http://haskell.org/

Announcements

   ndp-0.1: nested data parallelism in Haskell. Roman Leshchinskiy
   [2]announced the first release of [3]the NDP package, a library for
   writing nested data-parallel programs in Haskell, on shared-memory
   multiprocessors. The NDP library is part of the Data Parallel Haskell
   project. The paper [4]Data Parallel Haskell: a status report describes
   the underlying design and go through an example program.

   2. http://article.gmane.org/gmane.comp.lang.haskell.general/15006
   3. http://haskell.org/haskellwiki/GHC/Data_Parallel_Haskell
   4. http://www.cse.unsw.edu.au/~chak/papers/CLPKM07.html

   binary 0.3: bigger, better, faster. Lennart Kolmodin [5]announced
   binary 0.3. The 'binary' package provides efficient serialization of
   Haskell values to and from lazy ByteStrings. ByteStrings constructed
   this way may then be written to disk, written to the network, or
   further processed (e.g. stored in memory directly, or compressed in
   memory with zlib or bzlib). It's available [6]through Hackage, or via
   its [7]homepage.

   5. http://article.gmane.org/gmane.comp.lang.haskell.general/15044
   6. http://hackage.haskell.org/packages/archive/binary/binary-0.3.tar.gz
   7. http://www.cse.unsw.edu.au/~dons/binary.html

   Text.HTML.Chunks. Matthew Sackman [8]announced the [9]Text.HTML.Chunks
   library, a clone with improvements of the Perl HTML::Chunks module.
   The main achievement is the use of template-haskell to combine the
   template into the code at compile time. This then allows for static
   checking that the variables/fields that the templates are expecting
   are indeed being provided and that the templates the code is trying to
   use do indeed exist. The template is then incorporated within the
   code, removing the dependency on the template.

   8. http://article.gmane.org/gmane.comp.lang.haskell.general/15028
   9. http://www.wellquite.org/chunks

   Phooey 1.0 and GuiTV 0.3. Conal Elliott [10]announced a new version of
   Phooey, a library for functional user interfaces. Highlights in this
   release: uses new TypeCompose package, which includes a simple
   implementation of data-driven computation; new Applicative functor
   interface; eliminated the catch-all Phooey.hs module. Now import any
   one of Graphics.UI.Phooey.{Monad ,Applicative,Arrow}; Phooey.Monad has
   two different styles of output widgets, made by owidget and owidget'
   and more. Phooey is also used in GuiTV, a library for composable
   interfaces and 'tangible values'.

  10. http://article.gmane.org/gmane.comp.lang.haskell.general/15047

   The real Monad Transformer. Henning Thielemann [11]announced the real
   monad transformer! It has been argued that people avoid Haskell
   because of terms from Category theory like 'Monad'. This problem can
   now be solved by a wrapper which presents all the internet entirely
   without monads! Start [12]the parallel Haskell wiki. Of course the
   tool is written in Haskell, that is, Haskell helps solving problems
   which only exist because of Haskell. Bug reports and feature requests
   can be tracked at [13]here.

  11. http://article.gmane.org/gmane.comp.lang.haskell.general/15059
  12. http://tinyurl.com/2e32r4
  13. https://sourceforge.net/projects/parallelweb

   GHC 6.6.1 Release Candidate. Ian Lynagh [14]announced the Release
   Candidate phase for GHC 6.6.1. Snapshots beginning with 6.6.20070409
   are release candidates for 6.6.1. You can download snapshots from
   [15]here.

  14. http://article.gmane.org/gmane.comp.lang.haskell.glasgow.user/11964
  15. http://www.haskell.org/ghc/dist/stable/dist/

   Haskell Cryptographic Library 4.0.3. Dominic Steinitz [16]announced
   the release of a new version of the Haskell Cryptographic Library
   based on the [17]crypto proposal. See [18]the crypto home for more
   details. There is now no dependency on NewBinary. The downside is the
   library contains no support for ASN.1 which will be released in
   separate package.

  16. http://article.gmane.org/gmane.comp.lang.haskell.libraries/6761
  17. http://www.haskell.org/haskellwiki/Crypto_Library_Proposal
  18. http://www.haskell.org/crypto/

   TagSoup library 0.1. Neil Mitchell [19]announced TagSoup, a library
   for extracting information out of unstructured HTML code, sometimes
   known as [20]tag-soup. The HTML does not have to be well formed, or
   render properly within any particular framework. This library is for
   

[Haskell-cafe] k-minima in Haskell

2007-04-11 Thread raghu vardhan

What's the best way to implement the following function in haskell:
Given a list and an integer k as input return the indices of the least k
elements in the list. The code should be elegant and also, more importantly, 
must not make more than the minimum O(k*length(list)) number of operations.

R M




  Send a FREE SMS to your friend's mobile from Yahoo! Messenger. Get it now 
at http://in.messenger.yahoo.com/___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] k-minima in Haskell

2007-04-11 Thread Donald Bruce Stewart
mrvr84:
 
What's the best way to implement the following function in
haskell: Given a list and an integer k as input return the
indices of the least k elements in the list. The code should
be elegant and also, more importantly, must not make more
than the minimum O(k*length(list)) number of operations.
R M

Is this a homework question?

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


Re: [Haskell-cafe] Why Perl is more learnable than Haskell

2007-04-11 Thread Brandon S. Allbery KF8NH


On Apr 11, 2007, at 23:10 , kynn wrote:
rather pragmatic.  I have not been able to find enough support in  
Haskell
for everyday tasks (e.g. read a stream from a socket; parse it into  
a simple


The stuff in Network (not Network.Socket) gives you a Handle, which  
you can treat more or less like any other Haskell Handle  
(filehandle).  Network.Socket should be reserved for when you need to  
work at a really low level.


--
brandon s. allbery  [solaris,freebsd,perl,pugs,haskell]   
[EMAIL PROTECTED]
system administrator  [openafs,heimdal,too many hats]   
[EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon university   
KF8NH



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


Re: [Haskell-cafe] k-minima in Haskell

2007-04-11 Thread Stefan O'Rear
On Thu, Apr 12, 2007 at 08:58:33AM +0530, raghu vardhan wrote:
 What's the best way to implement the following function in haskell:
 Given a list and an integer k as input return the indices of the least
 k elements in the list. The code should be elegant and also, more
 importantly, must not make more than the minimum O(k*length(list))
 number of operations. 

Go read and thoroughly understand Why Functional Programming
Matters.

Also, your asyptotic complexity bound is just plain wrong.  I'd give
faster code, but Don is suspicious (and I can never tell these things
myself).

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


Re: [Haskell-cafe] k-minima in Haskell

2007-04-11 Thread Stefan O'Rear
On Wed, Apr 11, 2007 at 08:38:48PM -0700, Stefan O'Rear wrote:
 On Thu, Apr 12, 2007 at 08:58:33AM +0530, raghu vardhan wrote:
  What's the best way to implement the following function in haskell:
  Given a list and an integer k as input return the indices of the least
  k elements in the list. The code should be elegant and also, more
  importantly, must not make more than the minimum O(k*length(list))
  number of operations. 
 
 Go read and thoroughly understand Why Functional Programming
 Matters.
 
 Also, your asyptotic complexity bound is just plain wrong.  I'd give
 faster code, but Don is suspicious (and I can never tell these things
 myself).
 
 Stefan

Don tells me (in #haskell) that you are legitimate, so here is the
example:

kminima k lst = take k $ sort lst

If you want to be really explicit about it, here is a sort that will
work:

sort [] = []
sort l@(x:_) = filter (x) l ++ filter (==x) l ++ filter (x) l

(A stable quicksort, btw)

Note that this is FASTER than your bound - somewhere between O(n) and
O(n*log n).

Ain't lazy evaluation great? :)

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


Re: [Haskell-cafe] k-minima in Haskell

2007-04-11 Thread Stefan O'Rear
On Wed, Apr 11, 2007 at 09:20:12PM -0700, Tim Chevalier wrote:
 On 4/11/07, Stefan O'Rear [EMAIL PROTECTED] wrote:
 
 If you want to be really explicit about it, here is a sort that will
 work:
 
 sort [] = []
 sort l@(x:_) = filter (x) l ++ filter (==x) l ++ filter (x) l
 
 (A stable quicksort, btw)
 
 You may be missing a few recursive calls there :-)

Indeed.

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


Re: [Haskell-cafe] k-minima in Haskell

2007-04-11 Thread raghu vardhan
And just to remind people, the question is to find the indices and not
the numbers themselves. For example on input '3, [10,9,8,..., 3,2,1]'
the output must be '[9,8,7]'. 

- Original Message 
From: Stefan O'Rear [EMAIL PROTECTED]
To: raghu vardhan [EMAIL PROTECTED]
Sent: Wednesday, 11 April, 2007 11:17:15 PM
Subject: Re: [Haskell-cafe] k-minima in Haskell

On Thu, Apr 12, 2007 at 09:30:22AM +0530, raghu vardhan wrote:
 Hmmm.  That's not something I was looking for. I'm not sure the
 running time is good enough (think of k as being 2 - then you should
 not make more than 2n comparisons) - even with lazy evaluation,
 quick sort won't have a bound of O(k*n). 

Muahahahaha!
Muahahahahahahahahahaha!
Muahaha!

Actually it DOES.

(this list courtesy of a ghci one-liner)

find the 3 minima of 
[71,71,17,14,16,91,18,71,58,75,65,79,76,18,4,45,87,51,93,36]



take 3 (sort [71,71,17,14,16,91,18,71,58,75,65,79,76,18,4,45,87,51,93,36])



take 3 (sort (filter (71) 
[71,71,17,14,16,91,18,71,58,75,65,79,76,18,4,45,87,51,93,36]) ++ a bunch of 
stuff I won't track because it won't be evaluated)

  (comparisons so far: 20)

take 3 (sort [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36])

take 3 (sort (filter (17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36]) ++ 
filter (==17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36] ++
sort (filter (17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36]))

 (31)

take 3 (sort [14, 16, 18, 4] ++ 
filter (==17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36] ++
sort (filter (17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36]))

take 3 (sort (filter (14) [14, 16, 18, 4]) ++ sort (filter (==14) [14, 16, 18, 
4]) ++ sort (filter (14) [14, 16, 18, 4]) ++ 
filter (==17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36] ++
sort (filter (17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36]))

 (39)

take 3 (sort [4] ++ sort [14] ++ sort (filter (14) [14, 16, 18, 4]) ++ 
filter (==17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36] ++
sort (filter (17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36]))

take 3 (4 : 14 : sort (filter (14) [14, 16, 18, 4]) ++ 
filter (==17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36] ++
sort (filter (17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36]))

4 : 14 : take 1 (sort (filter (14) [14, 16, 18, 4]) ++ 
filter (==17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36] ++
sort (filter (17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36]))

 (43)

4 : 14 : take 1 (sort [16, 18] ++ 
filter (==17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36] ++
sort (filter (17) [17, 14, 16, 18, 58, 65, 18, 4, 45, 51, 36]))

 (47)

[4, 14, 16]

47 close enough to O(n*k) for you?  (remember this is quicksort we are
dealing with, O(n^2) worst case)

Stefan







  Send a FREE SMS to your friend's mobile from Yahoo! Messenger. Get it now 
at http://in.messenger.yahoo.com/___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] c2hs on mac

2007-04-11 Thread Ruben Zilibowitz

Hi,

I am having trouble building c2hs on Mac OS X. I noticed that  
Darwinports has a port for this, but I'd like to install it without  
using Darwinports because I already have ghc compiled and installed  
on my system.


Does anyone know how to get c2hs to work on the mac (or why it  
doesn't work in the first place)?


Regards,

Ruben

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


Re: [Haskell-cafe] k-minima in Haskell

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

Quoting raghu vardhan [EMAIL PROTECTED]:

 What's the best way to implement the following function in haskell:
 Given a list and an integer k as input return the indices of the least k
 elements in the list. The code should be elegant and also, more importantly,
 must not make more than the minimum O(k*length(list)) number of operations.

Pretty much like everyone has says, although it's best to use a real
lazy O(n log n) sort, not quicksort-with-dumbest-pivot.  To get the
indices, use the Schwartzian transform:

sortWith :: (Ord b) = (a - b) - [a] - [a]
sortWith f = mergeRuns . runs
  where
runs = map (:[])

mergeRuns [] = []
mergeRuns [xs] = xs
mergeRuns xss = mergeRuns (mergeRun xss)

mergeRun (xs1:xs2:xss) = mergeOne xs1 xs2 : mergeRun xss
mergeRun xss = xss

mergeOne [] ys = ys
mergeOne xs [] = xs
mergeOne xs'@(x:xs) ys':(y:ys)
= case compare (f x) (f y) of
LT - x : mergeOne xs ys'
GT - y : mergeOne xs' ys
EQ - x : y : mergeOne xs ys

getKMinima :: (Ord a) = [a] - [Int]
getKMinima k = map fst . take k . sortWith snd . zip [0..]

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


Re: [Haskell-cafe] c2hs on mac

2007-04-11 Thread Duncan Coutts
On Thu, 2007-04-12 at 15:20 +1000, Ruben Zilibowitz wrote:
 Hi,
 
 I am having trouble building c2hs on Mac OS X. I noticed that  
 Darwinports has a port for this, but I'd like to install it without  
 using Darwinports because I already have ghc compiled and installed  
 on my system.
 
 Does anyone know how to get c2hs to work on the mac (or why it  
 doesn't work in the first place)?

What is the problem exactly? Are you using the latest tarball or the
darcs version?

Duncan

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


Re: [Haskell-cafe] k-minima in Haskell

2007-04-11 Thread raghu vardhan

There seems to be some confusion about the question. There are two key things 
to keep in mind here:
1) You must make at most O(k*n) comparisons (in the worst case) if the list has 
length n.
2) The output must be the indices and not the numbers themselves. 

So, any algorithm that sorts is no good (think of n as huge, and k small). 
Another interesting caveat to this is that if k=2, you can actually solve the 
problem with just (n+log n) comparisons in worst case(instead of 2*n, that you 
get by a naive approach), and it's a nice exercise to do this.

As a further clarification, this is not a homework question. I genereally do 
whatever programming I do in Matlab, as I work with matrices (huge ones) and 
use this function a lot. I just wanted to see how different an implementation 
you can get in Haskell (I am new to Haskell so I might not be able to come up 
with the best way to do this). 

- Original Message 
From: Stefan O'Rear [EMAIL PROTECTED]
To: raghu vardhan [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Wednesday, 11 April, 2007 10:47:08 PM
Subject: Re: [Haskell-cafe] k-minima in Haskell

On Wed, Apr 11, 2007 at 08:38:48PM -0700, Stefan O'Rear wrote:
 On Thu, Apr 12, 2007 at 08:58:33AM +0530, raghu vardhan wrote:
  What's the best way to implement the following function in haskell:
  Given a list and an integer k as input return the indices of the least
  k elements in the list. The code should be elegant and also, more
  importantly, must not make more than the minimum O(k*length(list))
  number of operations. 
 
 Go read and thoroughly understand Why Functional Programming
 Matters.
 
 Also, your asyptotic complexity bound is just plain wrong.  I'd give
 faster code, but Don is suspicious (and I can never tell these things
 myself).
 
 Stefan

Don tells me (in #haskell) that you are legitimate, so here is the
example:

kminima k lst = take k $ sort lst

If you want to be really explicit about it, here is a sort that will
work:

sort [] = []
sort l@(x:_) = filter (x) l ++ filter (==x) l ++ filter (x) l

(A stable quicksort, btw)

Note that this is FASTER than your bound - somewhere between O(n) and
O(n*log n).

Ain't lazy evaluation great? :)

Stefan







  Send a FREE SMS to your friend's mobile from Yahoo! Messenger. Get it now 
at http://in.messenger.yahoo.com/___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe