Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED]
You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. eval command? (Alex Shearn) 2. Re: eval command? (Brandon S. Allbery KF8NH) 3. Re: eval command? (Brent Yorgey) 4. evaluation of expressions [was Re: eval command?] (Andrew Sackville-West) 5. Re: evaluation of expressions [was Re: eval command?] (Brandon S. Allbery KF8NH) 6. gtk2hs treeViewSetReorderable ([EMAIL PROTECTED]) 7. Re: evaluation of expressions [was Re: eval command?] (Tony Hannan) 8. Re: gtk2hs treeViewSetReorderable ([EMAIL PROTECTED]) 9. Re: evaluation of expressions [was Re: eval command?] (Andrew Sackville-West) ---------------------------------------------------------------------- Message: 1 Date: Mon, 27 Oct 2008 21:33:21 +0000 From: Alex Shearn <[EMAIL PROTECTED]> Subject: [Haskell-beginners] eval command? To: beginners@haskell.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hey all - I've been trying to write an IRC bot following the guide on the wiki, and we (those of us on the channel) were trying to get it to evaluate commands. So far, we have this for "eval" stuff, but is there anyway to specify a "parse in haskell" sort of thing? [code] -- Dispatch a command eval :: String -> Net () eval "!endbot" = write "QUIT" ":Exiting" >> io (exitWith ExitSuccess) eval x | "!haskbot " `isPrefixOf` x = privmsg (drop 9 x) eval _ = return () -- ignore everything else [/code] is there anyway to do something like: eval "!eval" `isPrefixOf` x = eval blah ? if this isn't beginners' stuff, let me know, i'll repost to the main mailing list. Many thanks, Alex Shearn -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ------------------------------ Message: 2 Date: Mon, 27 Oct 2008 19:00:00 -0400 From: "Brandon S. Allbery KF8NH" <[EMAIL PROTECTED]> Subject: Re: [Haskell-beginners] eval command? To: [EMAIL PROTECTED] Cc: beginners@haskell.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes On 2008 Oct 27, at 17:33, Alex Shearn wrote: > Hey all - I've been trying to write an IRC bot following the guide > on the wiki, and we (those of us on the channel) were trying to get > it to evaluate commands. > So far, we have this for "eval" stuff, but is there anyway to > specify a "parse in haskell" sort of thing? No, although you could fake it with the GHC-API (which basically means your bot has all of GHC built into it). In any case, that's not really a good idea; consider what damage could be done by arbitrary code. A better idea is to link the code into a small program with a very restricted environment and run that with a timeout. See http://code.haskell.org/lambdabot/Plugin/Eval.hs. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon university KF8NH ------------------------------ Message: 3 Date: Mon, 27 Oct 2008 19:45:26 -0400 From: Brent Yorgey <[EMAIL PROTECTED]> Subject: Re: [Haskell-beginners] eval command? To: beginners@haskell.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=us-ascii On Mon, Oct 27, 2008 at 07:00:00PM -0400, Brandon S. Allbery KF8NH wrote: > On 2008 Oct 27, at 17:33, Alex Shearn wrote: >> Hey all - I've been trying to write an IRC bot following the guide on the >> wiki, and we (those of us on the channel) were trying to get it to >> evaluate commands. >> So far, we have this for "eval" stuff, but is there anyway to specify a >> "parse in haskell" sort of thing? > > > No, although you could fake it with the GHC-API (which basically means your > bot has all of GHC built into it). > > In any case, that's not really a good idea; consider what damage could be > done by arbitrary code. A better idea is to link the code into a small > program with a very restricted environment and run that with a timeout. > See http://code.haskell.org/lambdabot/Plugin/Eval.hs. Brandon is right that this is difficult and tricky -- but fortunately, someone else has already done the hard work for you! Take a look at the mueval package [1], which should allow you to do what you want. -Brent [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mueval ------------------------------ Message: 4 Date: Mon, 27 Oct 2008 20:25:20 -0700 From: Andrew Sackville-West <[EMAIL PROTECTED]> Subject: [Haskell-beginners] evaluation of expressions [was Re: eval command?] To: beginners@haskell.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset="us-ascii" On Mon, Oct 27, 2008 at 07:45:26PM -0400, Brent Yorgey wrote: > On Mon, Oct 27, 2008 at 07:00:00PM -0400, Brandon S. Allbery KF8NH wrote: > > On 2008 Oct 27, at 17:33, Alex Shearn wrote: > >> Hey all - I've been trying to write an IRC bot following the guide on the > >> wiki, and we (those of us on the channel) were trying to get it to > >> evaluate commands. > >> So far, we have this for "eval" stuff, but is there anyway to specify a > >> "parse in haskell" sort of thing? > > > > > > No, although you could fake it with the GHC-API (which basically means your > > bot has all of GHC built into it). > > > > In any case, that's not really a good idea; consider what damage could be > > done by arbitrary code. A better idea is to link the code into a small > > program with a very restricted environment and run that with a timeout. > > See http://code.haskell.org/lambdabot/Plugin/Eval.hs. > > Brandon is right that this is difficult and tricky -- but fortunately, > someone else has already done the hard work for you! Take a look at > the mueval package [1], which should allow you to do what you want. this raises a question for me, being a bit of a schemer. Is there any parallel in haskell to the data is code model of the lisp family? For example, playing around in scheme with a symbolic differentiator, it is trivial to then evaluate the differentiated s-expression at arbitrary value by representing the expression, and it's derivative as a regular scheme expression. Is this something that can be done in haskell? My initial impression is no, that you'd have to parse it as an expression and evaluate it as you would in regular imperative languages. I'd love to hear otherwise. A -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/beginners/attachments/20081027/9103e5ea/attachment-0001.bin ------------------------------ Message: 5 Date: Mon, 27 Oct 2008 23:26:58 -0400 From: "Brandon S. Allbery KF8NH" <[EMAIL PROTECTED]> Subject: Re: [Haskell-beginners] evaluation of expressions [was Re: eval command?] To: Andrew Sackville-West <[EMAIL PROTECTED]> Cc: beginners@haskell.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes On 2008 Oct 27, at 23:25, Andrew Sackville-West wrote: > this raises a question for me, being a bit of a schemer. Is there any > parallel in haskell to the data is code model of the lisp family? For > example, playing around in scheme with a symbolic differentiator, it > is trivial to then evaluate the differentiated s-expression at > arbitrary value by representing the expression, and it's derivative as > a regular scheme expression. > > Is this something that can be done in haskell? My initial impression > is no, that you'd have to parse it as an expression and evaluate it as > you would in regular imperative languages. I'd love to hear otherwise. You get this in a type-safe form with Template Haskell; you can operate on expressions at the AST level. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon university KF8NH ------------------------------ Message: 6 Date: Tue, 28 Oct 2008 16:30:37 +0100 From: [EMAIL PROTECTED] Subject: [Haskell-beginners] gtk2hs treeViewSetReorderable To: Beginners@haskell.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; DelSp="Yes"; format="flowed" Hello, I am using a TreeView from the TreeList package and a ListStore as its data model. I set treeViewSetReorderable to True and now rows can be drag-n-dropped around. The data in the ListStore gets updated as expected. I want to get notified, when the order of the elements in the list changes (or just, when something is draged around - even if it is dropped on the position it was taken from). In the documentation it says "..., then the user can reorder the model by dragging and dropping rows. The developer can listen to these changes by connecting to the model's signals." After hours of seaching, I still don't find where I have to connect to. Have you any clue? Best wishes, Nikolas Link to documentation: http://www.haskell.org/gtk2hs/docs/current/Graphics-UI-Gtk-TreeList-TreeView.html#v%3AtreeViewSetReorderable ------------------------------ Message: 7 Date: Tue, 28 Oct 2008 19:00:00 -0400 From: "Tony Hannan" <[EMAIL PROTECTED]> Subject: Re: [Haskell-beginners] evaluation of expressions [was Re: eval command?] To: "Brandon S. Allbery KF8NH" <[EMAIL PROTECTED]> Cc: beginners@haskell.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset="iso-8859-1" On Mon, Oct 27, 2008 at 11:26 PM, Brandon S. Allbery KF8NH < [EMAIL PROTECTED]> wrote: > On 2008 Oct 27, at 23:25, Andrew Sackville-West wrote: > >> this raises a question for me, being a bit of a schemer. Is there any >> parallel in haskell to the data is code model of the lisp family? For >> example, playing around in scheme with a symbolic differentiator, it >> is trivial to then evaluate the differentiated s-expression at >> arbitrary value by representing the expression, and it's derivative as >> a regular scheme expression. >> >> Is this something that can be done in haskell? My initial impression >> is no, that you'd have to parse it as an expression and evaluate it as >> you would in regular imperative languages. I'd love to hear otherwise. >> > > > You get this in a type-safe form with Template Haskell; you can operate on > expressions at the AST level. > > Yeah, but can you do this at run time? I though Template Haskell can only be used at compile time. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20081028/0e38537e/attachment-0001.htm ------------------------------ Message: 8 Date: Wed, 29 Oct 2008 00:33:32 +0100 From: [EMAIL PROTECTED] Subject: Re: [Haskell-beginners] gtk2hs treeViewSetReorderable To: Beginners@haskell.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; DelSp="Yes"; format="flowed" I undertook a second quest searching the gtk2hs documentation. The solution is to have a look at Graphics.UI.Gtk.ModelView.CustomStore. On a custom model are all the functions available that get called when something interesting happens in the view. Only connect the model to the view, that's it. The functions get called on the model and there is no need for some external to register call-back functions at the view. There's still the possibility for the model to accept call-back functions if required. Nikolas Zitat von [EMAIL PROTECTED]: > Hello, > > I am using a TreeView from the TreeList package and a ListStore as its > data model. I set treeViewSetReorderable to True and now rows can be > drag-n-dropped around. The data in the ListStore gets updated as > expected. > > I want to get notified, when the order of the elements in the list > changes (or just, when something is draged around - even if it is > dropped on the position it was taken from). > > In the documentation it says "..., then the user can reorder the model > by dragging and dropping rows. The developer can listen to these > changes by connecting to the model's signals." > > After hours of seaching, I still don't find where I have to connect to. > Have you any clue? > > Best wishes, > Nikolas > > Link to documentation: > http://www.haskell.org/gtk2hs/docs/current/Graphics-UI-Gtk-TreeList-TreeView.html#v%3AtreeViewSetReorderable > > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 9 Date: Tue, 28 Oct 2008 17:20:12 -0700 From: Andrew Sackville-West <[EMAIL PROTECTED]> Subject: Re: [Haskell-beginners] evaluation of expressions [was Re: eval command?] To: Tony Hannan <[EMAIL PROTECTED]> Cc: beginners@haskell.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset="us-ascii" On Tue, Oct 28, 2008 at 07:00:00PM -0400, Tony Hannan wrote: > On Mon, Oct 27, 2008 at 11:26 PM, Brandon S. Allbery KF8NH < > [EMAIL PROTECTED]> wrote: > > > On 2008 Oct 27, at 23:25, Andrew Sackville-West wrote: > > > >> this raises a question for me, being a bit of a schemer. Is there any > >> parallel in haskell to the data is code model of the lisp family? For > >> example, playing around in scheme with a symbolic differentiator, it > >> is trivial to then evaluate the differentiated s-expression at > >> arbitrary value by representing the expression, and it's derivative as > >> a regular scheme expression. > >> > >> Is this something that can be done in haskell? My initial impression > >> is no, that you'd have to parse it as an expression and evaluate it as > >> you would in regular imperative languages. I'd love to hear otherwise. > >> > > > > > > You get this in a type-safe form with Template Haskell; you can operate on > > expressions at the AST level. > > > > > Yeah, but can you do this at run time? I though Template Haskell can only be > used at compile time. That's what I'm talking about, run time evaluation of code/data. In scheme, I can take as input (+ (exp x 2) (* 2 x)) a representation of x^2 + 2x I can feed that "data" into a function (derive input) and get back (+ (* 2 x) 2) a representation of 2x +2, the derivative of the above. The function derive can manipulate that "Data" which is just a list, or s-expression like any other data (for example accessing the first element in the list, determining that it's a '+' and so calling derive recursively on the two following elements). then I can feed that result into (eval) with some information about what the value of x is and it will be evaluated just like a regular scheme expression. something like (it's been a while): (let ((x 2)) (eval default-environment (derive (input)))) where default-environment lets you get the information about the current environment into the eval environment so that x has a value. So now, what was "Data" a moment ago is treated as executable within the eval. The above (let) would spit out(in this case) a value of 6. Is such a thing possible in haskell? (I'm really just curious, I have no need of this functionality at this point). Oh, and I apologise for the fingernail clippings... A -- -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/beginners/attachments/20081028/90bb0d32/attachment.bin ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 4, Issue 15 ****************************************