Re: [Haskell-cafe] Dynamic thread management?

2007-08-13 Thread Mitar
Hi! I am thinking about a model where you would have only n threads on a n-core (or processor) machine. They would be your worker threads and you would spawn them only once (at the beginning of the program) and then just delegate work between them. On 8/13/07, Jan-Willem Maessen [EMAIL

Re: [Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread Andrew Coppin
Stefan O'Rear wrote: Also, large numbers don't (this is arguably a bug...) have restricted types: [EMAIL PROTECTED]:~$ ghc -e '100 :: Int' -1486618624 So many other programming languages allow weird things to happen with numeric overflows... it would be nice if Haskell

[Haskell-cafe] out of core computing in haskell

2007-08-13 Thread Carter T Schonwald
Hello Everyone, I'm not quite sure if I'm posing this question correctly, but what facilities currently exist in haskell to nicely deal with datastructures that won't fit within a given machine's ram? And if there are no such facilities, what would it take to fix that? thanks -Carter

Re: [Haskell-cafe] out of core computing in haskell

2007-08-13 Thread Stefan O'Rear
On Mon, Aug 13, 2007 at 12:29:25PM -0700, Carter T Schonwald wrote: Hello Everyone, I'm not quite sure if I'm posing this question correctly, but what facilities currently exist in haskell to nicely deal with datastructures that won't fit within a given machine's ram? And if there are no

Re: [Haskell-cafe] out of core computing in haskell

2007-08-13 Thread Andrew Coppin
Carter T Schonwald wrote: Hello Everyone, I'm not quite sure if I'm posing this question correctly, but what facilities currently exist in haskell to nicely deal with datastructures that won't fit within a given machine's ram? And if there are no such facilities, what would it take to fix

Re: [Haskell-cafe] Dynamic thread management?

2007-08-13 Thread Jan-Willem Maessen
On Aug 13, 2007, at 2:53 PM, Mitar wrote: Hi! I am thinking about a model where you would have only n threads on a n-core (or processor) machine. They would be your worker threads and you would spawn them only once (at the beginning of the program) and then just delegate work between them.

Re: [Haskell-cafe] out of core computing in haskell

2007-08-13 Thread Carter T Schonwald
The main two use cases I have in mind are 1) really really really big abstract syntax trees or proof trees (a la compilers or theorem provers) 2) random access to numerical data does that help clarify what i'm asking about? In each case, is there a standard way of dealing with this? in the

[Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Benjamin Franksen
Brian Brunswick wrote: One thing that I keep seeing people say (not you), is that monads /sequence/ side effects. This is wrong, or at least a limited picture. /All/ of the above structures are about combining compatible things things together in a row. /None/ of them force any particular

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Brandon S. Allbery KF8NH
On Aug 13, 2007, at 16:29 , Benjamin Franksen wrote: Let's take the simplest example: Maybe. The effect in question is the premature abortion of a computation (when Nothing is returned). And of course Maybe sequences these effects, that's what you use it for: the _first_ action to be

[Haskell-cafe] Re: Help with a project design

2007-08-13 Thread Benjamin Franksen
Andrea Rossato wrote: The task this library should do is simple: given an xml object (representing a bibliographic reference), render it with rules stored in a different xml object (the citation style). While I think I can find solutions for this problem - the rendering -, what I find

Re: [Haskell-cafe] Re: Language support for imperative code. Was: Re: monad subexpressions

2007-08-13 Thread Brian Hulley
Brian Hulley wrote: apfelmus wrote: Brian Hulley schrieb: main = do buffer - createBuffer edit1 - createEdit buffer edit2 - createEdit buffer splitter - createSplitter (wrapWidget edit1) (wrapWidget edit2) runMessageLoopWith splitter

Re: [Haskell-cafe] out of core computing in haskell

2007-08-13 Thread David Roundy
In the second case, if your numerical data is just a big array, why not just mmap it? Unless you're running on a 32 bit machine, or have a *seriously* large amount of data, that seems like the easiest option. Although if you're talking about mutable data, that's a whole 'nother can of worms... but

Re: [Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread Isaac Dupree
Andrew Coppin wrote: Stefan O'Rear wrote: Also, large numbers don't (this is arguably a bug...) have restricted types: [EMAIL PROTECTED]:~$ ghc -e '100 :: Int' -1486618624 So many other programming languages allow weird things to happen with numeric overflows... it would

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread David Roundy
On Mon, Aug 13, 2007 at 05:13:01PM -0400, Brandon S. Allbery KF8NH wrote: On Aug 13, 2007, at 16:29 , Benjamin Franksen wrote: Let's take the simplest example: Maybe. The effect in question is the premature abortion of a computation (when Nothing is returned). And of course Maybe sequences

Re: [Haskell-cafe] Re: Language support for imperative code. Was: Re: monad subexpressions

2007-08-13 Thread Isaac Dupree
Brian Hulley wrote: Thinking about this a bit more, and just so this thought is recorded for posterity (!) and for the benefit of anyone now or in a few hundred years time, trying to solve Fermat's last GUI, the object oriented solution allows the buffer object to do anything it wants, so that

[Haskell-cafe] Re: Re: Language support for imperative code. Was: Re: monad subexpressions

2007-08-13 Thread Benjamin Franksen
Brian Hulley wrote: Brian Hulley wrote: apfelmus wrote: Brian Hulley schrieb: main = do buffer - createBuffer edit1 - createEdit buffer edit2 - createEdit buffer splitter - createSplitter (wrapWidget edit1) (wrapWidget edit2)

[Haskell-cafe] Re: Re: Explaining monads

2007-08-13 Thread Benjamin Franksen
Brandon S. Allbery KF8NH wrote: On Aug 13, 2007, at 16:29 , Benjamin Franksen wrote: Let's take the simplest example: Maybe. The effect in question is the premature abortion of a computation (when Nothing is returned). And of course Maybe sequences these effects, that's what you use it for:

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Tillmann Rendel
David Roundy wrote: It's the *effect* of a monad, not the *side* effect. The type of = defines this dependency. And when you have a chain of dependencies, that is sometimes referred to as a sequence. True, it's not mystical, but it's still sequenced. How can a Haskell type define a data

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Brian Brunswick
On 13/08/07, David Roundy [EMAIL PROTECTED] wrote: Try executing: do { x - return 2; undefined; return (x*x); } in any monad you like, and you'll find that regardless of the *data* dependencies (the return value of this monadic action is unambiguous), the undefined is evaluated *before*

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Derek Elkins
On Mon, 2007-08-13 at 22:29 +0200, Benjamin Franksen wrote: Brian Brunswick wrote: One thing that I keep seeing people say (not you), is that monads /sequence/ side effects. This is wrong, or at least a limited picture. /All/ of the above structures are about combining compatible

Re: [Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread Sebastian Sylvan
On 13/08/07, Pekka Karjalainen [EMAIL PROTECTED] wrote: On 8/13/07, L.Guo [EMAIL PROTECTED] wrote: Hi All: Hello, I am reading http://www.haskell.org/haskellwiki/Prime_numbers The code in sector 1 Bitwise prime sieve. I have 3 questions about it. 1) In function go, what does

RE: [Haskell-cafe] Explaining monads

2007-08-13 Thread Derek Elkins
On Mon, 2007-08-13 at 19:31 +0200, peterv wrote: When I read side-effects, I understand it as unwanted effects, like aliasing, and effects depending on the order of execution. I'm not sure if my understanding here is correct. I hope Haskell does not allow side-effects but only effects, meaning

Re: [Haskell-cafe] Re: Re: Language support for imperative code. Was: Re: monad subexpressions

2007-08-13 Thread Isaac Dupree
Benjamin Franksen wrote: I'd be careful. Introducing a network connection into the equation makes the object (its methods) susceptible to a whole new bunch of failure modes; think indefinite delays, connection loss, network buffer overflow, etc etc. It may be a mistake to abstract all that away;

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Dan Piponi
On 8/13/07, David Roundy [EMAIL PROTECTED] wrote: Try executing: do { x - return 2; undefined; return (x*x); } in any monad you like instance Monad M where return a = M a ~(M a) = f = f a Or is that cheating? -- Dan ___ Haskell-Cafe

Re: [Haskell-cafe] Re: Re: Language support for imperative code. Was: Re: monad subexpressions

2007-08-13 Thread Donn Cave
On Tue, 14 Aug 2007, Benjamin Franksen wrote: ... I'd be careful. Introducing a network connection into the equation makes the object (its methods) susceptible to a whole new bunch of failure modes; think indefinite delays, connection loss, network buffer overflow, etc etc. It may be a mistake

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Arie Peterson
On 8/13/07, David Roundy [EMAIL PROTECTED] wrote: | Try executing: | | do { x - return 2; undefined; return (x*x); } | | in any monad you like It's not just the identity monad: Prelude :m +Control.Monad.State Prelude Control.Monad.State flip evalState () $ do { x - return 2; undefined;

[Haskell-cafe] Re: Re: Explaining monads

2007-08-13 Thread Benjamin Franksen
Derek Elkins wrote: On Mon, 2007-08-13 at 22:29 +0200, Benjamin Franksen wrote: Brian Brunswick wrote: One thing that I keep seeing people say (not you), is that monads /sequence/ side effects. This is wrong, or at least a limited picture. /All/ of the above structures are about

Re: [Haskell-cafe] Explaining monads

2007-08-13 Thread Gregory Propf
I made this mistake myself at first too. It seems that the Monad = side effect machine error is common to Haskell newbies. Probably to do with the fact that the first thing every programmer wants to do is write a hello world program and for that you need the IO Monad which requires some

Re: [Haskell-cafe] Re: Re: Explaining monads

2007-08-13 Thread Dan Piponi
On 8/13/07, Benjamin Franksen [EMAIL PROTECTED] wrote: Ok, I admit defeat now ;-) Monads in general /allow/ sequencing of (certain) effects, but it is not necessary for a monad to do so. I'm sure I said that 300 or so posts ago :-) Here's an example that might help make some of this explicit.

[Haskell-cafe] Re: Re: Re: Language support for imperative code. Was: Re: monad subexpressions

2007-08-13 Thread Benjamin Franksen
Isaac Dupree wrote: Benjamin Franksen wrote: I'd be careful. Introducing a network connection into the equation makes the object (its methods) susceptible to a whole new bunch of failure modes; think indefinite delays, connection loss, network buffer overflow, etc etc. It may be a mistake to

Re: [Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread ajb
G'day all. Quoting Andrew Coppin [EMAIL PROTECTED]: So many other programming languages allow weird things to happen with numeric overflows... it would be nice if Haskell didn't. It would nice if CPUs supported trapping integer arithmetic. Cheers, Andrew Bromage

[Haskell-cafe] Small proof intro

2007-08-13 Thread Tim Newsham
I put together a small intro lesson on proving haskell code using quickcheck, equational reasoning and Isabelle/HOL. Its very elementary, but might be of interest to some people here. http://www.thenewsh.com/%7Enewsham/formal/reverse/ Feedback is appreciated. Tim Newsham

Re: [Haskell-cafe] Explaining monads

2007-08-13 Thread Ronald Guida
Ronald Guida wrote: Given the question What is a Monad, I would have to say A Monad is a device for sequencing side-effects. peterv [EMAIL PROTECTED] wrote: Side-effects is a piece of linguistic cruft played fast-and-loose by too many people in this game. Sequencing suffers the same

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Kim-Ee Yeoh
Ronald Guida wrote: Here is the brief explanation I came up with: Arrows and monads are abstract data types used to construct Domain Specific Embedded Languages (DSELs) within Haskel. A simple arrow provides a closed DSEL. A monad is a special type of arrow that creates an open

[Haskell-cafe] Re: a regressive view of support for imperative programming in Haskell

2007-08-14 Thread apfelmus
Stefan O'Rear wrote: apfelmus wrote: My assumption is that we have an equivalence forall a,b . m (a - m b) ~ (a - m b) because any side effect executed by the extra m on the outside can well be delayed until we are supplied a value a. Well, at least when all arguments are fully applied,

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Dougal Stanton
On 14/08/07, Ronald Guida [EMAIL PROTECTED] wrote: My present goal is to understand monads well enough to be able to explain them to others. I wonder if it's possible to create a tutorial that explains monads well enough so that they just make sense or click for people. It seems everyone

[Haskell-cafe] Parsec: Parenthesized expressions and more!

2007-08-14 Thread Vimal
Hi I was trying out some parsing with parsec. I tried: Accepting proper parenthesized expressions, this was the code: parens :: Parser () parens = do char '(' parens char ')' parens | return () Implementing basically: S - (S)S | e. I doubt the fact that 'e' was actually considered,

[Haskell-cafe] Re: Parsec: Parenthesized expressions and more!

2007-08-14 Thread Christian Maeder
Vimal wrote: Hi I was trying out some parsing with parsec. I tried: Accepting proper parenthesized expressions, this was the code: parens :: Parser () parens = do char '(' parens char ')' parens | return () I would indent | return () a bit less: ... parens |

Re: [Haskell-cafe] Re: Explaining monads

2007-08-14 Thread Bertram Felgenhauer
Benjamin Franksen wrote: Brian Brunswick wrote: One thing that I keep seeing people say (not you), is that monads /sequence/ side effects. This is wrong, or at least a limited picture. /All/ of the above structures are about combining compatible things things together in a row. I

[Haskell-cafe] Converting Emacs syntax coloured Haskell code to HTML

2007-08-14 Thread Peter Verswyvelen
I noticed many code snippets on the wiki that have syntax colouring. How is this done? Can I convert syntax coloured code from Emacs to HTML? I'm using the Haskell mode for Emacs to get the syntax colouring. I'm writing a monads for C# programmers tutorial (oh no) and would

Re: [Haskell-cafe] Converting Emacs syntax coloured Haskell code to HTML

2007-08-14 Thread Alfonso Acosta
M-x htmlize-buffer On 8/14/07, Peter Verswyvelen [EMAIL PROTECTED] wrote: I noticed many code snippets on the wiki that have syntax colouring. How is this done? Can I convert syntax coloured code from Emacs to HTML? I'm using the Haskell mode for Emacs to get the syntax colouring.

Re: [Haskell-cafe] Converting Emacs syntax coloured Haskell code to HTML

2007-08-14 Thread Bas van Dijk
On 8/14/07, Peter Verswyvelen [EMAIL PROTECTED] wrote: I noticed many code snippets on the wiki that have syntax colouring. How is this done? Can I convert syntax coloured code from Emacs to HTML? Look at HsColour: http://www.cs.york.ac.uk/fp/darcs/hscolour/ regards, Bas van Dijk

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Lanny Ripple
Having just gone through all the tutorials and things (again but this time I think it stuck) the Haskell community is on the wrong track as far as teaching Monads to new programmers. If I were teaching addition and multiplication to children I wouldn't start with, We'll begin by defining an

[Haskell-cafe] Bathroom reading

2007-08-14 Thread Dougal Stanton
I'm looking for cool but mind-bending examples of functional brilliance. Let us say, hypothetically, you had a bathroom without any reading material. And having read all the Dilbert and Garfield you could seriously stomach, decide you should educate yourself while on the job. :-) So you decide

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Sebastian Sylvan
On 14/08/07, Lanny Ripple [EMAIL PROTECTED] wrote: Having just gone through all the tutorials and things (again but this time I think it stuck) the Haskell community is on the wrong track as far as teaching Monads to new programmers. If I were teaching addition and multiplication to children

Re: [Haskell-cafe] Bathroom reading

2007-08-14 Thread Bas van Dijk
On 8/14/07, Dougal Stanton [EMAIL PROTECTED] wrote: I'm looking for cool but mind-bending examples of functional brilliance. Let us say, hypothetically, you had a bathroom without any reading material. And having read all the Dilbert and Garfield you could seriously stomach, decide you should

Re: [Haskell-cafe] Bathroom reading

2007-08-14 Thread Brandon S. Allbery KF8NH
On Aug 14, 2007, at 11:17 , Dougal Stanton wrote: Let us say, hypothetically, you had a bathroom without any reading material. And having read all the Dilbert and Garfield you could seriously stomach, decide you should educate yourself while on the job. :-) Sounds to me like you want a

Re: [Haskell-cafe] Bathroom reading

2007-08-14 Thread Spencer Janssen
On Tuesday 14 August 2007 10:17:53 Dougal Stanton wrote: I'm looking for cool but mind-bending examples of functional brilliance. Let us say, hypothetically, you had a bathroom without any reading material. And having read all the Dilbert and Garfield you could seriously stomach, decide you

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Jeff Polakow
Hello, There is clearly a problem with the Haskell/monad tutorials out there... The tutorials seriously need to step back and start with something like, To enforce order of evaluation we evaluate closures* returning a defined type. The first closure will feed its result to the second

Re: [Haskell-cafe] Bathroom reading

2007-08-14 Thread Brent Yorgey
So you decide to print up some one-liner style programs into a little booklet. Something between credit-card and postcard sized, with a neat but mind-bending program on it. Don Stewart occasionally swoops in with some fixpoint malarkey to defuse heated discussions. I mean that kind of thing,

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Lanny Ripple
Look! You are doing it again! :) Does that paragraph even contain the word Monad? :) I'm aware a monad is an abstraction and as such it doesn't *do* anything. My point was along the lines that you don't need to know that your working in a field to be able to learn that 3/2 = 1.5 .

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Alex Queiroz
Hallo, On 8/14/07, Jeff Polakow [EMAIL PROTECTED] wrote: Hello, There is clearly a problem with the Haskell/monad tutorials out there... The tutorials seriously need to step back and start with something like, To enforce order of evaluation we evaluate closures* returning a defined

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Dan Piponi
On 8/14/07, Jeff Polakow [EMAIL PROTECTED] wrote: One general intuition about monads is that they represent computations rather than simple (already computed) values: x :: Int -- x is an Int x :: Monad m = m Int -- x is a computation of an Int What's a computation? It

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Dan Piponi
On 8/14/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: I like the very light weight analogy (which works for most practical uses of monads) that a monadic action is a recipe Many introductory programming books present the idea of a program as a recipe. Here's a recipe for computing factorials:

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Jeff Polakow
Hello, Look! You are doing it again! :) Does that paragraph even contain the word Monad? :) Sorry. Your first paragraph led me to believe you were writing about monads. I'm aware a monad is an abstraction and as such it doesn't *do* anything. My point was along the lines that you

[Haskell-cafe] Re: Bathroom reading

2007-08-14 Thread Chad Scherrer
Maybe something of these? http://www.haskell.org/haskellwiki/Blow_your_mind -- Chad Scherrer Time flies like an arrow; fruit flies like a banana -- Groucho Marx ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Derek Elkins
On Tue, 2007-08-14 at 09:55 -0500, Lanny Ripple wrote: Having just gone through all the tutorials and things (again but this time I think it stuck) the Haskell community is on the wrong track as far as teaching Monads to new programmers. If I were teaching addition and multiplication to

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Sebastian Sylvan
On 14/08/07, Dan Piponi [EMAIL PROTECTED] wrote: On 8/14/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: I like the very light weight analogy (which works for most practical uses of monads) that a monadic action is a recipe Many introductory programming books present the idea of a program as

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Lanny Ripple
A very good point. I even knew that implicitly but wasn't thinking in those terms explicitly when writing up my first post and it does make a difference in how you view things. -ljr Jeff Polakow wrote: Hello, Look! You are doing it again! :) Does that paragraph even contain the

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Lennart Augustsson
You don't normally call x::Int a computation of an Int because there's nothing that distinguishes the value of the x from what it was before you computed it. So I prefer to regard x as a value (in a domain, of course). But for x :: (Monad m) = m Int there is something else happening, so the word

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Lanny Ripple
Derek Elkins wrote: What people need to do is stop reading two page blog posts by someone who's just got monads and read the well-written peer-reviewed papers I have taught many people to program in group settings and individually in my career. I have referred them to many tutorials. I

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Jeff Polakow
Hello, On 8/14/07, Jeff Polakow [EMAIL PROTECTED] wrote: One general intuition about monads is that they represent computations rather than simple (already computed) values: x :: Int -- x is an Int x :: Monad m = m Int -- x is a computation of an Int What's a

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Brian Brunswick
On 14/08/07, Jeff Polakow [EMAIL PROTECTED] wrote: Of course, the type [Int] denotes a value which is a list of Ints; additionally [Int] can be viewed as a value representing the nondeterministic computation of a single Int. Generally, the type Monad m = m Int can be viewed as a value

Re: [Haskell-cafe] Bathroom reading

2007-08-14 Thread Dougal Stanton
On 14/08/07, Brent Yorgey [EMAIL PROTECTED] wrote: Clearly, we need to actually put together such a book! I'm imagining something where you have two mostly blank facing pages, with the code by itself in the middle of the right page; then the next 2-4 pages devoted to a short discussion of the

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Dan Piponi
On 8/14/07, Lennart Augustsson [EMAIL PROTECTED] wrote: You don't normally call x::Int a computation of an Int because there's nothing that distinguishes the value of the x from what it was before you computed it. Can you spell out exactly what you mean by this? So I prefer to regard x as a

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Dan Piponi
On 8/14/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: On 14/08/07, Dan Piponi [EMAIL PROTECTED] wrote: Where do monads come in? Well I would try to distinguish between code that we write to compute values, and values which represent monadic actions when coming up with analogies. How would

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Sebastian Sylvan
On 14/08/07, Dan Piponi [EMAIL PROTECTED] wrote: On 8/14/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: On 14/08/07, Dan Piponi [EMAIL PROTECTED] wrote: Where do monads come in? Well I would try to distinguish between code that we write to compute values, and values which represent

Re: [Haskell-cafe] Bathroom reading

2007-08-14 Thread Brent Yorgey
On 8/14/07, Dougal Stanton [EMAIL PROTECTED] wrote: On 14/08/07, Brent Yorgey [EMAIL PROTECTED] wrote: Clearly, we need to actually put together such a book! I'm imagining something where you have two mostly blank facing pages, with the code by itself in the middle of the right page; then

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Dan Piponi
On 8/14/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: Well that's easy, don't use the recipe analogy to explain code, use it for monadic values exclusively, and you avoid the confusion entirely! I don't think it's that complicated. It certainly is complicated. I think I have a good grasp of

[Haskell-cafe] Re: Explaining monads

2007-08-14 Thread Aaron Denney
On 2007-08-14, Dan Piponi [EMAIL PROTECTED] wrote: On 8/14/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: I like the very light weight analogy (which works for most practical uses of monads) that a monadic action is a recipe Many introductory programming books present the idea of a program as

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Jeff Polakow
Hello, On 14/08/07, Jeff Polakow [EMAIL PROTECTED] wrote: Of course, the type [Int] denotes a value which is a list of Ints; additionally [Int] can be viewed as a value representing the nondeterministic computation of a single Int. Generally, the type Monad m = m Int can be viewed as a

[Haskell-cafe] Re: Bathroom reading

2007-08-14 Thread Aaron Denney
On 2007-08-14, Spencer Janssen [EMAIL PROTECTED] wrote: On Tuesday 14 August 2007 10:17:53 Dougal Stanton wrote: I'm looking for cool but mind-bending examples of functional brilliance. Let us say, hypothetically, you had a bathroom without any reading material. And having read all the

[Haskell-cafe] Error building takusen with Cabal-1.1.6.2

2007-08-14 Thread John Dell'Aquila
Setup.hs wants a module that Cabal hides. Am I doing something wrong (newbie :-) or should I try to fall back to Cabal-1.1.6.1? $ ghc --make -o setup Setup.hs Setup.hs:13:7: Could not find module `Distribution.Compat.FilePath': it is hidden (in package Cabal-1.1.6.2)

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Sebastian Sylvan
On 14/08/07, Dan Piponi [EMAIL PROTECTED] wrote: On 8/14/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: Well that's easy, don't use the recipe analogy to explain code, use it for monadic values exclusively, and you avoid the confusion entirely! I don't think it's that complicated. It

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Arie Peterson
Dan Piponi wrote: | On 8/14/07, Lennart Augustsson [EMAIL PROTECTED] wrote: | You don't normally call x::Int a computation of an Int because there's | nothing that distinguishes the value of the x from what it was before | you computed it. | | Can you spell out exactly what you mean by this?

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Malte Milatz
Dan Piponi, Tue, 14 Aug 2007 11:52:16 -0700: All functions can be viewed as recipes. (+) is a recipe. Give me some ingredients (two numbers) and I'll use (+) to give you back their sum. (+) is not a recipe, it is a chef. On the other hand, (return 5 :: State Integer) is a recipe. You need a

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Sebastian Sylvan
On 14/08/07, Malte Milatz [EMAIL PROTECTED] wrote: Dan Piponi, Tue, 14 Aug 2007 11:52:16 -0700: All functions can be viewed as recipes. (+) is a recipe. Give me some ingredients (two numbers) and I'll use (+) to give you back their sum. (+) is not a recipe, it is a chef. On the other hand,

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Seth Gordon
Sebastian Sylvan wrote: On 14/08/07, Dan Piponi [EMAIL PROTECTED] wrote: If I was one of your students and you said that monads are recipes I would immediately ask you where the monads are in my factorial program regardless of whether you had introduced one or two different analogies for

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Sebastian Sylvan
On 14/08/07, Seth Gordon [EMAIL PROTECTED] wrote: Sebastian Sylvan wrote: On 14/08/07, Dan Piponi [EMAIL PROTECTED] wrote: If I was one of your students and you said that monads are recipes I would immediately ask you where the monads are in my factorial program regardless of whether you

[Haskell-cafe] defining last using foldr

2007-08-14 Thread Alexteslin
Hi, I am trying to do the exercise which asks to define built-in functions 'last' and 'init' using 'foldr' function, such as last Greggery Peccary = 'y' the type for my function is: myLast :: [Char] - Char I am not generalizing type so that make it less complicated. But what ever i am

[Haskell-cafe] Re: defining last using foldr

2007-08-14 Thread Aaron Denney
On 2007-08-14, Alexteslin [EMAIL PROTECTED] wrote: Hi, I am trying to do the exercise which asks to define built-in functions 'last' and 'init' using 'foldr' function, such as last Greggery Peccary = 'y' the type for my function is: myLast :: [Char] - Char I am not generalizing type

[Haskell-cafe] Re: Error building takusen with Cabal-1.1.6.2

2007-08-14 Thread Benjamin Franksen
John Dell'Aquila wrote: Setup.hs wants a module that Cabal hides. Am I doing something wrong (newbie :-) or should I try to fall back to Cabal-1.1.6.1? $ ghc --make -o setup Setup.hs Setup.hs:13:7: Could not find module `Distribution.Compat.FilePath': it is hidden (in package

Re: [Haskell-cafe] defining last using foldr

2007-08-14 Thread Rodrigo Queiro
I've found a way to do it, but it's not pretty. Hint: The function in the foldr first get the last value, and will need to keep it the whole way through. How can it tell if it is being given the last item or an earlier item? I'm generally not too good at the Socratic method, so feel free to

Re: [Haskell-cafe] defining last using foldr

2007-08-14 Thread Alexteslin
Well, i have tried cons (:) operator but when it passed to foldr doesn't work because cons operator operates first character and then the list but the foldr argument takes a function (a-a-a). Maybe i am missing the point here? Aaron Denney wrote: On 2007-08-14, Alexteslin [EMAIL PROTECTED]

Re: [Haskell-cafe] defining last using foldr

2007-08-14 Thread Chaddaï Fouché
2007/8/14, Alexteslin [EMAIL PROTECTED]: Well, i have tried cons (:) operator but when it passed to foldr doesn't work because cons operator operates first character and then the list but the foldr argument takes a function (a-a-a). Maybe i am missing the point here? What Aaron was saying

Re: [Haskell-cafe] defining last using foldr

2007-08-14 Thread Rodrigo Queiro
You can consider foldr to be continual modification of a state. The initial state is given as an argument, and then the (a - b - b) function is passed the next element of the list and the current state, and it returns the new state. foldr will then return the final state, from which the result can

[Haskell-cafe] Re: defining last using foldr

2007-08-14 Thread Aaron Denney
(Quoting reformatted. Try to have your responses below what you are responding to. It makes it easier to read as a conversation.) On 2007-08-14, Alexteslin [EMAIL PROTECTED] wrote: Aaron Denney wrote: Folds replace the cons operator (:) with the function you pass it. If you want the tail of

[Haskell-cafe] Re: defining last using foldr

2007-08-14 Thread Aaron Denney
On 2007-08-14, Chaddaï Fouché [EMAIL PROTECTED] wrote: 2007/8/14, Alexteslin [EMAIL PROTECTED]: Well, i have tried cons (:) operator but when it passed to foldr doesn't work because cons operator operates first character and then the list but the foldr argument takes a function (a-a-a). Maybe

[Haskell-cafe] Why monad tutorials don't work

2007-08-14 Thread Dan Weston
Conor McBride and Ross Paterson said it best in the introduction to their paper Applicative programming with effects [1]: This is the story of a pattern that popped up time and again in our daily work,..., until the temptation to abstract it became irresistible. Let us illustrate with

Re: [Haskell-cafe] Why monad tutorials don't work

2007-08-14 Thread Dougal Stanton
On 14/08/07, Dan Weston [EMAIL PROTECTED] wrote: [snips another metaphor for monadic programming] No offence to Dan, whose post I enjoyed. The concept of wrapping is as close a metaphor as we seem to get without disagreements. But this has brought me to a realisation, after Paul Erdos: The

Re: [Haskell-cafe] Re: defining last using foldr

2007-08-14 Thread Chaddaï Fouché
2007/8/14, Aaron Denney [EMAIL PROTECTED]: The problem with foldl is that you can't easily make it polymorphic because of how the null case is handled. foldl1 and foldr1 are trivial, true. The original last fail on empty list, it's far easier to obtain the same semantic with foldl than with

Re: [Haskell-cafe] Why monad tutorials don't work

2007-08-14 Thread Michael Vanier
snark As you know, an arrow tutorial is like a wrapper around a monad tutorial, sort of like a container around it that can do extra actions with sufficient lifting. The appropriate higher-order function to convert monad tutorials to arrow tutorials will be left as an exercise to the reader.

[Haskell-cafe] Re: defining last using foldr

2007-08-14 Thread Aaron Denney
On 2007-08-14, Chaddaï Fouché [EMAIL PROTECTED] wrote: 2007/8/14, Aaron Denney [EMAIL PROTECTED]: The problem with foldl is that you can't easily make it polymorphic because of how the null case is handled. foldl1 and foldr1 are trivial, true. The original last fail on empty list, it's far

Re: [Haskell-cafe] Why monad tutorials don't work

2007-08-14 Thread Dan Piponi
On 8/14/07, Dan Weston [EMAIL PROTECTED] wrote: Conor McBride and Ross Paterson said it best in the introduction to their paper Applicative programming with effects [1]: As von Neumann said: Young man, in mathematics you don't understand things, you just get used to them. Getting used to

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Derek Elkins
On Tue, 2007-08-14 at 12:40 -0500, Lanny Ripple wrote: Derek Elkins wrote: What people need to do is stop reading two page blog posts by someone who's just got monads and read the well-written peer-reviewed papers I have taught many people to program in group settings and individually in

Re: [Haskell-cafe] Why monad tutorials don't work

2007-08-14 Thread Erik Jones
On 8/14/07, Michael Vanier [EMAIL PROTECTED] wrote: I'm becoming more and more convinced that metaphors for monads do more harm than good. From now on I'm going to describe monads as purely abstract entities that obey certain laws, and that _in certain instances_ can be viewed to be like

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Michael Vanier
For what it's worth, the nature of Haskell is such that you do (at least currently) have to spend a lot of time reading research papers to understand what's going on. Maybe that will change sometime, but probably not soon. This ties in to the open-endedness of Haskell; I sometimes think that

[Haskell-cafe] Re:Explaining monads

2007-08-14 Thread Gregory Propf
Sorry to spam you Jeff, again I sent my email to the poster rather than the list. I'm using Yahoo beta webmail and don't see a way to set it to reply to the list rather than the originator. Anyway, this was my post: Hence the need to perform a run operation like runIdentity, evalState or

Re: [Haskell-cafe] Re:Explaining monads

2007-08-14 Thread Brian Brunswick
On 15/08/07, Gregory Propf [EMAIL PROTECTED] wrote: - Original Message From: Jeff Polakow [EMAIL PROTECTED] One general intuition about monads is that they represent computations rather than simple (already computed) values: I still want to re-iterate that they represent /complex/

[Haskell-cafe] GHC linking problems

2007-08-14 Thread SevenThunders
I have a large Haskell/C project that needs to be linked against an even larger set of C libraries and object files (OpNet) on a linux box (Fedora Core 7). So far I have been able to link my Haskell libraries to some C test code containing a main function without incident. However the link

  1   2   3   4   5   6   7   8   9   10   >