Re: [Haskell-cafe] Shortening if-then-else
Is there a shorter way to write the if-then-else part below? if (cmdType cmd) /= (CmdSitError Server) then return $ Just seat_num else return Nothing return $ if cmdType cmd /= CmdSitError Serv then Just seat_num else Nothing Arjan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parsec, state and/of my cluelessness
Hi Niklas, ctrlBodyParser :: CharParser ([Value], [Property], [Control]) ([Value], [Property], [Control]) ctrlBodyParser = do { c - ctrlParser -- parse child control ; (vs, ps, cs) - getState ; setState (vs, ps, (c : cs)) ; ctrlBodyParser } | do { p - propParser -- parse child property ; (vs, ps, cs) - getState ; setState (vs, (p : ps), cs) ; ctrlBodyParser } | do { v - valueParser -- parse value ; (vs, ps, cs) - getState ; setState ((v : vs), ps, cs) ; ctrlBodyParser } | do { getState } -- we're finished, return children Uhm, maybe I'm being clueless here but I never use state to pass around results. This looks like a place where you want to parse many subparsers: ctrlBodyParser = many parseOneCtrlBody parseOneCtrlBody = do { c - ctrlParser; return (Control c)} | do { p - propParser; return (Property p)} | do { v - valueParser; return (Valuev)} data CtrlBody = Control | Property | Value Of course, ctrlBodyParser then has type [CtrlBody] so if you want your triple of lists you have to postprocess the list. Anyway, I don't think parsec state is what you want to use here and explicit recursion of parsers can often be avoided using the many (pun intended) combinators of Parsec. Cheers, Arjan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Existential problem
Haha! I like the subject of this message :) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GUI
However, I want to know if there has been any practical standardisation in the GUI area. Last time I looked at this it seemed some decisions had been made (bind to existing api - wxWindows?). I am waiting for some real standardisation and a mature API before I jump ship from Java for my day-to-day programming. wxHaskell is available at http://www.wxhaskell.sfnet.org/ It runs on Windows, Linux and MacOS X. It has many GUI controls, database access, is well documented and perfectly stable. We use this toolkit for a Bayesian network tool, Dazzle. See http://www.cs.uu.nl/dazzle/images/screenshot.jpg for a screenshot. Have fun, Arjan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GUI
It seems a bit of a stretch to call wxhaskell perfectly stable, when it seems that the API changes with each release... It's definitely a working interface, but I wouldn't really call it a stable one. I guess it is stable in the sense that it doesn't crash. Yes, you are right. I meant the latter meaning of the word 'stable'. The interface has changed considerably at version 0.8 but will hardly (if at all) be changed at 0.9. Maybe Daan himself can shed some more light on the matter. Cheers, Arjan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ????Pattern match(es) are overlapped???
newtype Method = Method String getMethod = Method GET putMethod = Method PUT [...] doMeth getMethod = ... doMeth putMethod = ... For Haskell the last two lines look both like pattern-matching on a variable which always matches. You might as well have written: doMeth x = ... doMeth y = ... There is no macro facility in Haskell so you cannot give patterns a name like you do in line 2 and 3. You will have to write: doMeth (Method GET) = ... doMeth (Method PUT) = ... Good luck, Arjan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Dividing integers?
I don't understand why I get this error. I mean, apparently / is not defined for integers but I don't know how to cast the result of the length function into a Double... Use div for dividing integers with loss of precision: 3 `div` 2 (or: div 3 2) == 1 Casting an Int to a Float/Double can be done using fromIntegral: fromIntegral (length [1,2]) / 3 == 0. Besides, a simple integer division works: Prelude 2 / 3 0. This is not an integer division. Writing down a literal (like 2 or 3) denotes a number, not necessarily an Int. The context will influence what type it will be. Something I find really confusing myself, too (which is why it is not in Helium :-). Greetings, Arjan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building Haddock on Windows
Hello Alistair, Where can I find instructions for use? I see haddock.sgml in haddock-0.6/haddock/doc but reading sgml hurts. Is there an html version of this somewhere? Haddock is very well documented at http://www.haskell.org/haddock/ Greetings, Arjan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: a monadic if or case?
whatisit :: String - IO String whatisit f = do ifM doesDirectoryExist f then return dir else ifM doesFileExist f then return file else return nothing Is there any way I could do something like this? Not with the syntactic sugar of 'if'. But you can write [warning: untested code ahead] ifM :: IO Bool - IO a - IO a - IO a ifM test yes no = do b - test if b then yes else no And then ifM (doesDirectoryExist f) (return dir) (ifM (doesFileExist f) (return file) (return nothing)) ) Arjan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Learning Haskell moved
Hello all, The Learning Haskell page has moved to a better place, the official Haskell homepage. You can now find it at http://www.haskell.org/learning.html and through a link on the Haskell homepage index. Jerzy wrote: I would add some significant papers, such as John Hughes' Why functional programming matters, etc. I've added that paper to the introduction. Other suggestions are welcome. and perhaps - for some, a little bit advanced readers - some other papers, introducing type classes, perhaps monads (Wadler) I have added a link to the comp.lang.functional FAQ. It answers many questions beginners might have about functional programming in general, but also about specific languages. And it tells you which papers to read about monads. [...] perhaps be a good idea to put down a relatively comprehensive, easy comparison between Haskell and other languages, notably functional: Clean, also: Scheme, absolutely: ML variants, and Erlang. Good idea. I've started a table which you can find a link to in the Learning Haskell introduction. If people have suggestions for other columns, can fill in question marks, know of more important languages, tell us. Or, if you have writing permissions on the Haskell homepage, update the table. Cheers, Arjan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Functional programming in Python
For humans, it is quite natural to use visual cues (like layout) to indicate semantics. I agree, but let us not try to do that with just two (already overloaded) symbols. (let ((a 0) (b 1)) (+ a b)) let { a = 0; b = 1; } in a + b is valid Haskell and the way I use the language. Enough and more descriptive visual cues, I say. Using layout is an option, not a rule (although the thing is called layout rule...) But all this is not very constructive, because Haskell is not going to change into a fully parenthesized prefix syntax at my wish. Thank god :-) Arjan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe