Re: [Haskell-cafe] Interactive chatbot
No worries, I'd rather have it twice than not at all :-) Thank you all for the helpful tipps. We ended up knowing a lot more about Haskell. The easiest solution however, was to compile it all into an application - tadaa, deleting works as wished for. Regards, Torsten Am 05.11.2009 um 02:00 schrieb Ben Millwood: Oops, I clicked reply instead of reply to all. Duplicating the message below. I suppose this means someone is going to get two copies of this. Sorry someone! On Thu, Nov 5, 2009 at 12:56 AM, Ben Millwood hask...@benmachine.co.uk wrote: On Wed, Nov 4, 2009 at 10:21 PM, Torsten Otto t-otto-n...@gmx.de wrote: When we read the user's input through t - getLine it is not possible to delete typos before hitting enter and thereby sending the input off to the system (at least in OS X, bash). I didn't find that terribly problematic, but of course it is a bit of a show stopper from their point of view. As people have said it's worth checking what buffering settings you are using (especially note that ghci changes some interesting settings in relation to how input is handled, and compiled code may behave differently), but it might also be worth checking the terminal application's preferences to see if there are settings related to the interpretation of the backspace key that you need to twiddle one way or the other. In particular, if you are finding that pressing delete makes ^H appear on the input line instead of deleting things, or if pressing ctrl-H deletes stuff where the delete key fails to do so, it might be a problem with your terminal rather than with your program. This is only based on what I vaguely remember from faffing with the Mac Terminal application some time ago when it wouldn't co-operate with screen, but it may be worth a look. yours, Ben Millwood ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Interactive chatbot
Hi! My students have the task to program an interactive chatbot. We have run into a problem that I can't solve either: When we read the user's input through t - getLine it is not possible to delete typos before hitting enter and thereby sending the input off to the system (at least in OS X, bash). I didn't find that terribly problematic, but of course it is a bit of a show stopper from their point of view. The input is then used to generate a reply in purely functional code, and the reply sent to the command line via putStr. Is there a more clever way to interact with the user that would allow editing ones text before sending it to the bot? I guess we could try with a website, but don't know off hand how to do that, either, although I've seen beautiful webservers made in Haskell... Regards, Torsten Otto ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell and GUI
Gee, wizzz, folks. Thank you all for the many hints. I can't say yet which one I'll dive into but I'm in good spirits about Haskell and GUI now. I like the idea of a functional approach and I don't need extensive GUIs either, so Grapefruit just added another candidate... Using the Cocoa API or AppleScript bindings is very slick (I'll look into that), but I think I'd rather have a platform independent solution for my class. I'll do my best to post a beginners tutorial on the web where it may be found, but it'll likely be in German. I will definitely continue to recommend Haskell to my colleagues. Thanks again for your support, Torsten Am 17.01.2008 um 15:09 schrieb Wolfgang Jeltsch: Am Dienstag, 15. Januar 2008 20:42 schrieb Conal Elliott: If you can get wxHaskell installed working, you could try Phooey and/or TV. Both are described on the Haskell wiki and available via darcs and Hackage. And they have the interesting property of being a functional approach to GUI programming (similar to FranTk). Most of the other Haskell GUI toolkits are imperative in nature. And now my shameless plug: If you can get Gtk2Hs installed and working, you could try Grapefruit which is also a functional library. In addition to GUIs, it also supports animated graphics. At the moment, it’s main downside is that it supports only a small set of widgets (buttons, labels, edit fields and boxes). See http://haskell.org/haskellwiki/Grapefruit. Best wishes, Wolfgang ___ 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] Getting frantic with FranTk
Thank you for the encouragement, Justin. Unfortunately I did try that. But it may also be where my basic understanding is missing: the libraries - do I have to somehow compile all the source or can I just use it? The source is Haskell, but it all comes with makefiles - are these for use with GHC or something more? I have a feeling I have to compile something somehow into some special location. I guess I'll just keep mucking around until I find a clue somewhere... All I know so far is how to use modules in Hugs which is enough for High School, but there is so much more out there... The Readme points out for the underlying Tcl: *** If on unix compile up the TclPrim.so library and run the tclexe script, with hugs as the argument program ie ../bin/tclexe hugs *** Ok, I can find tclexe, but how do I compile up the TclPrim? Probably pretty standard, I'm working on that (hints would still be appreciated...). I'm confused at the point where the demo imports FranTk allright, but then I've hunted the web for missing modules which left me with something else missing: Hugs :l Demos.lhs ERROR ./Utils.hs - Error while importing DLL ./Utils.so: dlopen(./Utils.so, 9): image not found Foreign.Marshal.Alloc I don't begin to understand what this is telling me... If I get it to work, I'll put in on the Web for others to find. Torsten ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell and GUI
Seeing my woes with FranTk - what else is out there that people use if a (simple) GUI is desired for a Haskell app? Just a few textboxes and a button or two would do me. Thanks in advance! Regards, Torsten ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Newb: List of nodes in a graph - is there a prettier way?
Howdy, I'm working towards Dijkstra's algorithm here and I have a feeling that I could do without the helper function nodesInternal in the following code, if I only could figure out how. Any hints would be appreciated. nodes::Graph-[Id] should (and actually does) return a list of all nodes in the graph. Thanks a bunch in advance. Regards, Torsten Otto module Route where Datatypes for the representation of the graph: type Id = Int type Weight = Int type Edge = (Id,Id) type Graph = [ (Edge, Weight) ] graph::Graph graph = [ ((0,1),1), ((0,2),3), ((0,4),6), ((1,2),1), ((1,3),3), ((2,0),1), ((2,1),2), ((2,3),1), ((3,0),3), ((3,4),2), ((4,3),1), ((5,2),9)] data Cost = Finite Weight | Infinity deriving (Eq, Ord, Show) type PathCost = (Cost, Id) Return the number of edges in the graph: edges :: Graph - Int edges graph = length graph Calculate the sum of all weights: weightTotal::Graph - Weight weightTotal ((edge, weight):xs)| xs == [] = weight | otherwise = weight + (weightTotal xs) List all the nodes in the graph: nodes::Graph - [Id] nodes graph = nodesInternal [] graph nodesInternal::[Id]-Graph-[Id] nodesInternal list (((id1,id2),weight):xs) | (elem id1 list) (elem id2 list)= nodesInternal list xs | (elem id1 list) (not (elem id2 list)) = nodesInternal (id2:list) xs | (not (elem id1 list)) (elem id2 list) = nodesInternal (id1:list) xs | (not (elem id1 list)) (not (elem id2 list)) = nodesInternal (id1:id2:list) xs nodesInternal list [] = list Function for adding costs so that we can make use of Infinity for impossible routes: addCosts::Cost - Cost - Cost addCosts Infinity Infinity = Infinity addCosts Infinity (Finite x)= Infinity addCosts (Finite x) Infinity= Infinity addCosts (Finite x) (Finite y) = Finite (x + y) Return the cost of a given edge: lookUp::Edge - Graph - Cost lookUp (id1,id2) (((id1x,id2x),weightx):xs) | (id1==id1x id2==id2x) = Finite weightx | xs==[]= Infinity | otherwise = lookUp (id1,id2) xs ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe