Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Don Stewart
bf3:
> For me, a good reason why one should look at Haskell is because you 
> should NOT look at Haskell since it will change your view on programming 
> so much, you don't want to go back... ;-)
> 
> But where is the great IDE Haskell deserves??? :-) Seriously, 99% of the 
> programmers I know don't want to look at it because when they see Emacs 
> or VIM, they say "what the f*ck, I don't want to go back to the 
> stone age". If you want to attract more people that are inside the 
> "imperative-OO-with-nice-IDE-blob", create a great looking and 
> functional IDE. An IDE that integrates the existing tools. That shows 
> you graphical pictures of the graph rewriting process, potential space 
> leaks, profiling bottlenecks, etc. Heck, why not introduce pictures as 
> symbols and values, as in DrScheme. Or UNICODE fonts. or or ... Okay, 
> enough of that, off topic ;-)

It has been suggested we could just sit DrScheme in front of ghc/ghci.
Anyone with experience who'd like to step up for this?

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


[Haskell-cafe] more basic articles on functional programming using haskell

2007-10-05 Thread Vikrant
part I -> http://www.ias.ac.in/resonance/August2007/p27-48.pdf

part II -> http://www.ias.ac.in/resonance/September2007/p40-63.pdf

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


[Haskell-cafe] Re: New slogan for haskell.org

2007-10-05 Thread Alex Tarkovsky
Brandon S. Allbery KF8NH wrote:
> I can has English?  :)

This comment inspired what could be either the beginning of an
infectious Haskell recruitment campaign, or just a sign that some of us
are mad. I present the lambdacats:

http://arcanux.org/lambdacats.html

-- 
Alex Tarkovsky

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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Dan Weston
Perl hackers are notoriously good at write-once coding. It's the part 
where others read what you wrote and make sense of it where Haskell 
pulls ahead.


Albert Y. C. Lai wrote:

The Hackathon is a good opportunity to collect preliminary data.

Imagine: All other communities are still at the stage of "we feel 
productivity". We have "our data shows productivity". That puts us at a 
completely different level --- light-years above the crowd.


Haskell --- because we put the "engineering" back into "software 
engineering".

___
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] New slogan for haskell.org

2007-10-05 Thread Albert Y. C. Lai

The Hackathon is a good opportunity to collect preliminary data.

Imagine: All other communities are still at the stage of "we feel 
productivity". We have "our data shows productivity". That puts us at a 
completely different level --- light-years above the crowd.


Haskell --- because we put the "engineering" back into "software 
engineering".

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


[Haskell-cafe] Re: New slogan for haskell.org

2007-10-05 Thread Aaron Denney
On 2007-10-05, Aaron Denney <[EMAIL PROTECTED]> wrote:
> On 2007-10-05, Peter Verswyvelen <[EMAIL PROTECTED]> wrote:
>> But where is the great IDE Haskell deserves??? :-) Seriously, 99% of the 
>> programmers I know don't want to look at it because when they see Emacs 
>> or VIM, they say "what the f*ck, I don't want to go back to the 
>> stone age". If you want to attract more people that are inside the 
>> "imperative-OO-with-nice-IDE-blob", create a great looking and 
>> functional IDE.
>
> Bluntly, I don't see why the Haskell community needs those sorts of
> programmers.  I like Haskell with a big enough community to have useful
> libraries, but a small enough community such that the language can
> readily evolve and serve as a useful research platform.

This is not say that nice tools aren't useful or that we should be less
than welcoming to anyone interested in Haskell.

But the best tool that makes a language more useful is the language
itself.  If I don't have as much boilerplate all over the place, then I
don't need a tool that goes and finds all this boilerplate and changes
it.  When the language manages memory for me, I don't need valgrind.
If I write a program that can't crash, I don't need crash-analysis
tools.  If my programs minimize state-change, I have less need of
traditional debuggers with watchpoints and breakpoints.  If my functions
are guaranteed by the compiler to be pure, /semantic/ debuggers, that
algebraicly manipulate definitions and can iteratively zero in on
meanings being wrong rather than just implementations "glitching" become
useable.  When I can autogenerate test data for my functions based
solely on the type, testing can be much easier.

We already have a lot of nice tools that do what we want.  Slapping a
GUI on them and maintaining integration while they're evolving is less
useful to me than programmers exploring other additional useful tools.

-- 
Aaron Denney
-><-

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


[Haskell-cafe] Hackathon underway

2007-10-05 Thread Don Stewart
Just to let everyone know , the Haskell Hackathon is underway (the 2nd
this year), in Freiburg, Germany, and library and infrastructure code is
being worked on furiously -- Cabal and related tools in particular. You
can follow all the action from planet.haskell.org, and from the
hackathon site, including photos.

http://www.haskell.org/haskellwiki/Hac_2007_II#Photos_.2F_blogs

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


Re: [Haskell-cafe] Puzzled

2007-10-05 Thread Bertram Felgenhauer
Peter Verswyvelen wrote:
> The following code, when compiled with GHC 6.6.1 --make -O gives a stack 
> overflow when I enter 100 as a command line argument:
>
> (please don't look at the efficiency of the code, it can of course be 
> improved a lot both in time performance and numeric precision...)
>
> import System
>
> leibnizPI :: Integer -> Double
> leibnizPI n = sum (map leibnizTerm [0..n]) where
>leibnizTerm n = let i = fromIntegral n
>in 4 * (((-1) ** i) / (2*i+1))
> main = do
>  args <- getArgs
>  let n = read (head args)
>  print (leibnizPI n)
>
> However, if I replace
>
> main = print (leibnizPI 100)
>
> is does not stack overflow.
>
> Now, if I leave the original main, but replace sum in leibnizPI by
>
> mysum xs = aux 0 xs
>where
>  aux s (x:xs) = aux (s+x) xs
>  aux s [] = s
>
> Then I don't get a stack overflow.
>
> However, I do get a stack overflow when I compile it without -O, in all 
> cases.
>
> This puzzles me. I don't see any non-tail calls in my code...
>
> I guess it has to do with strictness? 
> http://www.haskell.org/haskellwiki/Performance/Strictness

Yes.

The problem is that without optimizations, both  sum  and  mysum
build a large unevaluated expression of the form

((..((0+x1)+x2)+...)+xn)

The stack overflow happens when this expression gets evaluated. At that
point, the outermost (+) demands the result of the (+) on the next level,
and so on.

To prevent this you need a stricter version of sum. You can build one
with foldl':

> import Data.List
> 
> sum' :: Num a => [a] -> a
> sum' = foldl' (+) 0

Arguably this is the "correct" definition of sum. The problem you
had is fairly common.

> Why isn't it possible to annotate strictness on the type signature in 
> Haskell as in Clean? Is this on the TODO list?

Strictness is independent from the type in Haskell (but see the fourth
solution presented below). You can explicitely make one value at least
as strict as another using  seq:

> mysum' xs = aux 0 xs
>where
>  aux s (x:xs) = let s' = s+x in s' `seq` aux s' xs
>  aux s [] = s

In ghc, you can mark arguments as strict

> mysum'' xs = aux 0 xs
>where
>  aux !s (x:xs) = aux (s+x) xs
>  aux !s [] = s

This is a language extension, you need -fbang-patterns
to allow it, or with a recent ghc (6.7, 6.9 or a 6.8 rc)
a {-# LANGUAGE BangPatterns #-} pragma, or -XBangPatterns.

A fourth possibility, which is Haskell 98 again, is to declare an
auxiliary data type with a strict field:

> data Strict a = Strict !a
>
> mysum''' xs = aux (Strict 0) xs
>   where
> aux (Strict s) (x:xs) = aux (Strict (s+x)) xs
> aux (Strict s) [] = s

Hope that helps,

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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Andrew Coppin

Henning Thielemann wrote:
If this would be true, they would have switched to Modula II quickly 
... I know that C programmers also like the 
concise/cryptic/inconsistent syntax.


It seems to me more than C programmers like to think they're cleaver 
because they can spend weeks building elaborate and complex low-level 
kludges to squeeze a few extra picoseconds out of the inner loop of a 
program to make it go just that bit faster. Trying to get such people to 
use Haskell seems fairly hopeless; you're so far from the hardware that 
you don't do such tricks.


(Of course, there are plenty of C programmers who use it for other 
reasons. It has the best compilers. It's the most portable. It can talk 
to the OS and to hardware directly. For embedded systems, it might be 
the only thing you've got. And so on...)


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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Andrew Coppin

Bayley, Alistair wrote:

Well, wouldn't it be best to define your audience first? At the risk of
alienating Pythonistas...

The Python home page is very much snake oil (as Albert points out). But
it appears that they're aiming squarely at the average gormless
C/C++/VB/Java drone who's heard a bit about some exciting dynamic
language called "python". And I think they do a pretty good job at
marketing to this segment.

So the question becomes: do you want to attract/seduce this kind of
programmer? Let's assume the answer is yes :-)


Um... that assumpion troubles me.

Learning Haskell requires a fairly serious investment of mental energy. 
The language is completely unlike anything else in the mainstream. (I 
don't think Lisp or Erlang count as "mainstream" quite yet.) How many 
coders who spend their days churning out boiler-plate Java or VB are 
going to bother with all that effort? Few, I would think. Besides, 
currently Haskell pretty much sucks at all the things Java and VB are 
good at. (Web development, playing with databases, talking to native 
applications, building complex GUIs, etc. Sure, it can all be done. But 
it's much harder than in Java or VB...)


I think if we want to get anywhere we need to look at targeting people 
whom Haskell actually has something to offer. Now, if I could just 
figure out who those are... :-/


PS. Let's *not* mention Lisp, Erlang, Clean et al, eh? They're all 
already wildly more popular than Haskell, so let's not make it any worse...


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


Re: [Haskell-cafe] Re: New slogan for haskell.org

2007-10-05 Thread Jonathan Cast
On Fri, 2007-10-05 at 20:19 +, Aaron Denney wrote:
> On 2007-10-05, Peter Verswyvelen <[EMAIL PROTECTED]> wrote:
> > But where is the great IDE Haskell deserves??? :-) Seriously, 99% of the 
> > programmers I know don't want to look at it because when they see Emacs 
> > or VIM, they say "what the f*ck, I don't want to go back to the 
> > stone age". If you want to attract more people that are inside the 
> > "imperative-OO-with-nice-IDE-blob", create a great looking and 
> > functional IDE.
> 
> Bluntly, I don't see why the Haskell community needs those sorts of
> programmers.

Hear, hear.  At the company I work for, all the code is perl/web
development --- and we wouldn't dream of hiring one of those
programmers.  In fact, I think decreasing the number of those
programmers in existence would be a good way to /increase/ the quantity
and quality of the programs in existence; those are the sorts of
programmers that, if they ever found a new career, we'd have to put
three additional programmers out of a job just to break even.



jcc


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


[Haskell-cafe] Re: New slogan for haskell.org

2007-10-05 Thread Aaron Denney
On 2007-10-05, Peter Verswyvelen <[EMAIL PROTECTED]> wrote:
> But where is the great IDE Haskell deserves??? :-) Seriously, 99% of the 
> programmers I know don't want to look at it because when they see Emacs 
> or VIM, they say "what the f*ck, I don't want to go back to the 
> stone age". If you want to attract more people that are inside the 
> "imperative-OO-with-nice-IDE-blob", create a great looking and 
> functional IDE.

Bluntly, I don't see why the Haskell community needs those sorts of
programmers.  I like Haskell with a big enough community to have useful
libraries, but a small enough community such that the language can
readily evolve and serve as a useful research platform.

> An IDE that integrates the existing tools. That shows you graphical
> pictures of the graph rewriting process,

There is a tool that does this for a Haskell dialect.

> potential space leaks,

That's a hard problem.

> profiling bottlenecks, etc.

I'm not entirely sure what you mean here, but people are researching
good ways of profiling and presenting the results to programmers. 

> Heck, why not introduce pictures as symbols and values, as in DrScheme.

Or as in Mathematica 6, to be a bit more mainstream.

> Or UNICODE fonts. 

GHC already supports UTF-8.  Vim and Emacs already support UTF-8.  Done.

-- 
Aaron Denney
-><-

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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Peter Verswyvelen
For me, a good reason why one should look at Haskell is because you 
should NOT look at Haskell since it will change your view on programming 
so much, you don't want to go back... ;-)


But where is the great IDE Haskell deserves??? :-) Seriously, 99% of the 
programmers I know don't want to look at it because when they see Emacs 
or VIM, they say "what the f*ck, I don't want to go back to the 
stone age". If you want to attract more people that are inside the 
"imperative-OO-with-nice-IDE-blob", create a great looking and 
functional IDE. An IDE that integrates the existing tools. That shows 
you graphical pictures of the graph rewriting process, potential space 
leaks, profiling bottlenecks, etc. Heck, why not introduce pictures as 
symbols and values, as in DrScheme. Or UNICODE fonts. or or ... Okay, 
enough of that, off topic ;-)


Donn Cave wrote:


On Oct 5, 2007, at 1:59 AM, Bayley, Alistair wrote:



So the question becomes: do you want to attract/seduce this kind of
programmer? Let's assume the answer is yes :-)


Hmm...


... Then what sort of
language should you use in your promotional paragraph? I don't think
"polymorphism", "monads/monadic effects", "higher order functions", and
even "type classes" should be used. These terms will be universally
unfamiliar to the target audience, and will alienate them.


Maybe.  Good.  Some readers will say to themselves `this language appears
to have many unfamiliar features ... I must look into this!'  At this 
point, these

are only ones who are going to thrive anyway.

From what I've seen, the greatest hurdle is the features that ARE 
familiar,
particularly strong static typing.  Everyone knows static typing from 
Pascal,
C, C++, Java ... know what I'm saying?  If there's some way to defeat 
this

false recognition, that should help a lot.

Or maybe that's good too, for more survivor self selection.  Maybe a good
slogan would be `like LISP, but with strong static typing!'

Donn Cave, [EMAIL PROTECTED]
___
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] Puzzled

2007-10-05 Thread Peter Verswyvelen
The following code, when compiled with GHC 6.6.1 --make -O gives a stack 
overflow when I enter 100 as a command line argument:


(please don't look at the efficiency of the code, it can of course be 
improved a lot both in time performance and numeric precision...)


import System

leibnizPI :: Integer -> Double
leibnizPI n = sum (map leibnizTerm [0..n]) where
   leibnizTerm n = let i = fromIntegral n
   in 4 * (((-1) ** i) / (2*i+1))
main = do
 args <- getArgs
 let n = read (head args)
 print (leibnizPI n)

However, if I replace

main = print (leibnizPI 100)

is does not stack overflow.

Now, if I leave the original main, but replace sum in leibnizPI by

mysum xs = aux 0 xs
   where
 aux s (x:xs) = aux (s+x) xs
 aux s [] = s

then I don't get a stack overflow.

However, I do get a stack overflow when I compile it without -O, in all 
cases.


This puzzles me. I don't see any non-tail calls in my code...

I guess it has to do with strictness? 
http://www.haskell.org/haskellwiki/Performance/Strictness


Why isn't it possible to annotate strictness on the type signature in 
Haskell as in Clean? Is this on the TODO list?


Many thanks,
Peter


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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Laurent Deniau

Brandon S. Allbery KF8NH wrote:


On Oct 5, 2007, at 12:33 , Henning Thielemann wrote:


http://www.henning-thielemann.de/CHater.html#CvsM3_ControlFlow


I can has English?  :)

If the first large table is any indication, though, we may need to 
define "inconsistent".  C syntax shown there is quite consistent; what 
it isn't, is designed to keep humans from making certain kinds of 
mistakes.  I'm rather mixed on that goal:  on the one hand, C does 
attract certain errors due to its syntax, but on the other, a language 
designed to coddle the programmer also tends to keep the programmer from 
doing useful things.  (What's the last practical application you've seen 
in Logo?  Or un-extended Pascal?)


Fully agreed. The only inconsistency I can think of is the declaration 
of pointer to function returning a pointer to function. This is 
effectively a bit hard to read since it needs to read forth and back to 
evaluate the expression. A typedef will simplify the reading when 
frequently used as in state machines.


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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Brandon S. Allbery KF8NH


On Oct 5, 2007, at 12:33 , Henning Thielemann wrote:


http://www.henning-thielemann.de/CHater.html#CvsM3_ControlFlow


I can has English?  :)

If the first large table is any indication, though, we may need to  
define "inconsistent".  C syntax shown there is quite consistent;  
what it isn't, is designed to keep humans from making certain kinds  
of mistakes.  I'm rather mixed on that goal:  on the one hand, C does  
attract certain errors due to its syntax, but on the other, a  
language designed to coddle the programmer also tends to keep the  
programmer from doing useful things.  (What's the last practical  
application you've seen in Logo?  Or un-extended Pascal?)


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


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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Henning Thielemann


On Fri, 5 Oct 2007, Laurent Deniau wrote:


Henning Thielemann wrote:

I know that C programmers also like the concise/cryptic/inconsistent 
syntax.


Syntax is often a matter of taste. Every languages look cryptic for 
unfamiliar people. Haskell has itself some conventions in notation which 
allows concise coding. Do you have an example of syntax inconsistency in C?


One? - Many!

Choose your favorite one:
  http://www.henning-thielemann.de/CHater.html#CvsM3_ControlFlow
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Richard Kelsall

Albert Y. C. Lai wrote:


... I'll ask the Greg Wilson question: where is your data? ...


I think we could make some sort of claim for the concise nature of
Haskell code based on "Evaluating High-Level Distributed Language
Constructs" by Phil Trinder

http://www.macs.hw.ac.uk/~trinder/papers/ICFP2007.pdf

which suggests a code size ratio approximately GdH = 1, Erlang = 6,
C++ = 42. I'm assuming GdH is sufficiently close to vanilla Haskell
for this result to apply to Haskell too.


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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Donn Cave


On Oct 5, 2007, at 1:59 AM, Bayley, Alistair wrote:



So the question becomes: do you want to attract/seduce this kind of
programmer? Let's assume the answer is yes :-)


Hmm...


... Then what sort of
language should you use in your promotional paragraph? I don't think
"polymorphism", "monads/monadic effects", "higher order functions",  
and

even "type classes" should be used. These terms will be universally
unfamiliar to the target audience, and will alienate them.


Maybe.  Good.  Some readers will say to themselves `this language  
appears
to have many unfamiliar features ... I must look into this!'  At this  
point, these

are only ones who are going to thrive anyway.

From what I've seen, the greatest hurdle is the features that ARE  
familiar,
particularly strong static typing.  Everyone knows static typing from  
Pascal,
C, C++, Java ... know what I'm saying?  If there's some way to defeat  
this

false recognition, that should help a lot.

Or maybe that's good too, for more survivor self selection.  Maybe a  
good

slogan would be `like LISP, but with strong static typing!'

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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Laurent Deniau

Henning Thielemann wrote:


On Fri, 5 Oct 2007, Laurent Deniau wrote:


Henning Thielemann wrote:
Productivity, robustness, maintainability: purity, type 
system, etc. Parallelism!


'type system' is something where C derivatives and scripting 
languages are weak - but their users count this as advantage.


Rarely (maybe in the 70's but not since C89). They count as an 
advantage simplicity, portability and efficiency. If you can provide a 
better type system to C while keeping these points, you are welcome. 
Still, it is easy to make your code strongly typed in C with some 
discipline.


If this would be true,


it is true and a good practice.

they would have switched to Modula II quickly ... 


Everybody is free to move from one language to another but Ada could be 
a more attractive target.


I know that C programmers also like the concise/cryptic/inconsistent 
syntax.


Syntax is often a matter of taste. Every languages look cryptic for 
unfamiliar people. Haskell has itself some conventions in notation which 
allows concise coding. Do you have an example of syntax inconsistency in C?


regards,

ld.

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


Re: [Haskell-cafe] Confusing type specialisation in ghci

2007-10-05 Thread Isaac Dupree

David Carter wrote:

This is all as I would expect so far, but:

Prelude> let sqlist = map sq
Prelude> :t sqlist
sqlist :: [Integer] -> [Integer]

And indeed, I get

Prelude> sqlist [2.5]

:1:8:
   No instance for (Fractional Integer)
   ... etc


The dreaded Monomorphism Restriction, which GHCi chooses to apply after 
every line you input.  You could say "let sqlist a = map sq a" 
(syntactically having arguments makes the defaulting of (Num a => [a] -> 
[a]) not apply), or just use `ghci -fno-monomorphism-restriction`.


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


[Haskell-cafe] Confusing type specialisation in ghci

2007-10-05 Thread David Carter

Hello,

Can someone elucidate to me this behaviour from ghci 6.6.1? Why is the 
type of sqlist specialised to Integer?


Prelude> let sq x = x * x
Prelude> :t sq
sq :: (Num a) => a -> a
Prelude> sq 2.5
6.25
Prelude> :t map sq
map sq :: (Num a) => [a] -> [a]
Prelude> map sq [2.5]
[6.25]

This is all as I would expect so far, but:

Prelude> let sqlist = map sq
Prelude> :t sqlist
sqlist :: [Integer] -> [Integer]

And indeed, I get

Prelude> sqlist [2.5]

:1:8:
   No instance for (Fractional Integer)
   ... etc

Thanks!

David





--
The Wellcome Trust Sanger Institute is operated by Genome Research 
Limited, a charity registered in England with number 1021457 and a 
company registered in England with number 2742969, whose registered 
office is 215 Euston Road, London, NW1 2BE. 
___

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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Henning Thielemann


On Fri, 5 Oct 2007, Laurent Deniau wrote:


Henning Thielemann wrote:
Productivity, robustness, maintainability: purity, type system, etc. 
Parallelism!


'type system' is something where C derivatives and scripting languages are 
weak - but their users count this as advantage.


Rarely (maybe in the 70's but not since C89). They count as an advantage 
simplicity, portability and efficiency. If you can provide a better type 
system to C while keeping these points, you are welcome. Still, it is easy to 
make your code strongly typed in C with some discipline.


If this would be true, they would have switched to Modula II quickly ... I 
know that C programmers also like the concise/cryptic/inconsistent syntax.

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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Laurent Deniau

Henning Thielemann wrote:
Productivity, robustness, maintainability: purity, type system, 
etc. Parallelism!


'type system' is something where C derivatives and scripting languages 
are weak - but their users count this as advantage.


Rarely (maybe in the 70's but not since C89). They count as an advantage 
simplicity, portability and efficiency. If you can provide a better type 
system to C while keeping these points, you are welcome. Still, it is 
easy to make your code strongly typed in C with some discipline.


I want to raise the 
question again, whether it is reasonable to move convinced C and Perl 
programmers to Haskell - They will want to write C and Perl style 
programs using Haskell.


Not necessary. I am coming from C/C++ and I use Haskell for what I like 
it, that is functional programming.


I think it is better to attract the people who 
find 'filter' and 'map' good in Python and want to get to know the 
original language.


filter and map exist also in non functional languages. lambda and 
composition are much more uncommon outside the FPL world and much more 
difficult to 'emulate'.



On Thu, 4 Oct 2007, Don Stewart wrote:


Yep, its similar to the elevator pitch, but a little shorter, and
mentions why as a programmer this is worth your time.

I'm not sure "monadic effects" is terribly motivating for someone who's
heard about Haskell, and just wants to get things done faster, and more
reliably -- which is really what Haskell can be about.


My experience is, that 'purely functional' made me curious because I 
wanted a nice, elegant language which is not cluttered with much 
patches. 'Monadic effects' sounded strange and made me even more curious.


Exactly the same for me but I prefer arrows to monads ;-) BTW, I do not 
understand why Arrow does not have a delay operator which would store 
its input and return its previous input. This would be quite helpful to 
describe signal processing and control system with SF (this question 
came to mind while reading the draft of H.Liu and P.Hudak on space leaks).


What bother me about Haskell is that unfortunately I cannot use it in my 
work (numerical analysis) because of its lack of _efficiency_ and to a 
lesser extend of stability and portability. Despite that I am pretty 
sure that it will be solved in some future.


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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Laurent Deniau

Henning Thielemann wrote:


On Fri, 5 Oct 2007, Albert Y. C. Lai wrote:

Granted, perhaps your perspective is, if every other company is 
shouting "customers are number one", then ours must too, and who 
actually lives up to it is the non-sequitur here. You're in the 
buzzword war, not the evidence war. OK, then make sure you include
 executability, as the Python guys in their infinite wisdom have 
forgotten that one. You'll trump them on that point, ha!


me too


To exemplify, I now analyze the Python statement under my glass:

"dynamic object-oriented": Good, informative, I know those words
and I am the one to decide its implications to me.


To be honest - I do not know exactly what is meant with 'dynamic'
here. I know Python is dynamically typed - is this meant? Or
'dynamic' in the sense of 'can alter data at run-time', or 'can run
programs' at all?


all of that, plus the ability to change the objects' types (hierarchies)
at runtime like in most dynamically typed languages.

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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Don Stewart
lemming:
> 
> On Fri, 5 Oct 2007, Albert Y. C. Lai wrote:
> 
> >Granted, perhaps your perspective is, if every other company is shouting 
> >"customers are number one", then ours must too, and who actually lives up 
> >to it is the non-sequitur here. You're in the buzzword war, not the 
> >evidence war. OK, then make sure you include executability, as the Python 
> >guys in their infinite wisdom have forgotten that one. You'll trump them 
> >on that point, ha!
> 
> me too
> 
> >To exemplify, I now analyze the Python statement under my glass:
> >
> >"dynamic object-oriented": Good, informative, I know those words and I am 
> >the one to decide its implications to me.
> 
> To be honest - I do not know exactly what is meant with 'dynamic' here. I 
> know Python is dynamically typed - is this meant? Or 'dynamic' in the 
> sense of 'can alter data at run-time', or 'can run programs' at all?

'dynamic' as in 'agile' and 'cool' :)

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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Henning Thielemann


On Fri, 5 Oct 2007, Albert Y. C. Lai wrote:

Granted, perhaps your perspective is, if every other company is shouting 
"customers are number one", then ours must too, and who actually lives up to 
it is the non-sequitur here. You're in the buzzword war, not the evidence 
war. OK, then make sure you include executability, as the Python guys in 
their infinite wisdom have forgotten that one. You'll trump them on that 
point, ha!


me too


To exemplify, I now analyze the Python statement under my glass:

"dynamic object-oriented": Good, informative, I know those words and I am the 
one to decide its implications to me.


To be honest - I do not know exactly what is meant with 'dynamic' here. I 
know Python is dynamically typed - is this meant? Or 'dynamic' in the 
sense of 'can alter data at run-time', or 'can run programs' at all?

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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Henning Thielemann



On 10/4/07, Don Stewart <[EMAIL PROTECTED]> wrote:

It was raised at CUFP today that while Python has:

Python is a dynamic object-oriented programming language that can be
used for many kinds of software development. It offers strong
support for integration with other languages and tools, comes with
extensive standard libraries, and can be learned in a few days. Many
Python programmers report substantial productivity gains and feel
the language encourages the development of higher quality, more
maintainable code.


I think that this description is very unspecific and I guess everyone 
claims that for his favourite language.




Here's some quick points:

General purpose: applications from OS kernels to compilers to web dev to ...
Strong integration with other languages: FFI, and FFI binding tools
Many developer tools: debugger, profiler, code coverage, QuickCheck
Extensive libraries: central library repository, central repo hosting


Until here people will say: "Ah nice, like C++ I use for many years now."



Productivity, robustness, maintainability: purity, type system, etc. 
Parallelism!


'type system' is something where C derivatives and scripting languages are 
weak - but their users count this as advantage. I want to raise the 
question again, whether it is reasonable to move convinced C and Perl 
programmers to Haskell - They will want to write C and Perl style programs 
using Haskell. I think it is better to attract the people who find 
'filter' and 'map' good in Python and want to get to know the original 
language.





On Thu, 4 Oct 2007, Don Stewart wrote:


Yep, its similar to the elevator pitch, but a little shorter, and
mentions why as a programmer this is worth your time.

I'm not sure "monadic effects" is terribly motivating for someone who's
heard about Haskell, and just wants to get things done faster, and more
reliably -- which is really what Haskell can be about.


My experience is, that 'purely functional' made me curious because I 
wanted a nice, elegant language which is not cluttered with much patches. 
'Monadic effects' sounded strange and made me even more curious.

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


Re: [Haskell-cafe] Curry and uncurry

2007-10-05 Thread Martin Percossi
Warning: I hope I haven't spoiled the answer to this problem. If so, 
read only until the answer becomes clear!


I think the key is to be quite clear about what it is the function 
should do. Reading the type helps:


Prelude> :t curry
curry :: ((a, b) -> c) -> a -> b -> c

This type signature looks a bit confusing, but in fact, we can separate 
it into two chunks:


curry :: ((a, b) -> c) -> (a -> b -> c)

The first chunk is the input, and the second chunk is the output, 
obviously. So what this means is that curry takes a function which sends 
(a, b) pairs to a new type c, and returns a function which takes two 
arguments (*), a variable of type a, and one of type b, and returns a c.


So our implementation will have to take a function as its argument:

curry f = [implementation]

Also, we know that curry should itself return a function. Although we 
don't yet know the definition of that function, let's declare it and 
return it anyway:


curry f = let  in curriedFn

But what should curriedFn do? Well we know that it should replicate the 
behaviour of f. But we also know that it's arguments need to be 
translated, so that the two arguments (one of type a, and one of type b) 
become a *single* argument of type (a, b). Can you think of a definition 
of curriedFn so that when it is called with the arguments x, y, it in 
turn produces the same result as calling f (x, y) ?


HTH
Martin

(*) yes, I am aware that the internally all functions take just one 
parameter.


PR Stanley wrote:


No, still no idea!
I tried curry f
where f :: (Num a) => (a, a) -> a
and it didn't like it.
For some reason I'm finding this a little chalenging.
Thanks, Paul
At 17:03 03/10/2007, you wrote:

On 10/3/07, PR Stanley 
<[EMAIL PROTECTED]> wrote:

I didn't even know about the curry and uncurry functions. I'm not
looking for the answer but some guidance would be much appreciated.
Thanks, Paul


You can look at the types without seeing the implementation, too. 
Just start up GHCI and type:


  :t curry

or

  :t uncurry

Justin



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



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


[Haskell-cafe] Re: Space and time leaks

2007-10-05 Thread ChrisK
Dan Weston wrote:
> Ronald Guida wrote:
>> I need some help with space and time leaks.
>>
>> I know of two types of space leak.  The first type of leak occurs when
>> a function uses unnecessary stack or heap space.
>>
>> GHCi> sum [1..10^6]
>> *** Exception: stack overflow
>>
>> Apparently, the default definition for "sum" has a space leak.
>> I can define my own sum in terms of strict foldl ...
>>
>>  > sum' xs = foldl' (+) 0 xs
>>
>> ... and it doesn't overflow the stack.
>>
>> GHCi> sum' [1..10^6]
>> 5050
>> (0.27 secs, 112403416 bytes)
> 
> But it fills the heap? My intuition is that
> 
>   foldr (+) 0 [1..10^6]
> 
> is the fusion of a good producer and consumer so no heap is wasted
> constructing [1..10^6] but the stack is instead filled with
> (1+),(2+),...,(99+) unary functions, whereas
> 
>   foldl' (+) 0 [1..10^6]
> 
> does not fill the stack with anything but does fill the heap with
> [1..10^6] because foldl' is no longer a good consumer?

Nope, it runs in small space.  The [1..10^6] is evaluated lazily, it is never
larger than the thunk that represent the rest of the list.  If foldl' is a "good
consumer" then GHC can avoid making the list's cons-cells (:).  If foldl' is not
a "good consumer" then then each cons cell is created and then quickly garbage
collected.

> 
> If so, it seems that the stack is smaller than the heap (or else the
> size of (1+) is much larger than that the element of an [Int].
> 
> Anyone know the truth of any of this?

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


RE: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Bayley, Alistair
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Don Stewart
> 
> > > It was raised at CUFP today that while Python has:
> > > ...
> > > Note its all about how it can help you.
> > >
> > > The Haskell website has the rather strange motivational text:
> > > ...
> > 
> > Can't we embrace the power of 'and'? It's wonderful that Haskell is
> > seeing more practical use, but we shouldn't forget the foundations,
> > either. Maybe we should put your second description first, 
> and *then*
> > have a paragraph saying, "and, for those who know what these are,
> > polymorphism, monadic effects, etc."? Only describing 
> Haskell in terms
> > of software engineeering doesn't seem right to me.
> 
> Yes, I think that's the best step. Combine both why you'd use it, with
> what unique features enable this. 


Well, wouldn't it be best to define your audience first? At the risk of
alienating Pythonistas...

The Python home page is very much snake oil (as Albert points out). But
it appears that they're aiming squarely at the average gormless
C/C++/VB/Java drone who's heard a bit about some exciting dynamic
language called "python". And I think they do a pretty good job at
marketing to this segment: the python.org website is certainly sexier
than haskell.org, and the promotional text is in prime position, *in
bold*.

BTW, the Ruby website ( http://www.ruby-lang.org/en/ ) is quite similar
in promotional style, and has an even sexier design. They're making the
most of the attention ruby-on-rails has generated.

So the question becomes: do you want to attract/seduce this kind of
programmer? Let's assume the answer is yes :-) ... Then what sort of
language should you use in your promotional paragraph? I don't think
"polymorphism", "monads/monadic effects", "higher order functions", and
even "type classes" should be used. These terms will be universally
unfamiliar to the target audience, and will alienate them. I agree with
Tim that Haskell's sound foundations are great and should be promoted;
but perhaps in woolier language?

Something to bear in mind is that if your reader does know what
higher-order functions, type classes, and monads are, then it is likely
that they already have a good idea of what Haskell is. Preaching to the
converted.

> Only describing Haskell in terms
> of software engineeering doesn't seem right to me.

If you assume the same target audience as above, to me it seems right to
*only* use software engineeering terms, because they're about the only
terms that will be understood.

So here are some points I think we could make, in software engineering
terms:
 - more concise, readable code (like other functional languages, such as
Erlang, Scheme, Lisp)
 - sound theoretical foundation (language is well-defined and logical).
Code with side-effects is separated from purely functional code.
 - more reliable (no pointers, static type checking)
 - static type system superior to Java, C++, and C# - type inference
means it doesn't get in your way (I'd like to say something about how
the type system can reduce the amount of code you have to write through
good design of your data types and classes, but I don't know how...)
 - excellent integration with existing C code via one of the best FFI's
around
 - excellent support for concurrent and parallel programming
(forecasting the impending NDP implementation :-)
 - compilers generate fast code, in the same ballpark as C/C++
 - advanced testing tools like Quickcheck, plus the familiar xUnit clone
 - general purpose: can be used for servers, web-apps, desktop apps,
scripting


Alistair
*
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Albert Y. C. Lai

Don Stewart wrote:

It was raised at CUFP today that while Python has:

Python is a dynamic object-oriented programming language that can be
used for many kinds of software development. It offers strong
support for integration with other languages and tools, comes with
extensive standard libraries, and can be learned in a few days. Many
Python programmers report substantial productivity gains and feel
the language encourages the development of higher quality, more
maintainable code.

With the links from the start about using Python for various purposes,
along with reassuring text about licenses and so on. 


Note its all about how it can help you.


Many people invent and promote new programming languages because it is 
thought that they will improve productivity, reliability, 
maintainability, extensibility, evolvability, readability, writability, 
XXXivity, YYYbility, ...


Call me a skeptic, cynical, ivory-tower, completely detached, 
you-need-to-get-out-more academic, but since almost every programming 
language inventor gets to make such claims, or at least state such aims, 
they are bordering on becoming meaningless commercial buzzwords, like 
every company says and lies about "customers are number one!" Even if 
the claims are true, they are non-sequiturs because they're what 
programming languages are supposed to be! (Executability is very 
important too; are you going to emphasize it?) And are the claims ever 
true? I'm sure they're noble aims, but if anyone claims any of them is 
achieved, such as the Python statement claims productivity gains, I'll 
ask the Greg Wilson question: where is your data? And I'll add my own: 
do you just poll "feelings" or do you actually measure objective 
deliverables?


Granted, perhaps your perspective is, if every other company is shouting 
"customers are number one", then ours must too, and who actually lives 
up to it is the non-sequitur here. You're in the buzzword war, not the 
evidence war. OK, then make sure you include executability, as the 
Python guys in their infinite wisdom have forgotten that one. You'll 
trump them on that point, ha!


My point is, you want to say, "this language is about you". OK, that 
sounds right about "customers are number one", and we pretty know what 
that's about. If it's supposed to be false anyway, fine, you're saying 
it for a reason, so just copy every other company's silly buzzwords and 
throw in more silly buzzwords that even other companies have forgotten 
about. And if it's supposed to be true, do you have proof?


My academic, rational, technical-merit perspective is, we state Haskell 
for what it is. We state it has FFI. We state we have QuickCheck. We 
state it is purely functional, non-strict, monadic. If we suspect 
readers don't know those words, use some other words. Let the readers 
decide what these mean to their software engineering objectives. We 
don't claim software engineering objectives for them; we don't have data 
to prove any. The moment we refrain from unproved claims, we stand out 
from the snake oil salespeople. The moment we cut that "it's about you" 
crap, the moment we go back to the basics and say "this is our offer, 
take your time to consider it", that's when the whole business is truly 
about the readers.


To exemplify, I now analyze the Python statement under my glass:

"dynamic object-oriented": Good, informative, I know those words and I 
am the one to decide its implications to me.


"can be used for many kinds of software development": Informationless. 
Which major programming language can't be? It's OK to list, instead, in 
a subsequent paragraph a roster of the many kinds allured to.


"strong integration", "extensive libraries": Good, these are 
distinguishing technical offers, I want to know them.


"can be learned in a few days": Though this one isn't backed by studies, 
I won't call it bluff. This one is not a big deal. Unfortunately, 
Haskell is unlikely to be learned in a few days. Fortunately, Haskell is 
likely to revolutionize minds in a few days.


"Many Python programmers report substantial ...": Substantial claim it 
is. Snake oil, unless proved otherwise.

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


[Haskell-cafe] Re: [Haskell] reading from stdin

2007-10-05 Thread Reinier Lamers

Axel Simon wrote:


a) is the behaviour I want, but unfortunately for platform d)
b) must be due to ghci and Hugs having different opinions on whether
stdin should be line buffered or unbuffered
c) this is weird
d) this is broken

You can probably unify the behaviors of platforms a, b and c by calling 
hSetBuffering on stdin to turn off  buffering.


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