Re: [Haskell-cafe] ANN: Angel 0.4.4
31.07.2013, 05:03, "Michael Xavier" mich...@michaelxavier.net:angel is a daemon "angel is a background process" sounds better. Sorry for offtopic ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Object Oriented programming for Functional Programmers
Well, we can say "concepts" in place of "theory". And I'm comparing Eiffel with other OOP lang, not with some langs based on a solid math theory (lambda calcules for FP langs, for example). ok? DbC is not the same as "assert macros". First, it has a lang semantic. There is an interesting graduated mechanism to turn off or turn on conditions' checking. Dbc is not only initeresting "concept" of lang. Meyer is considering class as a type in his type system. By the way, preconditions and postconditions of class and its subclass have to be consistient. I don't remeber all details now, as I remeber preconditions of subclass are automaticly logically 'and'ed to preconditions of superclass. This supports "concept" of "class is type" and "subclass is a same type as superclass". Other "concept" - classes are only modules. Other "concept" - "command/query separation" = dividing functions on functions that change state of object and on functions that query some info from function (sic. pure functions!). Other "concept" - polymorphic types (general types) - parametrisied types, including constrained parametrisied types (MAP [V, K - HASHABLE]). Other "concept" - solving multiple inherient problem - "name clashing" And so on. BTW. Why you think that Eiffel type system is unsafe? I don't what is a situation with java type now (not using java for several yeas), but I thought that java type system is more unsafe that eiffel type system. (They said that there were generic types in java). And BTW, smalltalk is a lang with dynamic type system. PS. In structuring programming, to prove correctness of loop construction, you have to write down precondition of loop, loop invariant, loop postcondition. You have to (mathamaticly) prove: if precondition holds than invariant holds (and in result we get solved postcondition).___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Object Oriented programming for Functional Programmers
Opps... I forgot about Eiffel agents! PS. After participationing in this discussion I'm tempting to reread Meyer's book after 10 years interval, to have a detailed look at the eiffel from the FP position. When I read this book first I know nothing about FP. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Object Oriented programming for Functional Programmers
Eiffel, for my opinion, is a best OOP language. Meyer use a theoretical approach as it is possible in OOP. 01.01.2013, 23:56, "Bob Hutchison" hutch-li...@recursive.ca:On 2012-12-31, at 4:26 PM, Rico Moorman rico.moor...@gmail.com wrote:Hello Bob and Mike, Reading a little within the suggested book I came across the following statement. We should first examine the merits and limitations of the traditional approach: usingfunctions as a basis for the architecture of software systems. This will not only lead us toappreciate why we need something else — object technology — but also help us avoid, when we do move into the object world, certain methodological pitfalls such as prematureoperation ordering, which have been known to fool even experienced O-O developers. Because you both have more experience with this piece of literature, how would you interpret it? With a grain of salt or would function really mean procedure from the viewpoint of the author? He is talking about functions/procedures as in C, Pascal, Algol… structured programming basically. The first edition was written in 1988, the second about 10 years later. However, today, I *think* he might include functions as found in modern functional languages in this, and as you read on in the book you'll see why I say this. I've been considering re-reading OOSC2 for a while now (it is, believe it or not, a fun book… well, maybe that's just me) and keep Haskell and ML in mind while reading it. Meyer is trying to thoroughly explain the reasoning behind OO in this book, it isn't really a critique of anything especially (except indirectly other OO languages). Meyer can be scathing but you'll have to look elsewhere for the best/worst/most fun of that. Haskell, as it matures, is going to have to have an answer for everything in this book (answers may include 'pass' as Meyer does with Eiffel on a few issues–there's no shame in admitting Haskell, or anything else, doesn't have all the answers)… he's talking about issues that are independent of programming language. Cheers,Bob Thank you very much in advance. Best regards, Rico MoormanOn Mon, Dec 31, 2012 at 6:13 PM, Bob Hutchison hutch-li...@recursive.ca wrote:On 2012-12-30, at 2:58 PM, Daniel Díaz Casanueva dhelta.d...@gmail.com wrote: Well, my curiosity is bringing me to learn a new general purpose programming language. Haskellers are frequently comparing Object-Oriented languages with Haskell itself, but I have never programmed in any OO-language! (perhaps this is an uncommon case) I thought it could be good to me (as a programmer) to learn C/C++. Many interesting courses (most of them) use these languages and I feel like limited for being a Haskell programmer. It looks like I have to learn imperative programming (with side effects all over around) in some point of my programming life. So my questions for you all are:* Is it really worthwhile for me to learn OO-programming?Yes. And you should learn OO *very* well. And remember, OO doesn't really get interesting until the program gets big. As for languages I'd suggest Smalltalk or Eiffel, perhaps both. The big advantage to Eiffel is that you have Object Oriented Software Construction (second edition (not first)) to work from. Every OO language has to answer to the issues brought up in OOSC2 (and they don't/can't). Eiffel's inheritance mechanism is also one of the few that let you use inheritance to do useful things (OOSC2 names 16 or 18 different uses for inheritance… it's not just for 'is-a' relationships). Eiffel also has a contract system that's powerful enough to be useful. Smalltalk's advantage is that it will also introduce you to the idea of a programming 'system', for lack of better words. Smalltalk works in a live system, as you are writing code you are modifying live and already executing code. Once you realize that the 'best' editor in Smalltalk is the debugger (and what 'a good debugger' actually means) you'll understand test-driven-development's origins. This is very different from Haskell. Actually, you should probably learn both languages. I don't think C++ will help you learn OO, or much of anything else either. Vigorously avoid is my advice.C you're probably going to have to learn sooner or later but wait until you have to. And it's not OO at all. Though, if you learn KR C (pre-ansi C) you'll get a better understanding of why people liked OO so much :-) Ruby might be an easy route to OO too. I like the language quite a lot, but I'm not sure I'd recommend it for your purposes.* If so, where should I start? There are plenty of "functional programming for OO programmers" but I have never seen "OO programming for functional programmers". * Is it true that learning other programming languages leads to a better use of your favorite programming language?That's been my experience. And it'll be harder to name your favourite language too.* Will I learn new programming strategies that I can use back in the Haskell world?Probably.Cheers,BobThanks in advance
Re: [Haskell-cafe] Object Oriented programming for Functional Programmers
I said "theoratical", but not "mathematical" or "a scientific" theory. Meyer have built a quite coherent construction in comparison with other OOP langs. BTW, when I started study haskell i had similar question: is it possible to add DbC to haskell? Does haskell need DbC?For example, class invariants may be expressed in DbC construction (fmap id = id for Functior, for example). 02.01.2013, 02:41, "Mike Meyer" m...@mired.org:MigMit miguelim...@yandex.ru wrote:On Jan 1, 2013, at 10:23 PM, Никитин Лев leon.v.niki...@pravmail.ruwrote: Eiffel, for my opinion, is a best OOP language. Meyer use atheoretical approach as it is possible in OOP.Really? Because when I studied it I had a very different impression:that behind this language there was no theory at all. And it's onlyfeature I remember that is not present in mainstream languages is it'spre/postconditions system, which looked like an ugly hack for me.I agree with Leon. Of course, I learned it out of OOSC2, which provides the theory. When compared to "mainstream" OO languages like C++, Java or Python, it's on a much solider theoretical basis. Compared to something like Scheme, Haskell or even Clojure, maybe not so much.On the other hand, one persons theory is another persons hack. The theory behind the pre/post conditions is "Design by Contract". The contracts are as important as the type signature, and show up in the auto-generated docs in eiffel systems. I found at least one attempt to add DbC features to Haskell. I'm not sold on it as a programming technique - the bugs it uncovers are as likely to be in the pre/post conditions as in the code.-- Sent from my Android tablet with K-9 Mail. Please excuse my swyping.___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Instead of Haskell running on the JVM is there a way for Haskell to call a JVM language ...
And I'd be very interested.Let me know too, please. 20.11.2012, 13:32, "John Wiegley" jo...@newartisans.com: KC kc1...@gmail.com writes: Instead of Haskell running on the JVM is there a way for Haskell to call a JVM language (or generate bytecode) to access the Java class libraries when needed? Or Is there a way for a JVM language or bytecode to call Haskell when needed?I'd be very interested to know the answer to this as well. Please let me knowwhat you discover.John___Haskell-Cafe mailing listHaskell-Cafe@haskell.orghttp://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] HXT: how to get sibling element
Thanx to all. I've done it! === import Text.XML.HXT.Core import Text.XML.HXT.Curl import Text.XML.HXT.HTTP import Control.Arrow.ArrowNavigatableTree pageURL = http://localhost/test.xml; main = do r - runX (configSysVars [withCanonicalize no, withValidate no, withTrace 0, withParseHTML no] readDocument [withErrors no, withWarnings no, withHTTP []] pageURL getChildren isElem hasName div (getTitle + getSections)) putStrLn Articles: putStrLn mapM_ putStrLn $ map (\i - (fst i) ++ is ++ (snd i) ++ \n) r putStrLn getTitle = listA (getChildren isElem hasName span) arr head getChildren getText arr trim arr (Title,) getSections = addNav listA (getChildren withoutNav (isElem hasName span)) arr tail unlistA ((getChildren remNav getText) (listA followingSiblingAxis arr head remNav getText arr (rc . trim))) ltrim [] = [] ltrim (' ':x) = ltrim x ltrim ('\n':x) = ltrim x ltrim ('\r':x) = ltrim x ltrim ('\t':x) = ltrim x ltrim x = x rtrim = reverse . ltrim . reverse trim = ltrim . rtrim rc (':':' ':x) = x rc x = x == ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] HXT: how to get sibling element
Hello, haskellers. Suppose we have this xml doc (maybe, little stupid): div spanSome story/span spanDescription/span: This story about... spanAuthor/span: Tom Smith /div In the end I whant to get list: [(Title, Some story), (Description,This story about...), (Author, Tom Smith)], or, maybe this: Book Some story [(description,This story about...), (Author, Tom Smith)] (Book = Book String [(String, String)]. First span is a special case then others and I undestand how to process it: === import Text.XML.HXT.Core import Text.XML.HXT.Curl import Text.XML.HXT.HTTP pageURL = http://localhost/test.xml; main = do r - runX (configSysVars [withCanonicalize no, withValidate no, withTrace 0, withParseHTML no] readDocument [withErrors no, withWarnings no, withHTTP []] pageURL getChildren isElem hasName div listA (getChildren hasName span) getTitle + getSections) putStrLn Статьи: putStr mapM_ putStr $ map (\i - (fst i) ++ : ++ (snd i) ++ | ) r putStrLn getTitle = arr head getChildren getText arr trim arr (Title,) getSections = arr tail unlistA ((getChildren getText arr trim) (getChildren getText arr trim)) ltrim [] = [] ltrim (' ':x) = ltrim x ltrim ('\n':x) = ltrim x ltrim ('\r':x) = ltrim x ltrim ('\t':x) = ltrim x ltrim x = x rtrim = reverse . ltrim . reverse trim = ltrim . rtrim === And I' get list: [(Title, Some story), (Description,Description), (Author, Author)] (Maybe, there is a better way to get this list?) But I cannot find a way to get text that followes some span. I suppose that I have to use function from Data.Tree.NavigatableTree.XPathAxis, but I don't puzzle out how to do it. Please, help me. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] HXT: how to get sibling element
I absolutly agree with you but unfortunetly, it is not my xml file.It is extraction from html page of public web server. I cannot to change format of this html page.Sorry. I had to explain it in first letter. But than what about to get sibling text (geting sibling is an separate interesting tasks with no matter for my contrete case). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HXT: how to get sibling element
Oh, yes! In this situation with so poor structured source I can try to use tagsoup. (or I'll take a look at xml-conduit). Nevertheless for better undestanding HXT it will be interesting to solve this problem in HXT. Or is it impossible? 15.03.2012, 20:08, Asten, W.G.G. van (Wilfried, Student B-TI) w.g.g.vanas...@student.utwente.nl: You might want to check out the xml-conduit package. It has preceding and following sibling Axis. I am not sure how the package works exactly, but it seems to be a good starting point. 2012/3/15 Никитин Лев leon.v.niki...@pravmail.ru: I absolutly agree with you but unfortunetly, it is not my xml file. It is extraction from html page of public web server. I cannot to change format of this html page. Sorry. I had to explain it in first letter. But than what about to get sibling text (geting sibling is an separate interesting tasks with no matter for my contrete case). ___ 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] puzzling polymorphism behavior (7.0.3 windows)
Maybe everytime you use 'cell' you tell haskell to create NEW cell. Try this: push' i cell = modifyIORef cell (++ [i]) main = do cell - newIORef [] push' x cell {- push' 3 cell will be incorrect in this case -} push' o cell readIORef cell = return Why the original code porduces [(),()] but not [] I cannot undestand. 15.03.2012, 23:53, gladst...@gladstein.com gladst...@gladstein.com: Why does the following program compile and produce the results it does? It seems like 3 and x got interpreted as the same type, (). Thanks in advance for your help. import Data.IORef import System.IO.Unsafe cell = unsafePerformIO $ newIORef [] push i = modifyIORef cell (++ [i]) main = do push 3 push x readIORef cell = return *Main :browse cell :: GHC.IORef.IORef [a] push :: a - IO () main :: IO [a] *Main main [(),()] ___ 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] On the purity of Haskell
29.12.2011, 23:55, Gregg Reynolds d...@mobileink.com: Haskell does not and cannot know what the result of an IO action is, because it's outside the scope of the language (and computation). (The Int part of IO Int refers to the input, not the output; it's just a sort of type annotation.) It's not even a computation, unless you want to take a broad view and include oracles, interaction, etc. in your definition of computation. Yes, purity is a property of language. It's matter to thinking of algorithms and expressing these algorithms in computer language. It's not matter (in general) for programmers what PC would be do with IO computation. We want to have an expressive instrument and want to have a robust language. We want to have a language that can give us possibility to express our algorithms in clear, easy to understand, proven ways. And purity property of language is about it. It's not interesting to programmers what means purity to compile or to runtime system. It maybe interesting if we can realize effective compiler form language with purity property to machine codes. But haskell shows us than it's possible. Isn't it? --- PS sorry for my not good French ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] On the purity of Haskell
Of course we take in matter what computation getStr :: IO [Char] means. Of course we take in matter what computation putStr :: String - IO () means (I know, putStr is not computation, puStr x is computation, but it's not important) And If I want to write echo program, I have to combine these computation in such manner: echo = do s - getStr putStr s But for geometry I have similarly situation. I know arithmetics and I know Pythagoras theorem and I combine arithmetics operations to get length of hypotéinusa: h x y = sqrt $ x * x + y * y. What is difference of IO actions and PURE operation *? I have to know meaning of getStr action but I have to know meaning of * operation. Side effects appears in impure languages when we can different results of function (procedure etc) with same parameters. For example, when our function use global (modifible) variable. But we WANT that ours function (Int - Int, Char - [a], b - IO a - it's not matter) will be PURE, becourse it makes life of programmers easy. But I don't understand importance of thinking about side effects in dilemma of language vs compiled pogramm. 30.12.2011, 02:21, Heinrich Apfelmus apfel...@quantentunnel.de: Gregg Reynolds wrote: Donn Cave wrote: Quoth Gregg Reynolds wrote: Look again at the sentence you trimmed off the end: Of course, the point is that this result is an *IO action* of type IO Int, it's not the Int you would get when executing this action. I believe that more or less points to the key to this discussion. If it didn't make sense to you, or didn't seem relevant to the question of pure functions, then it would be worth while to think more about it. Ok, let's parse it out. …it's not the int you would get 'when executing this action. Close, but no cooky: it's not any kind of int at all (try doing arithmetic with it). IO Int is a piece of rhetoric for the mental convenience of the user; Haskell does not and cannot know what the result of an IO action is, because it's outside the scope of the language (and computation). (The Int part of IO Int refers to the input, not the output; it's just a sort of type annotation.) It's not even a computation, unless you want to take a broad view and include oracles, interaction, etc. in your definition of computation. Why would IO Int be something special or mysterious? It's an ordinary value like everything else; it's on the same footing as [Char], Maybe Int, Int - String, Bool, and so on. I see no difference between the list [1,2,3] :: [Int] and the action pick a random number between 1 and 6 :: IO Int . Best regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com ___ 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] On the purity of Haskell
If seed depends of psudo random event, for example of current systime, we must use IO action. 30.12.2011, 02:47, Steve Horne sh006d3...@blueyonder.co.uk: BTW - why use an IO action for random number generation? There's a perfectly good pure generator. It's probably handy to treat it monadically to sequence the generator state/seed/whatever but random number generation can be completely pure. ___ 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] Happstack, RqData: (How) can I extract multiple data from form?
Пересылаемое сообщение 20.10.10, 00:22, Никитин Лев leon.v.niki...@pravmail.ru: Are formlets integrated with HSP? hsp support is in a separate package: http://hackage.haskell.org/package/formlets-hsp There is a demo of using HSP+Formlets+Happstack here: http://src.seereason.com/formlets-hsp/examples/happs-hsp/ hope this helps! - jeremy Thanks! (Sorry for my stuped question) Завершение пересылаемого сообщения ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Fwd: [Haskell-cafe] Happstack, RqData: (How) can I extract multiple data from form?
Пересылаемое сообщение 18.10.10, 23:58, Никитин Лев leon.v.niki...@pravmail.ru: Пересылаемое сообщение 18.10.10, 23:57, Никитин Лев : Well. Thanks. I've just have a look at formlets. I think is what i need. But I'm using now HSP. Are formlets integrated with HSP? (I saw olny using formlets with text.xhtml). And [after discussion of Web wiki page] what is props and cons of using HSP? For newbiers it will be good idia to include some comparison between web frameworks, templating systems etc. (their props and cons). The following looks like something that you might want: http://hackage.haskell.org/packages/archive/formlets/0.7.3/doc/html/Text-Formlets-MassInput.html See the source for more clues about its use: http://hackage.haskell.org/packages/archive/formlets/0.7.3/doc/html/src/Text-Formlets-MassInput.html#massInput More about the Formlets library here: http://www.haskell.org/haskellwiki/Formlets Завершение пересылаемого сообщения Завершение пересылаемого сообщения ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe