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

2007-07-02 Thread Jules Bean
Gregory Propf wrote: Thanks, that was helpful. I didn't realize that there were pure functional monads. Actually, it's stronger than that. All monads are pure functional, even IO. Haskell is an entirely 100% pure functional language[*]. The IO monad allows you to build up, in a pure,

[Haskell-cafe] Re: Parsers are monadic?

2007-07-02 Thread apfelmus
Paul Hudak wrote: readFile :: Name - FailCont - StrCont - Behaviour Here StrCont was the success continuation, which took a string (the file contents) as argument. I rather liked the flexibility that this offered -- since I/O errors were fairly common, it made sense to give success and

Re: [Haskell-cafe] Parsers are monadic?

2007-07-02 Thread Claus Reinke
contrary to monadic parsers, those continuation-based parsers had *two* continuations, one for success, one for failure. and that seemed to be a very natural match for the problem. Two-continuations is a monad too, right? yes, but my problem is not about giving them a monadic interface, but

Re: [Haskell-cafe] Re: Tree Guidance

2007-07-02 Thread Hans van Thiel
On Fri, 2007-06-29 at 19:35 +0200, Thomas Schilling wrote: On 27 jun 2007, at 18.41, Hans van Thiel wrote: [snip] Thanks, Apfelmus, for the references. Guess I'll start there, then. And thanks, Chris, for the info and code. Read only 'up pointers' could be what is needed. But

Re: Re[2]: [Haskell-cafe] XmlSerializer.deserialize?

2007-07-02 Thread Philip Armstrong
On Mon, Jul 02, 2007 at 12:23:36AM +0200, Hugh Perkins wrote: Clll :-) Thanks for the link. Er are you the Philip Armstrong I was at college with Shhh. Don't tell everyone or they'll all want one. (iow, yes: Probably.) Phil -- http://www.kantaka.co.uk/ .oOo. public key:

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

2007-07-02 Thread Claus Reinke
class Monad m = MonadError e m | m - e where throwError :: e - m a catchError :: m a - (e - m a) - m a .. power of TwoCont? I mean, it still seems like there's an operation missing that supplies new left and right continuations at once. i guess, instead of one DiMonad with two sets of

[Haskell-cafe] Re: Parsers are monadic?

2007-07-02 Thread apfelmus
apfelmus wrote: class DiMonad m where returnR :: a - m e a bindR :: m e a - (a - m e b) - m e b returnL :: e - m e a bindL :: m e a - (e - m e' a) - m e' a type TwoCont e a = (e - R) - (a - R) - R A final question remains: does the dimonad abstraction cover the

Re: [Haskell-cafe] N00b question

2007-07-02 Thread Jim Burton
poop wrote: So I'm working my way thorough haskell, doing some programming problems, and I have this one so far: Hi, I haven't spotted the problem in your code but there's an alternative solution to Euler Problem 14 on the wiki:

[Haskell-cafe] Before

2007-07-02 Thread Andrew Coppin
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... ___ Haskell-Cafe mailing list

Re: Re[2]: [Haskell-cafe] XmlSerializer.deserialize?

2007-07-02 Thread Hugh Perkins
lol small world :-) On 7/2/07, Philip Armstrong [EMAIL PROTECTED] wrote: On Mon, Jul 02, 2007 at 12:23:36AM +0200, Hugh Perkins wrote: Clll :-) Thanks for the link. Er are you the Philip Armstrong I was at college with Shhh. Don't tell everyone or they'll all want one.

Re: [Haskell-cafe] Before

2007-07-02 Thread Dan Piponi
On 7/2/07, Andrew Coppin [EMAIL PROTECTED] 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? It's as close to a mathematician's notion of a monad as Haskell's types and

Re: [Haskell-cafe] Before

2007-07-02 Thread Andrew Coppin
Dan Piponi wrote: On 7/2/07, Andrew Coppin [EMAIL PROTECTED] 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? It's as close to a mathematician's notion of a monad as

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

2007-07-02 Thread Gregory Propf
Right, I read more about it and found this out. The 'main' function is apparently magical at runtime and allows you to break the with pure functionality just once but since it can call other functions this allows for useful programs to be written. - Original Message From: Jules Bean

[Haskell-cafe] Very simple parser

2007-07-02 Thread Gregory Propf
As a programming exercise I'm trying to use the State monad to create a simple parser. It's for a very simple assembly language for a simple virtual machine. The state is a string of instructions. I want to be able to call something like getNextInstruction to pull out the next instruction

[Haskell-cafe] Re: Parsers are monadic?

2007-07-02 Thread Arie Peterson
Gregory Propf wrote: Right, I read more about it and found this out. The 'main' function is apparently magical at runtime and allows you to break the with pure functionality just once but since it can call other functions this allows for useful programs to be written. There is more than one

Re: [Haskell-cafe] Very simple parser

2007-07-02 Thread Arie Peterson
Gregory Propf wrote: As a programming exercise I'm trying to use the State monad to create a simple parser. It's for a very simple assembly language for a simple virtual machine. The state is a string of instructions. I want to be able to call something like getNextInstruction to pull out

Re: [Haskell-cafe] Before

2007-07-02 Thread Jonathan Cast
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

Re: [Haskell-cafe] Very simple parser

2007-07-02 Thread Stefan O'Rear
vim: set ft=lhaskell: On Mon, Jul 02, 2007 at 02:25:57PM -0700, Gregory Propf wrote: | As a programming exercise I'm trying to use the State monad to create | a simple parser. It's for a very simple assembly language for a | simple virtual machine. The state is a string of instructions. I |

[Haskell-cafe] Getting debugging/logging info?

2007-07-02 Thread Hugh Perkins
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 ); How can we do something similar in Haskell? ___ Haskell-Cafe

[Haskell-cafe] Callback functions?

2007-07-02 Thread Hugh Perkins
This sounds something like using a continuation function. In imperative languages, we might have something like: class MyDisplayForm { void ButtonGo_Press() { Processor.Go( new CallbackDelegate( this.SetStatus ) ); } public void SetStatus( string message ) { StatusLbl.Text

Re: [Haskell-cafe] Callback functions?

2007-07-02 Thread Stefan O'Rear
On Tue, Jul 03, 2007 at 12:26:47AM +0200, Hugh Perkins wrote: This sounds something like using a continuation function. In imperative languages, we might have something like: class MyDisplayForm { void ButtonGo_Press() { Processor.Go( new CallbackDelegate( this.SetStatus ) );

Re: [Haskell-cafe] Very simple parser

2007-07-02 Thread Gregory Propf
I hadn't seen that before, thanks. My code wouldn't be that useful as it depends on some of my datatypes. I don't know some basic things here since I'm so new to Haskell. For example, am I to assume that I need to create my own instance of State and then define get and put for it? Some of

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

2007-07-02 Thread Neil Mitchell
Hi SystemLogging.LogInfo(Did Something); SystemLogging.LogInfo(x is + x ); How can we do something similar in Haskell? See trace: http://www.haskell.org/hoogle/?q=trace Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

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

2007-07-02 Thread Mark T.B. Carroll
Hugh Perkins [EMAIL PROTECTED] writes: SystemLogging.LogInfo(About to do something...); DoSomething(); SystemLogging.LogInfo(Did Something); SystemLogging.LogInfo(x is + x ); How can we do something similar in Haskell? Maybe, with System.IO, main = do log - openFile /tmp/log.txt

Re: [Haskell-cafe] Very simple parser

2007-07-02 Thread Hugh Perkins
Graham Hutton has some great tutorials on parsing. Check out the Are parsers monodic? thread (not exact name) for a good reference. There's also a good tutorial at http://www.cs.nott.ac.uk/~gmh/book.html In Section Slides, click on 8 Functional parsers, but you may just want to start from 1.

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

2007-07-02 Thread Hugh Perkins
On 7/3/07, Neil Mitchell [EMAIL PROTECTED] wrote: See trace: http://www.haskell.org/hoogle/?q=trace I'll check that out. Thanks. Maybe, with System.IO, Fine in main :-) Less good in a 100,000 line application. ___ Haskell-Cafe mailing list

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

2007-07-02 Thread Mark T.B. Carroll
Hugh Perkins [EMAIL PROTECTED] writes: (snip) Maybe, with System.IO, Fine in main :-) Less good in a 100,000 line application. Oh, sorry, I thought your point had been about making sure the operation was done before the did something line got printed. (-: -- Mark

Re: [Haskell-cafe] Callback functions?

2007-07-02 Thread Hugh Perkins
http://cvs.haskell.org/cgi-bin /cvsweb.cgi/fptools/libraries/GLUT/examples/RedBook/ Ok, I'll take a look What makes a callback different from any other kind of function? Well... what about inside monads? Does this break purity??? Does this require adding IO to the monad if the callback

Re: [Haskell-cafe] Callback functions?

2007-07-02 Thread Dan Piponi
On 7/2/07, Hugh Perkins [EMAIL PROTECTED] wrote: Anyway, so the question is: how do we write callback functions in FP/Haskell? Can someone provide a simple, but functional example? What makes a callback different from any other kind of function? In Haskell, as in other functional programming

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

2007-07-02 Thread Brandon S. Allbery KF8NH
On Jul 2, 2007, at 18:40 , Neil Mitchell wrote: SystemLogging.LogInfo(Did Something); SystemLogging.LogInfo(x is + x ); How can we do something similar in Haskell? See trace: http://www.haskell.org/hoogle/?q=trace In addition, you could use the Writer monad to collect log information

Re: [Haskell-cafe] Callback functions?

2007-07-02 Thread Dan Piponi
On 7/2/07, Hugh Perkins [EMAIL PROTECTED] wrote: Well... what about inside monads? Does this break purity??? Does this require adding IO to the monad if the callback function does IO? Check out the documentation for the HOpenGL callbacks here:

Re: [Haskell-cafe] Very simple parser

2007-07-02 Thread Arie Peterson
Gregory Propf wrote: | [...] For example, am I to assume that I need to | create my own instance of State and then define get and put for it? No, there is a 'State s' monad provided (for arbitrary state type 's'), which implements the 'get' and 'put' methods. In other words, 'State s' is an

Re: [Haskell-cafe] Very simple parser

2007-07-02 Thread Gregory Propf
This was a bit baffling too. It appears that there's an implied argument to runTick. This also works and makes it more explicit. I suppose the compiler just works out that the only place to put the 'n' is after tick. runTick :: Int - (String,Int) runTick n = runState tick n - Original

Re: [Haskell-cafe] Very simple parser

2007-07-02 Thread Tim Chevalier
On 7/2/07, Gregory Propf [EMAIL PROTECTED] wrote: This was a bit baffling too. It appears that there's an implied argument to runTick. This also works and makes it more explicit. I suppose the compiler just works out that the only place to put the 'n' is after tick. runTick :: Int -

Re: [Haskell-cafe] Callback functions?

2007-07-02 Thread Albert Y. C. Lai
Hugh Perkins wrote: What makes a callback different from any other kind of function? Well... what about inside monads? Does this break purity??? Does this require adding IO to the monad if the callback function does IO? As I'm writing this I kindof have this sense inside me that this is

Re: [Haskell-cafe] Very simple parser

2007-07-02 Thread Gregory Propf
OK, I get the reference to currying now. A function of 2 variables can be seen as a function of one that returns another function of one. So a function of one variable can be seen as a function of no variables that returns a function of one. Very nice. - Original Message From: Tim