Re: [Haskell-cafe] Before

2007-07-03 Thread Henning Thielemann

On Mon, 2 Jul 2007, Jonathan Cast wrote:

> On Monday 02 July 2007, Andrew Coppin wrote:
> > What were monads like before they became a Haskell language construct?
> >
> > Is Haskell's idea of a "monad" actually anywhere close to the original
> > mathematical formalism?
> >
> > Just being randomly curiose...
>
> Curiosity can be a dangerous thing . . .
>
> Short answer: they're equivalent, or rather, Haskell monads are equivalent to
> what Haskellers would naturally write when translating mathematical monads
> into Haskell. ...

How about preserving that mail in a HaskellWiki article?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Re: Parsers are monadic?

2007-07-03 Thread Bulat Ziganshin
Hello Gregory,

Tuesday, July 3, 2007, 1:02:44 AM, you wrote:

> Right, I read more about it and found this out.  The 'main'
> function is apparently magical at runtime and allows you to break

i recommend you to read two htmls:
http://sigfpe.blogspot.com/2006/08/you-could-have-invented-monads-and.html
and http://haskell.org/haskellwiki/IO_inside


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Getting debugging/logging info?

2007-07-03 Thread Jules Bean

Hugh Perkins wrote:

In imperative languages we can do this type of thing:

SystemLogging.LogInfo("About to do something...");
DoSomething();
SystemLogging.LogInfo("Did Something");
SystemLogging.LogInfo("x is " + x );


This is what the Writer Monad is for, probably.

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


[Haskell-cafe] Haskell's "currying" versus Business Objects Gem Cutter's "burning"

2007-07-03 Thread peterv
In Haskell, currying can only be done on the last (rightmost) function
arguments.

 

So 

 

foo x y

 

can be curried as 

 

foo x

 

but not as 

 

foo ? y

 

where ? would be a "wilcard" for the x parameter.

 

In Haskell, one must write a new function

 

foo2  y x = foo x y

 

and then one can curry the x parameter like

 

foo2 y

 

In Gem Cutter - which is a visual programming language - on can "burn" any
input argument (which is like putting the ? for any argument in the foo
function). See
http://resources.businessobjects.com/labs/cal/gemcutter-techpaper.pdf

 

This burning looks more general to me, but cannot be done using the textual
approach?

 

Does this reasoning make any sense? 

 

Thanks,

Peter

 

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


Re: [Haskell-cafe] Haskell's "currying" versus Business Objects Gem Cutter's "burning"

2007-07-03 Thread Salvatore Insalaco

2007/7/3, peterv <[EMAIL PROTECTED]>:


 In Haskell, currying can only be done on the last (rightmost) function
arguments.


You can use "flip".
E.g. if you have foo x y, and you want use "foo ? y" in a map, you can just
write:

map (flip foo y) xs

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


Re: [Haskell-cafe] Haskell's "currying" versus Business Objects Gem Cutter's "burning"

2007-07-03 Thread Dougal Stanton

On 03/07/07, peterv <[EMAIL PROTECTED]> wrote:





In Haskell, currying can only be done on the last (rightmost) function
arguments.



So



foo x y



can be curried as



foo x



but not as



foo ? y



where ? would be a "wilcard" for the x parameter.



The function flip can be used in two-argument functions, if you only
have second argument but not the first:


function ??? arg2 -- this is what you mean
flip function arg2 -- this is how you write it


So for example


let nums = flip map [1..10]
nums (*2)

[2,4,6,8,10,12,14,16,18,20]

nums (subtract 1)

[0,1,2,3,4,5,6,7,8,9]

For the general situation of N arguments, I don't think there are any
predefined functions to help you. (After all, as N increases, the
number of variations of argument order gets rather silly.)

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


Re: [Haskell-cafe] Haskell's "partial application" (not currying!) versus Business Objects Gem Cutter's "burning"

2007-07-03 Thread Jules Bean

peterv wrote:
In Haskell, currying can only be done on the last (rightmost) function 
arguments.



You are talking about partial application, not currying.


foo x y

can be curried as

foo x

but not as

foo ? y

where ? would be a “wilcard” for the x parameter.


(\x -> foo x y)

[snip]

This burning looks more general to me, but cannot be done using the 
textual approach?


Well, it can be done, but basically there are two issues:

1. You need to demarquate the 'scope' of the ?. What 'lump' of 
expression is the partially evaluated part. An obvious way to do this is 
with parentheses, but you have to be careful.


2. If you have more than one ?, you need to remember which is which. 
Think of nested expressions, nested ?s. What if you want to use the 
'same' ? more than once?


The solution that haskell chooses to (2) is to 'label' the ?s with 
names. The solution to (1) is to mark the scope with a \, and the list 
of names bound:


\x z ->  foo (foo x y) z

Jules


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


Re: [Haskell-cafe] Haskell's

2007-07-03 Thread Peter Verswyvelen
Ah, thanks for the correction. So if I understand it correctly, this is 
currying:

when

f :: (a,b) -> c

then

g :: a -> (b,c)

is the curried form of f? So currying has to do with tuples? 

And partial application is just leaving away some tail arguments?






>- Oorspronkelijk bericht -
>Van: Jules Bean [mailto:[EMAIL PROTECTED]
>Verzonden: dinsdag, juli 3, 2007 12:19 PM
>Aan: 'peterv'
>CC: Haskell-Cafe@haskell.org
>Onderwerp: Re: [Haskell-cafe] Haskell's "partial application" (not currying!) 
>versus Business Objects Gem  Cutter's "burning"
>
>peterv wrote:
>> In Haskell, currying can only be done on the last (rightmost) function 
>> arguments.
>
>
>You are talking about partial application, not currying.
>
>> foo x y
>> 
>> can be curried as
>> 
>> foo x
>> 
>> but not as
>> 
>> foo ? y
>> 
>> where ? would be a “wilcard” for the x parameter.
>
>(\x -> foo x y)
>
>[snip]
>
>> This burning looks more general to me, but cannot be done using the 
>> textual approach?
>
>Well, it can be done, but basically there are two issues:
>
>1. You need to demarquate the 'scope' of the ?. What 'lump' of 
>expression is the partially evaluated part. An obvious way to do this is 
>with parentheses, but you have to be careful.
>
>2. If you have more than one ?, you need to remember which is which. 
>Think of nested expressions, nested ?s. What if you want to use the 
>'same' ? more than once?
>
>The solution that haskell chooses to (2) is to 'label' the ?s with 
>names. The solution to (1) is to mark the scope with a \, and the list 
>of names bound:
>
>\x z ->  foo (foo x y) z
>
>Jules
>
>
>
>


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


Re: [Haskell-cafe] Haskell's "currying" versus Business Objects Gem Cutter's "burning"

2007-07-03 Thread Bulat Ziganshin
Hello peterv,

Tuesday, July 3, 2007, 1:40:11 PM, you wrote:
> This burning looks more general to me, but cannot be done using the textual 
> approach?

it's just a matter of syntax :)

"foo ? bar" may be replaced with "\x -> foo x bar"

although i agree that "burning" syntax is useful. one problem that
arrives with it is where we should insert lambda


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Haskell's

2007-07-03 Thread Jules Bean

Peter Verswyvelen wrote:

Ah, thanks for the correction. So if I understand it correctly, this is 
currying:

when

f :: (a,b) -> c

then

g :: a -> (b,c)

is the curried form of f? So currying has to do with tuples? 



g :: a -> b -> c

(also could be written as g :: a -> (b -> c) )

is the curried form of f.

Curry has to do with the isomorphism between tuples, and 
functions-returning-functions.





And partial application is just leaving away some tail arguments?



Depending how generally you want to construe it; you might say "partial 
application is leaving off tail arguments" or "partial application is 
leaving off some arguments".


Currying makes partial application "easier".

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


Re: [Haskell-cafe] Haskell's

2007-07-03 Thread Henning Thielemann

On Tue, 3 Jul 2007, Peter Verswyvelen wrote:

> Ah, thanks for the correction. So if I understand it correctly, this is 
> currying:
>
> when
>
> f :: (a,b) -> c
>
> then
>
> g :: a -> (b,c)
>
> is the curried form of f?

No it is

g :: a -> b -> c
g = curry f

> So currying has to do with tuples?

Yes.

> And partial application is just leaving away some tail arguments?

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


Re: [Haskell-cafe] Haskell's

2007-07-03 Thread Ilya Tsindlekht
On Tue, Jul 03, 2007 at 10:53:33AM +, Peter Verswyvelen wrote:
> Ah, thanks for the correction. So if I understand it correctly, this is 
> currying:
> 
> when
> 
> f :: (a,b) -> c
> 
> then
> 
> g :: a -> (b,c)
g :: a->b->c
> 
> is the curried form of f? So currying has to do with tuples? 
> 
> And partial application is just leaving away some tail arguments?
> 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell's currying and partial application

2007-07-03 Thread Henning Thielemann

On Tue, 3 Jul 2007, Peter Verswyvelen wrote:

> Ah, thanks for the correction. So if I understand it correctly, this is 
> currying:

See also:
 http://haskell.org/haskellwiki/Currying
 http://haskell.org/haskellwiki/Partial_application

and more generally:
 http://haskell.org/haskellwiki/Category:Glossary
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Two-continuation `monads' and MonadMinus [Re: Parsers are monadic?]

2007-07-03 Thread oleg

When designing the full Kanren, we have experimented with
two-continuation actions and various plumbing combinators (any, all,
deterministic-all, etc). We eventually gave up on this after we
realized that a simple interface suffices. Called MonadMinus,
it is capable of defining LogicT monad with the true logical
negation as well as interleaving and committed choice. Our ICFP05
paper describes MonadMinus monad (actually, the transformer) and
LogicT as well as their two implementations. One of them uses success
and failure continuations, and the other is based on delimited
continuations. The latter offer an additional way to report
`out-of-band' errors and continue parsing after the error has been
`fixed'.

http://okmij.org/ftp/Computation/monads.html#LogicT

It is fair to say that whereas foldr/build and destroy/unfoldr fusion
techniques work for Haskell lists, msplit/reflect in the LogicT paper
is a fusion law for a general backtracking computation over arbitrary,
perhaps even strict, base monad. That computation may look nothing
like list; in fact, the LogicT paper gives an example with delimited
continuations, with abort playing the role of nil and shift the role
of cons.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell's currying and partial application

2007-07-03 Thread Peter Verswyvelen
Duh, I made a typo in my previous emails, I did mean a -> (b -> c) and not a -> 
(b,c). But you guys quickly corrected that

IMHO when reading

http://haskell.org/haskellwiki/Currying

a newbie like me cannot see the difference between currying and partial 
application...

I quote the text:



"Currying is the process of transforming a function that takes multiple 
arguments into a function that takes just a single argument and returns another 
function if any arguments are still needed. In Haskell, all functions are 
considered curried: that is, all functions in Haskell take just single 
arguments.

This is mostly hidden in notation, and so may not be apparent to a new 
Haskeller. Let's take the function

div :: Int -> Int -> Int

which performs integer division. The expression div 11 2 unsurprisingly 
evaluates to 5. But there's more that's going on than immediately meets the 
untrained eye. It's a two-part process. First,

div 11

is evaluated and returns a function of type

Int -> Int"



But that is partial application, not currying no... Later in the text tuples 
are mentioned, but the real definition of currying being

-- Hope I get it right this time...
curry :: ((a, b) -> c) -> a -> b -> c

is not really clear from the article to me...




>- Oorspronkelijk bericht -
>Van: Henning Thielemann [mailto:[EMAIL PROTECTED]
>Verzonden: dinsdag, juli 3, 2007 01:48 PM
>Aan: 'Peter Verswyvelen'
>CC: Haskell-Cafe@haskell.org
>Onderwerp: Re:  [Haskell-cafe] Haskell's currying and partial application
>
>
>On Tue, 3 Jul 2007, Peter Verswyvelen wrote:
>
>> Ah, thanks for the correction. So if I understand it correctly, this is 
>> currying:
>
>See also:
> http://haskell.org/haskellwiki/Currying
> http://haskell.org/haskellwiki/Partial_application
>
>and more generally:
> http://haskell.org/haskellwiki/Category:Glossary
>
>


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


Re: [Haskell-cafe] Haskell's currying and partial application

2007-07-03 Thread Henning Thielemann

On Tue, 3 Jul 2007, Peter Verswyvelen wrote:

> IMHO when reading
>
> http://haskell.org/haskellwiki/Currying
>
> a newbie like me cannot see the difference between currying and partial 
> application...

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


Re: [Haskell-cafe] Haskell's currying and partial application

2007-07-03 Thread Jules Bean

Henning Thielemann wrote:

On Tue, 3 Jul 2007, Peter Verswyvelen wrote:


IMHO when reading

http://haskell.org/haskellwiki/Currying

a newbie like me cannot see the difference between currying and partial 
application...


Better now?


Much better, IMO, although I still don't like the part with four 
examples of sections. Sure, sections are cool but they have nothing much 
to do with currying. Even if our binary operators were defined 
uncurried, we could have identical syntactic sugar for sections...


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


Re: [Haskell-cafe] Before

2007-07-03 Thread Jonathan Cast
On Tuesday 03 July 2007, you wrote:
> On Mon, 2 Jul 2007, Jonathan Cast wrote:
> > On Monday 02 July 2007, Andrew Coppin wrote:
> > > What were monads like before they became a Haskell language construct?
> > >
> > > Is Haskell's idea of a "monad" actually anywhere close to the original
> > > mathematical formalism?
> > >
> > > Just being randomly curiose...
> >
> > Curiosity can be a dangerous thing . . .
> >
> > Short answer: they're equivalent, or rather, Haskell monads are
> > equivalent to what Haskellers would naturally write when translating
> > mathematical monads into Haskell. ...
>
> How about preserving that mail in a HaskellWiki article?

I should not that doing this makes the monad-free web particularly 
hilarious . . .

http://saxophone.jpberlin.de/MonadTransformer?source=http%3A%2F%2Fwww%2Ehaskell%2Eorg%2Fhaskellwiki%2FCategory%5Ftheory%2FMonads&language=English

-- 
Sincerely,
Jonathan Cast
Computer Programmer
http://sourceforge.net/projects/fid-core
http://sourceforge.net/projects/fid-emacs
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Before

2007-07-03 Thread Jonathan Cast
On Tuesday 03 July 2007, you wrote:
> On Mon, 2 Jul 2007, Jonathan Cast wrote:
> > On Monday 02 July 2007, Andrew Coppin wrote:
> > > What were monads like before they became a Haskell language construct?
> > >
> > > Is Haskell's idea of a "monad" actually anywhere close to the original
> > > mathematical formalism?
> > >
> > > Just being randomly curiose...
> >
> > Curiosity can be a dangerous thing . . .
> >
> > Short answer: they're equivalent, or rather, Haskell monads are
> > equivalent to what Haskellers would naturally write when translating
> > mathematical monads into Haskell. ...
>
> How about preserving that mail in a HaskellWiki article?

Done.  The wiki already has pages on categories and natural transformations 
(but not functors?!?):

http://haskell.org/haskellwiki/Category_theory
http://haskell.org/haskellwiki/Category_theory/Natural_transformation

with links to (non-existent) pages on functors and monads; I filled in 
skeleton functor and monad pages

http://haskell.org/haskellwiki/Category_theory/Functor
http://haskell.org/haskellwiki/Category_theory/Monads

including everything in my email but not in the category or natural 
transformation pages.

Jonathan Cast
http://sourceforge.net/projects/fid-core
http://sourceforge.net/projects/fid-emacs
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Sparse documentation

2007-07-03 Thread Andrew Coppin
Is there a reason why the documentation for virtually every module in 
Control.Monad simply begins with a line that says


 "Inspired by some paper (http://www.ogi.edu/csee/~mpj/)"

and then just shows you a bunch of type signatures, without telling you 
*anything* about what the module is supposed to be for, or what all 
these classes, types, methods and functions are meant to *do*?


I'm currently struggling with a really knotty problem, and the last 
thing I need is unhelpful documentation. :-S


(Did I mention that that URL goes nowhere?)

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


Re: [Haskell-cafe] Sparse documentation

2007-07-03 Thread Brent Yorgey

Is there a reason why the documentation for virtually every module in
Control.Monad simply begins with a line that says

  "Inspired by some paper (http://www.ogi.edu/csee/~mpj/)"



It's probably because it was felt that the paper itself is better
documentation than anything that could be written in the comments.  Of
course, this may or may not be actually true.  It just seems to be a
particular quirk of the way the Haskell community generates, disseminates,
and consumes information.

Is there a particular module you're having trouble with?  Or just griping in
general? =)

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


Re: [Haskell-cafe] Before

2007-07-03 Thread Henning Thielemann

On Tue, 3 Jul 2007, Jonathan Cast wrote:

> On Tuesday 03 July 2007, you wrote:
> >
> > How about preserving that mail in a HaskellWiki article?
>
> Done.  The wiki already has pages on categories and natural transformations
> (but not functors?!?):
>
> http://haskell.org/haskellwiki/Category_theory
> http://haskell.org/haskellwiki/Category_theory/Natural_transformation
>
> with links to (non-existent) pages on functors and monads; I filled in
> skeleton functor and monad pages
>
> http://haskell.org/haskellwiki/Category_theory/Functor
> http://haskell.org/haskellwiki/Category_theory/Monads
>
> including everything in my email but not in the category or natural
> transformation pages.

Great work! It's now much nicer to read than the e-mail.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] Haskell's currying and partial application

2007-07-03 Thread Peter Verswyvelen
Much better. Although I struggle a bit with the exercises ;)

Let's see

id :: a -> a

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

=> curry id :: ((a,b) -> (a,b)) -> a -> b -> (a,b)

So basically if 

f = curry id 

then

f x y = (x,y)

which means

curry id = (,)

something like this?

Do I win a price now? ;)











-Original Message-
From: Henning Thielemann [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 03, 2007 3:21 PM
To: Peter Verswyvelen
Cc: Haskell-Cafe@haskell.org
Subject: Re: [Haskell-cafe] Haskell's currying and partial application


On Tue, 3 Jul 2007, Peter Verswyvelen wrote:

> IMHO when reading
>
> http://haskell.org/haskellwiki/Currying
>
> a newbie like me cannot see the difference between currying and partial
application...

Better now?

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


Re: [Haskell-cafe] Sparse documentation

2007-07-03 Thread Tim Newsham

Is there a particular module you're having trouble with?  Or just griping in
general? =)


How about STM?  It would be nice if I didn't have to scan the paper each 
time I do something with STM.  Isn't that the point of having an API 
reference?



-Brent


Tim Newsham
http://www.thenewsh.com/~newsham/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] Haskell's currying and partial application

2007-07-03 Thread Henning Thielemann

On Tue, 3 Jul 2007, Peter Verswyvelen wrote:

> Let's see
>
> id :: a -> a
>
> curry :: ((a,b) -> c) -> a -> b -> c
>
> => curry id :: ((a,b) -> (a,b)) -> a -> b -> (a,b)
>
> So basically if
>
> f = curry id
>
> then
>
> f x y = (x,y)
>
> which means
>
> curry id = (,)
>
> something like this?

You got it!

> Do I win a price now? ;)

I hoped that nobody would care about the puzzle, thus I have not thought
about a price so far. :-]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Sparse documentation

2007-07-03 Thread Duncan Coutts
On Tue, 2007-07-03 at 15:11 -0400, Brent Yorgey wrote:
> 
> Is there a reason why the documentation for virtually every
> module in
> Control.Monad simply begins with a line that says
> 
>   "Inspired by some paper (http://www.ogi.edu/csee/~mpj/)"
> 
> It's probably because it was felt that the paper itself is better
> documentation than anything that could be written in the comments.  Of
> course, this may or may not be actually true.  It just seems to be a
> particular quirk of the way the Haskell community generates,
> disseminates, and consumes information. 

Actually, the code was documented in comments in the code, just not in
haddock format. :-(

Fortunately, some kind soul has gone through and converted the
documentation to haddock format:
http://hackage.haskell.org/trac/ghc/ticket/1410

So it'll all appear in the html docs in the next version. In the mean
time one can look at the haddock comments in the source:
http://darcs.haskell.org/packages/mtl/Control/Monad/

Duncan


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


Re: [Haskell-cafe] Sparse documentation

2007-07-03 Thread Claus Reinke
the references have not been updated, it seems. but once you've 
used the name "Mark P Jones", mentioned next to the link, to 
google for a current url for his publications page, you'll


(a) find a treasure-trove of haskell papers
   http://web.cecs.pdx.edu/~mpj/

(b) be able to submit a fix for the documentation bug to the
   library maintainer, which 'ghc-pkg describe mtl' lists as
   [EMAIL PROTECTED]

(c) indicate to the maintainer what additional information 
   you would find helpful in the haddocks, and perhaps help

   to get it there (several libraries have acquired more directly
   useful haddocks this way, including parts of the monad libs,
   with the permission of paper and tutorial authors, but there 
   are still quite a few gaps waiting to be filled)


(did i mention that putting bug reports in parentheses in emails
is not the best way to attract attention, get the bug recorded, 
or fixed?-)


claus

- Original Message - 
From: "Andrew Coppin" <[EMAIL PROTECTED]>

To: 
Sent: Tuesday, July 03, 2007 7:38 PM
Subject: [Haskell-cafe] Sparse documentation


Is there a reason why the documentation for virtually every module in 
Control.Monad simply begins with a line that says


 "Inspired by some paper (http://www.ogi.edu/csee/~mpj/)"

and then just shows you a bunch of type signatures, without telling you 
*anything* about what the module is supposed to be for, or what all 
these classes, types, methods and functions are meant to *do*?


I'm currently struggling with a really knotty problem, and the last 
thing I need is unhelpful documentation. :-S


(Did I mention that that URL goes nowhere?)

___
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] sha1 implementation thats "only" 12 times slower then C

2007-07-03 Thread Anatoly Yakovenko

inlining some of the functions definitely gave me a boost, so i am
about 8.5 times slower then openssl sha1sum.  I dont really understand
the core output, but after inlining i got a completely different
profile output, i am guessing its because the cost of the inlined
functions is spread to the callers.

COST CENTREMODULE   %time %alloc

updateElem SHA1  13.40.0
sRotateL   SHA1  13.40.0
hashElem   SHA1  12.50.0
sXor   SHA1  10.90.0
unboxW SHA1  10.00.0
temp   SHA1   8.10.0
sAdd   SHA1   7.80.0
sAnd   SHA1   5.00.0
do20   SHA1   4.1   18.0
hashA16IntoA80 SHA1   2.80.9
do60   SHA1   2.5   18.0
splitByN   SHA1   2.2   15.6
ffkk   SHA1   2.20.0
sOrSHA1   1.60.0
do40   SHA1   0.9   18.0
hashPtrIntoA80 SHA1   0.62.7
hashA80SHA1   0.61.8
do80   SHA1   0.6   18.0
joinTail   SHA1   0.02.1
main   Main   0.04.8


On 6/30/07, Donald Bruce Stewart <[EMAIL PROTECTED]> wrote:

aeyakovenko:
> So I tried implementing a more efficient sha1 in haskell, and i got to
> about 12 times slower as C.  The darcs implementation is also around
> 10 to 12 times slower, and the crypto one is about 450 times slower.
> I haven't yet unrolled the loop like the darcs implementation does, so
> I can still get some improvement from that, but I want that to be the
> last thing i do.
>
> I think I've been getting speed improvements when minimizing
> unnecessary allocations.  I went from 40 times slower to 12 times
> slower by converting a foldM to a mapM that modifies a mutable array.
>
> Anyone have any pointers on how to get hashElem and updateElem to run
> faster, or any insight on what exactly they are allocating.  To me it
> seems that those functions should be able to do everything they need
> to without a malloc.

Try inlining key small functions, and check the core.

-O2 -ddump-simpl | less

-- Don


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


Re: [Haskell-cafe] Sparse documentation

2007-07-03 Thread Spencer Janssen
On Tue, 3 Jul 2007 09:23:02 -1000 (HST)
Tim Newsham <[EMAIL PROTECTED]> wrote:

> How about STM?  It would be nice if I didn't have to scan the paper
> each time I do something with STM.  Isn't that the point of having an
> API reference?
> 
> > -Brent
> 
> Tim Newsham
> http://www.thenewsh.com/~newsham/

What is missing in STM's documentation?  TArray, TChan, TMVar have just
as much documentation as their non-transactional counterparts.  The
documentation for TVar and STM is also available, but perhaps more
difficult to find.  Note that Control.Concurrent.STM.TVar (similarly
Control.Monad.STM) does not have any documentation on the page, but
each identifier is a link to GHC specific modules that give more
documentation.  This is a bug in Haddock: it doesn't know how to
include documentation from another package.


Cheers,
Spencer Janssen


Documentation:
http://www.haskell.org/ghc/docs/latest/html/libraries/stm/Control-Concurrent-STM-TVar.html
http://www.haskell.org/ghc/docs/latest/html/libraries/base/GHC-Conc.html#t%3ATVar

http://www.haskell.org/ghc/docs/latest/html/libraries/stm/Control-Monad-STM.html
http://www.haskell.org/ghc/docs/latest/html/libraries/base/GHC-Conc.html#t%3ASTM

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


Re: [Haskell-cafe] Sparse documentation

2007-07-03 Thread Andrew Coppin

Tim Newsham wrote:
Is there a particular module you're having trouble with?  Or just 
griping in

general? =)


How about STM?  It would be nice if I didn't have to scan the paper 
each time I do something with STM.  Isn't that the point of having an 
API reference?


Similar remarks hold for Parsec. The online manual is very well done, 
and I learned the thing easily and painlessly. But the online 
documentation is one 1,000 mile long HTML page. On the other hand, the 
nicely browsable API docs contain virtually nothing except the type 
signatures...


On the one hand, in Haskell (unlike any other language I've ever seen) 
you can often *almost* tell what something does just form the type. 
(Pretty amazing, really.) OTOH, sometimes you can't...


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


Re: [Haskell-cafe] Sparse documentation

2007-07-03 Thread Andrew Coppin

Brent Yorgey wrote:


Is there a reason why the documentation for virtually every module in
Control.Monad simply begins with a line that says

  "Inspired by some paper (http://www.ogi.edu/csee/~mpj/
)"


It's probably because it was felt that the paper itself is better 
documentation than anything that could be written in the comments.  Of 
course, this may or may not be actually true.  It just seems to be a 
particular quirk of the way the Haskell community generates, 
disseminates, and consumes information.


It's probably damn useful to have the paper *as well*. You know, for 
some context, a nice overview, introductory material, etc. (I mean, if 
the link worked...)


It's also nice to have some brief comments in the API docs to say what 
the heck a particular module is even *for*, and provide enough info on 
the stuff in that module that you can quickly dip into it when you can't 
remember the name of something...


Is there a particular module you're having trouble with?  Or just 
griping in general? =)


After many hours tying my brain in knots, I *think* I need to use a 
monad transformer... but I've never ever done that before. So I'd like 
to learn how it works. (And then I'd like to figure out what standard 
monads are out there and what they do.) But the docs aren't helping me 
greatly in this regard. (I notice the Wiki is also somewhat devoid of 
any material on this subject...)


Essentially I want to run a parser on top of a parser, and I think maybe 
this is the way to do it.


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


Re: [Haskell-cafe] Sparse documentation

2007-07-03 Thread Brent Yorgey

It's also nice to have some brief comments in the API docs to say what
the heck a particular module is even *for*, and provide enough info on
the stuff in that module that you can quickly dip into it when you can't
remember the name of something...



I certainly don't disagree with you!  I was just commenting on the tendency
of the community to document things in academic papers.  But I'm glad to
hear from Duncan that better Haddock documentation will be in the next
version of the libraries.

After many hours tying my brain in knots, I *think* I need to use a

monad transformer... but I've never ever done that before. So I'd like
to learn how it works.



Try http://uebb.cs.tu-berlin.de/~magr/pub/Transformers.en.html.  I found
that paper very clear and helpful in learning to use monad transformers.
Then you will probably also want to read
http://cale.yi.org/index.php/How_To_Use_Monad_Transformers.

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


Re: [Haskell-cafe] Getting debugging/logging info?

2007-07-03 Thread Hugh Perkins

Ok, I'll play with that.

On 7/3/07, Jules Bean <[EMAIL PROTECTED]> wrote:


Hugh Perkins wrote:
> In imperative languages we can do this type of thing:
>
> SystemLogging.LogInfo("About to do something...");
> DoSomething();
> SystemLogging.LogInfo("Did Something");
> SystemLogging.LogInfo("x is " + x );

This is what the Writer Monad is for, probably.

Jules

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


Re: [Haskell-cafe] sha1 implementation thats "only" 12 times slower then C

2007-07-03 Thread Alistair Bayley

On 03/07/07, Anatoly Yakovenko <[EMAIL PROTECTED]> wrote:

inlining some of the functions definitely gave me a boost, so i am
about 8.5 times slower then openssl sha1sum.  I dont really understand
the core output, but after inlining i got a completely different
profile output, i am guessing its because the cost of the inlined
functions is spread to the callers.


Are you using -auto, or -auto-all? Because it makes a difference to
the generated core, and the extent to which inlining takes place. I've
noticed that -auto permits more inlining than -auto-all, so try -auto
if you can. Also, follow the advice in the GHC manual, and only export
the functions you need to. This will aid both the inliner and
specialiser enormously.

As for reading core (well, actually simplifier output; core has less
"punctuation"), these links might help:

4.16.3. How to read Core syntax
http://www.haskell.org/ghc/docs/latest/html/users_guide/options-debugging.html#id3130643

(and the Encoding module has the actual rules for the Unique names)
http://darcs.haskell.org/ghc/compiler/utils/Encoding.hs

6.2. Faster: producing a program that runs quicker
http://www.haskell.org/ghc/docs/latest/html/users_guide/faster.html
(see "How do I find out a function's strictness?")

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


Re: [Haskell-cafe] sha1 implementation thats "only" 12 times slower then C

2007-07-03 Thread Anatoly Yakovenko

Are you using -auto, or -auto-all? Because it makes a difference to
the generated core, and the extent to which inlining takes place. I've
noticed that -auto permits more inlining than -auto-all, so try -auto


-auto doesn't generate any meaningfull profiling info for me


if you can. Also, follow the advice in the GHC manual, and only export
the functions you need to. This will aid both the inliner and
specialiser enormously.


cool, this actually helped quite a bit, now only 7.5 times slower :)



As for reading core (well, actually simplifier output; core has less
"punctuation"), these links might help:

4.16.3. How to read Core syntax
http://www.haskell.org/ghc/docs/latest/html/users_guide/options-debugging.html#id3130643

(and the Encoding module has the actual rules for the Unique names)
http://darcs.haskell.org/ghc/compiler/utils/Encoding.hs

6.2. Faster: producing a program that runs quicker
http://www.haskell.org/ghc/docs/latest/html/users_guide/faster.html
(see "How do I find out a function's strictness?")


thanks for the tip, ill take a look at those.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] sha1 implementation thats "only" 12 times slower then C

2007-07-03 Thread Donald Bruce Stewart
aeyakovenko:
> inlining some of the functions definitely gave me a boost, so i am
> about 8.5 times slower then openssl sha1sum.  I dont really understand
> the core output, but after inlining i got a completely different
> profile output, i am guessing its because the cost of the inlined
> functions is spread to the callers.
> 
> COST CENTREMODULE   %time %alloc
> 
> updateElem SHA1  13.40.0
> sRotateL   SHA1  13.40.0
> hashElem   SHA1  12.50.0
> sXor   SHA1  10.90.0
> unboxW SHA1  10.00.0

So I'd now dive in and seriously look at the Core for these guys.
Work out what they're doing, and how they differ from the C version.

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


Re: [Haskell-cafe] Sparse documentation

2007-07-03 Thread brad clawsie
> It's also nice to have some brief comments in the API docs to say what the 
> heck a particular module is even *for*, and provide enough info on the 
> stuff in that module that you can quickly dip into it when you can't 
> remember the name of something...

agreed. 

for me, the perldocs for most of the well-used perl packages are the
gold standard. do a perldoc on the LWP or DBI modules, for example.

i often find myself using a combination of the api docs and the zvon
reference. examples are essential. it would be nice to merge these two
documentation sources. from

http://zvon.org/index.php?nav_id=legal&mime=html

i see that zvon employs a form of bsd (attribution) license

of course if i can help improve documentation, let me know. its one
thing that novice/hobbyist haskellers can contribute effectively

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


Re: [Haskell-cafe] Haskell's "currying" versus Business Objects GemCutter's "burning"

2007-07-03 Thread L.Guo
In this case, I usually use _flip_ function.

flip :: (a -> b -> c) -> b -> a -> c
flip f x y = f y x

--   
L.Guo
2007-07-04

-
From: peterv
At: 2007-07-03 17:40:35
Subject: [Haskell-cafe] Haskell's "currying" versus Business Objects 
GemCutter's "burning"

In Haskell, currying can only be done on the last (rightmost) function 
arguments.


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


[Haskell-cafe] The Garbage Collector Ate My Homework

2007-07-03 Thread Thomas Conway

Well, not quite, but look at the following:

118,342,689,824 bytes allocated in the heap
144,831,738,780 bytes copied during GC (scavenged)
335,086,064 bytes copied during GC (not scavenged)
255,257,516 bytes maximum residency (42 sample(s))

222884 collections in generation 0 (3891.90s)
42 collections in generation 1 (153.99s)

   536 Mb total memory in use

 INIT  time0.00s  (  0.00s elapsed)
 MUT   time  233.66s  (776.99s elapsed)
 GCtime  4045.89s  (4251.52s elapsed)
 EXIT  time0.00s  (  0.00s elapsed)
 Total time  4279.55s  (5028.52s elapsed)

 %GC time  94.5%  (84.5% elapsed)

 Alloc rate506,470,897 bytes per MUT second

 Productivity   5.5% of total user, 4.6% of total elapsed

Can anyone offer general suggestions for how to fix this!

T.
--
Dr Thomas Conway
[EMAIL PROTECTED]

Silence is the perfectest herald of joy:
I were but little happy, if I could say how much.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The Garbage Collector Ate My Homework

2007-07-03 Thread Tim Chevalier

On 7/3/07, Thomas Conway <[EMAIL PROTECTED]> wrote:

Well, not quite, but look at the following:

118,342,689,824 bytes allocated in the heap
144,831,738,780 bytes copied during GC (scavenged)
335,086,064 bytes copied during GC (not scavenged)
255,257,516 bytes maximum residency (42 sample(s))

 222884 collections in generation 0 (3891.90s)
 42 collections in generation 1 (153.99s)

536 Mb total memory in use

  INIT  time0.00s  (  0.00s elapsed)
  MUT   time  233.66s  (776.99s elapsed)
  GCtime  4045.89s  (4251.52s elapsed)
  EXIT  time0.00s  (  0.00s elapsed)
  Total time  4279.55s  (5028.52s elapsed)

  %GC time  94.5%  (84.5% elapsed)

  Alloc rate506,470,897 bytes per MUT second

  Productivity   5.5% of total user, 4.6% of total elapsed

Can anyone offer general suggestions for how to fix this!



Are you compiling with -O2? Besides that, there's not too much we can
say without either seeing your code, or the results of profiling when
you compile with -prof -auto-all, or both.

Cheers,
Tim

--
Tim Chevalier* catamorphism.org *Often in error, never in doubt
"There are no difficult problems, just unfortunate notations."  --
Alfonso Gracia-Saz
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The Garbage Collector Ate My Homework

2007-07-03 Thread Stefan O'Rear
On Wed, Jul 04, 2007 at 03:56:20PM +1000, Thomas Conway wrote:
> Well, not quite, but look at the following:
> 
> 118,342,689,824 bytes allocated in the heap
> 144,831,738,780 bytes copied during GC (scavenged)
> 335,086,064 bytes copied during GC (not scavenged)
> 255,257,516 bytes maximum residency (42 sample(s))
> 
> 222884 collections in generation 0 (3891.90s)
> 42 collections in generation 1 (153.99s)
> 
>536 Mb total memory in use
> 
>  INIT  time0.00s  (  0.00s elapsed)
>  MUT   time  233.66s  (776.99s elapsed)
>  GCtime  4045.89s  (4251.52s elapsed)
>  EXIT  time0.00s  (  0.00s elapsed)
>  Total time  4279.55s  (5028.52s elapsed)
> 
>  %GC time  94.5%  (84.5% elapsed)
> 
>  Alloc rate506,470,897 bytes per MUT second
> 
>  Productivity   5.5% of total user, 4.6% of total elapsed
> 
> Can anyone offer general suggestions for how to fix this!

The fact that so many collections occured in the nursery suggests that
you are creating a huge amount of temporary objects and immediately
throwing them away.  This is expected if the strictness analyser is
disabled by not enabling optimizations.  Passing -funbox-strict-fields
may help.  Otherwise, as Tim says, your best bet is to post a profile.

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


Re: [Haskell-cafe] The Garbage Collector Ate My Homework

2007-07-03 Thread Tim Chevalier

[I assume this was meant to go to the list as well, so I'm adding it
back to the CCs]

On 7/3/07, Thomas Conway <[EMAIL PROTECTED]> wrote:

It occurs to me that tweaking the GC parameters can probably make a
big difference: is starting with a bigger heap likely to help, or more
generations? My generation hypothesis is that more generations will
encourage the cached data to drop down out of generation 0, reducing
the GC load.



Starting with a bigger heap is likely to help, since it means that GCs
will be needed less often. I'm not sure I buy your generation
hypothesis, because even with two generations, you would expect to see
some of the cached data move to generation 1. Lots of data in
generation 0 implies your code continues to allocate many objects as
it goes on running. On the other hand, you could still try and see if
it helps.

Cheers,
Tim

--
Tim Chevalier* catamorphism.org *Often in error, never in doubt
"The illegal we do immediately. The unconstitutional takes a little
longer."  -- Henry Kissinger
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe