Re: [Haskell-cafe] Simple GUI Form
Sure, and thanks for sharing. We need more declarative GUI building! On Sat, Dec 1, 2012 at 9:00 AM, timothyho...@seznam.cz wrote: I created that for a specific application I was writing, where I was saving the data directly to disk. I modularized as an afterthought. But I don't see anything wrong with using types that have JS in their names. It is STILL a haskell data structure. Just one which can be converted to a relatively universally parse-able String easily when needed ;) It's fine if you don't use gtk. I just wanted to show off my code :) Timothy -- Původní zpráva -- Od: Rune Harder Bak r...@bak.dk Datum: 30. 11. 2012 Předmět: Re: [Haskell-cafe] Simple GUI Form I know it's not wx, but if you were willing to use GTK, you could simply install: http://hackage.haskell.org/package/gtk-jsinput and generate the form automatically as described in: https://github.com/timthelion/gtk-jsinput/blob/master/Graphics/UI/Gtk/Custom/JSInput.hs Cool! Would rather see it generated from the haskell data structure than from json, but you could of cause generate json from the data type. My understand is that GTK applications don't look and feel native on windows/mac, that's why I went for wx, but I could easily be wrong. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Simple GUI Form
Of course. There is no reason to think that FRP is limited to real-time applications with complicated interactions. (...) there is a somewhat comprehensive tutorial [1] as well as lots of examples [2] linked from the wiki. Thank you for the links. I read it and looked at the examples. It seems you still need to build up the wx gui the same way as using wx directly and be sure it is in sync with the datatype. You just handle the logic with reactive-banana. As there really is almost no logic involved it gives too much overhead, needing to convert all the widgets to behaviors etc. I got the form working in wx, so I'll stick with that for now! Thanks! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Simple GUI Form
I know it's not wx, but if you were willing to use GTK, you could simply install: http://hackage.haskell.org/package/gtk-jsinput and generate the form automatically as described in: https://github.com/timthelion/gtk-jsinput/blob/master/Graphics/UI/Gtk/Custom/JSInput.hs Cool! Would rather see it generated from the haskell data structure than from json, but you could of cause generate json from the data type. My understand is that GTK applications don't look and feel native on windows/mac, that's why I went for wx, but I could easily be wrong. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Simple GUI Form
Hi I have some input parameters data Input = ... that I need the user to enter in a gui pop-up. (windows people...) The rest of the app is not gui (or perhaps progress could be displayed in a log-window) What is the easiest way to make such a GUI form? It need to compile for both Linux and Windows, so I though WxWidgets was ideal, and I got wx[1] 0.90 to install (using wxWidgets2.8) on both windows and linux. Now I just need to create the form, but how do you do that? Any clues or links to examples? I have never used wxwidgets on any platform or done any other form of GUI before for that matters. (apart from some Visual Basic ten years ago, and html). I tried looking at wx examples, but I couldn't find this simple use case explained anywhere. I installed wx in the first place because WxGeneric[2] seemed exactly what I needed, but I can't get it to compile using ghc7.4.2 from haskell-platform. Anybody got that working or have some other simple method? Help much appreciated! -Rune [1] http://hackage.haskell.org/package/wx-0.13.2.3 [2] http://hackage.haskell.org/package/WxGeneric ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Simple GUI Form
I'm very interested in FRP, but all the examples I could see was forms with live feedback gui like a real-time calculator. This is a one-time form where the user fills everything in, clicks on a button, where after the computations might take a long time, perhaps display some console-info. But maybe this is a good use-case for reactive-banana as well? Do you have any good examples in this regard? On Thu, Nov 29, 2012 at 2:37 PM, Ertugrul Söylemez e...@ertes.de wrote: Hi there Rune, if you want to get started with declarative GUI programming in Haskell, I really recommend taking the FRP route. Check out the reactive-banana-wx [1] library instead of using wxHaskell directly. If you manage to get wxHaskell working on Windows, then reactive-banana will work as well. [1]: http://www.haskell.org/haskellwiki/Reactive-banana Greets, Ertugrul Rune Harder Bak r...@bak.dk wrote: I have some input parameters data Input = ... that I need the user to enter in a gui pop-up. (windows people...) The rest of the app is not gui (or perhaps progress could be displayed in a log-window) What is the easiest way to make such a GUI form? It need to compile for both Linux and Windows, so I though WxWidgets was ideal, and I got wx[1] 0.90 to install (using wxWidgets2.8) on both windows and linux. Now I just need to create the form, but how do you do that? Any clues or links to examples? I have never used wxwidgets on any platform or done any other form of GUI before for that matters. (apart from some Visual Basic ten years ago, and html). I tried looking at wx examples, but I couldn't find this simple use case explained anywhere. I installed wx in the first place because WxGeneric[2] seemed exactly what I needed, but I can't get it to compile using ghc7.4.2 from haskell-platform. Anybody got that working or have some other simple method? Help much appreciated! -Rune [1] http://hackage.haskell.org/package/wx-0.13.2.3 [2] http://hackage.haskell.org/package/WxGeneric -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. ___ 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] List all multiply/add combinations
On Sun, Nov 18, 2012 at 2:04 PM, Stefan Klinger all-li...@stefan-klinger.de wrote: Sounds like you would want to enumerate all possible *abstract* syntax trees, these implicitly have exactly the necessary parentheses. I'd do this recursively, splitting the sequence of numbers in two at all possible places, and then combine the corresponding results with all possible operators. That was my second idea, but just doing it naively resulted in many equivalent calculations, so I thought there might be a better way to view the problem. But as Artyom showed On Sat, Nov 17, 2012 at 11:37 PM, Artyom Kazak artyom.ka...@gmail.com wrote: Indentation messed up… I have pasted the code here: http://hpaste.org/77864 enumerating the abstract syntax tree is actually (or at least could be) the way to go! Thanks a lot! What I need is a little bit different, but now I feel I'm on the right track! This is my first question to the café and it makes me a lot more certain using Haskell for production, when you can get this kind of quick and thorough help when in doubt. Great community! -Rune ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] List all multiply/add combinations
Given a list of numbers of fixed length I need to list all possible values (and the associated computation) you get by inserting +,-,*,/ between the numbers, and also set parentheses where you please. It shouldn't list computations with unnecessary parentheses. Example list of length 3 [a,b,c] and only with + and *: a*b+c, a*(b+c),a*b*c,a+b*c,(a+b)*c,a+b+c What would be a good way to do this, and a good representation in Haskell? Best, Rune ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] List all multiply/add combinations
It might be rare that a real world problem can be formulated as such a simple mathematical challenge, so I can't blame you for thinking about home work. I did too. Actually it's part of a logic puzzle I'm implementing. Attacking the problem textually, I can treat the list of infix operators as char, and insert parentheses in all possible configurations. Then remove the illegal and unnecessary one. To get the result, I then need to parse the string. That seems slow, and awkward. I need to do hundreds of thousands of these calculations. I could then work directly with parsing trees, and generate all binary trees of fixed lengths. But most of them would be unnecessary, so it seems like I'm attacking it from the wrong angle. I get that using permutations you can get rid of the need for parentheses, but you also get a lot of impossible calculations (like a*c+b in the example before). It's also not straight forward to go back to the original representation with parentheses. But maybe I'm missing something obvious here? On Sat, Nov 17, 2012 at 4:18 PM, timothyho...@seznam.cz wrote: This smells like homework to me, which isn't a bad thing, it will however change the way I answer you. Please look at http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-List.html#v:permutations and show us your attempts to use this function. Timothy -- Původní zpráva -- Od: Rune Harder Bak r...@bak.dk Datum: 17. 11. 2012 Předmět: [Haskell-cafe] List all multiply/add combinations Given a list of numbers of fixed length I need to list all possible values (and the associated computation) you get by inserting +,-,*,/ between the numbers, and also set parentheses where you please. It shouldn't list computations with unnecessary parentheses. Example list of length 3 [a,b,c] and only with + and *: a*b+c, a*(b+c),a*b*c,a+b*c,(a+b)*c,a+b+c What would be a good way to do this, and a good representation in Haskell? Best, Rune ___ 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] Interest in typed relational algebra library?
Yes, that would be very nice! Type-checked queries really is a must, but I´ve found HaskellDB too cumbersome to work with. -Rune On Sat, Jul 7, 2012 at 11:45 AM, Paul Visschers m...@paulvisschers.net wrote: Hello, I've been out of the Haskell game for a bit, but now I'm back. A couple of years ago I made a small library that implements relational algebra with types so that malformed queries and other operations are caught at compile time. It is heavily based off of the internals of HaskellDB (see http://hackage.haskell.org/packages/archive/haskelldb/2.1.1/doc/html/Database-HaskellDB-PrimQuery.html), but types so that it can actually be used directly instead of having to use HaskellDB's query monad. Besides the joy of using relational algebra directly in your code, this also means that you can make query-optimizing code in a type-safe way, you can subquery results returned by the database directly without accessing the database again and you have more options when converting from relation algebra to SQL or another query language. The library isn't quite ready for release, but I might want to work on it a bit and then release it. Is anyone interested in such a library? Paul Visschers ___ 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
[Haskell-cafe] Idiomatic Aeson
Hi I'm trying to parse a nested structure using Aeson (from Facebook) It looks something like this: { education: [ { school: { name: A }, }, { concentration: [ { name: B } } ]} And besides this there is a lot of fields I don't need. (And a lot of other fields I do need) What is the idiomatic aeson way of doing this? I'm using Aeson because it's fast, and it seams to have all the relevant combinators, just can't get them to play nicely together. I was thinking something like getInfo (Object m) = (,) $ m .: school .: name * mapM (.: name) (m .: concentracion) but of cause the types don't add up. the verbose style like getInfo (Object m) = do school - m .: school schoolName - case school of Object m' - m' .: name l - typeMismatch schoolName l concentration - m .: concentration concentrationName - case concentration of Array l - forM (V.toList l) $ \m' - case m' of Object m' - m' .: name l - typeMismatch concentrationName l ) o - typeMismatch parseList o return (schoolName,concentrationName) quickly explodes. So I wrote my own functions of the following sort parseName name _ (Object m) = m .: name parseName _ err l = typeMismatch err l parseList p (Array l) = mapM p $ V.toList l parseList _ o = typeMismatch parseList o so I can do something like getInfo (Object m) = (,) $ parseName school school m = parseName name schoolName * parseName concentration concentration m = parseList (parseName name concentrationName) And then variants for for .:?, but then it gets messy with = and maybe. Getting rid of the m in the above I moved to arrows, and.. it seems I'm not understanding the standard combinators. So.. what is the idiomatic way of doing this in Aeson? It shouldn't be necessary to move to template-haskell/generics to do this! Thanks! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange No instance error with cabal install
Sorry, forgot to send to the list, But everything works today, and the commit was pulled from aeson to aeson-native, so that must have been it. Thanks! On Wed, Sep 21, 2011 at 8:20 AM, Rune Harder Bak r...@bak.dk wrote: So you are saying, that this is basically because he has other version of different packages, not providing the same instances, that makes sense. The other problem was no instance for Default (Request R) (Request from Network.Wai) It was provided by http-enumerator, but maybe not in his version of the package. I tried with aeson-native after you post without look, but I see a new one has been released now. Going to try it today. Thanks! On Tue, Sep 20, 2011 at 2:00 PM, Roel van Dijk vandijk.r...@gmail.com wrote: I see the aeson version with the stricter dependency on deepseq 1.2 is now also released on hackage: http://hackage.haskell.org/package/aeson-0.3.2.12 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Strange No instance error with cabal install
Sometimes when one of our developers (using Arch-linux) tries to cabal install packages he gets a no instance for error. Code that compiles fine on my computer, and other computers I try it on. Even some packages on hackage (trying to install aeson-native for instance gives Data/Aeson/Types.hs:196:22: No instance for (NFData Object) arising from a use of `rnf' Possible fix: add an instance declaration for (NFData Object) In the expression: rnf o In an equation for `rnf': rnf (Object o) = rnf o In the instance declaration for `NFData Value') I tried removing the .ghc and .cabal folder, even reinstalled ghc-7.04 and cabal-install (most recent), but the problem persisted (might not have been a clean install though, I'm no Arch expert) I know this is kind of vauge, and not in she shape of filling a bug report, heck I can't even reproduce the error on my computer. But perhaps somebody else has run in to this strange behavior before? Best, Rune ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe