7 ms·
Programming at the specification level with Haskell
- noelwelsh 12y agoThis article assumes too much background -- not of Haskell but of the authors prior work. It starts off: "I have a problem: How I present the few applicative and monadic combinators that I just developed." Ummm ... which combinators? At least provide a link to the prior article that I assume introduced them. As introductions go, this article's introduction doesn't do a very good job.
- agocorona 12y agoNo, I mean "the combinators that I just developed and want to explain here".
- agocorona 12y agoI added a bit more context. Thanks
- mijoharas 12y agoYou're right, he does link to the article (at least I think it's the one that is being referred to), but not until "Enter the monad" which seems later than it shoud be. Here is the link: https://www.fpcomplete.com/user/agocorona/monad-reactive-programming-2 https://www.fpcomplete.com/user/agocorona/monad-reactive-pro...
- tome 12y agoThis seems to be a valid link: https://www.fpcomplete.com/user/agocorona/EDSL-for-hard-working-IT-programmers https://www.fpcomplete.com/user/agocorona/EDSL-for-hard-work...
- unfamiliar 12y ago"Object-oriented programming is an exceptionally bad idea which could only have originated in California." - Dijkstra I don't think this is a real quotation.
- pestaa 12y agoYou are right. http://programmers.stackexchange.com/questions/99166/dijkstra-quote-on-object-orientation http://programmers.stackexchange.com/questions/99166/dijkstr... Although, OOP is still a mess.
- jimmaswell 12y agoIt's hardly any kind of "mess". It's the most practical and intuitive to reason about choice for a significant amount of work that needs to be done. FP excels at some cases but not all of them. Contorting all of my OOP code into a functional structure would be a nightmare.
- dons 12y ago> the most practical and intuitive What is intuitive to one is not necessarily intuitive to all.
- __Joker 12y agoTrue. Does this have anything to do with the way programming is taught, most of the times starting with imperative then with OOP ?
- agocorona 12y agoI think that there are objective measures of complexity. So there are objective measures of simplicity. ideographic writing is more complex and less composable than phonetic writing and yet can express the same ideas. Subjectively, a chinese can understand Chinese ideograms while maybe he find written English difficult to understand. But a Chinese would learn phonetic writing in less time than ideographic writing and would be capable to express complex ideas using the most composable writing system in less time, no doubt.
- michaelochurch 12y agoUpvoted, though I disagree, because I hate when people use downvotes for quality content they disagree with, and you don't deserve to be grayed out. "Object" often means "thing of which I have incomplete knowledge". When you have an Object, you've given up on reasoning about it from axiomatic principles or deep knowledge, and you're looking at it holistically alone. Sometimes, that's just fine. The Unix File concept is a well-designed object, because you can use the read and write system calls without having to know whether it's a regular file, a socket, a tape drive, a memfile, or something else. While working under incomplete knowledge is sometimes necessary, it's never the ideal. You can use Alan Kay's original OOP principles when software reaches a certain level of complexity, but shouldn't orient your programming around incomplete knowledge or unmanageable complexity. The problem with corporate OOP is that it enables the imprecision-of-thought of technically incompetent software managers and "enterprise architects" who are better at managing up than at solving technical problems. In fact, Dijkstra spells out the problem with corporate OOP in two words, as quoted in the OP: complexity sells. Complexity + imprecision-of-thought = disaster. And a major reason why top-5% programmers love Haskell is because it simply blocks the imprecision of thought that characterizes typical, business-as-usual, mediocre corporate software development.
- agocorona 12y agoVery sorry: https://www.fpcomplete.com/user/agocorona/EDSL-for-hard-working-IT-programmers https://www.fpcomplete.com/user/agocorona/EDSL-for-hard-work...
- mijoharas 12y agoDoes anyone else get "Base.hs@493:1-493:2 parse error on input `" on trying to run the code snippet in https://www.fpcomplete.com/user/agocorona/EDSL-for-hard-working-IT-programmers#composition-of-programs--runnable-example- https://www.fpcomplete.com/user/agocorona/EDSL-for-hard-work... Am I misusing fpcomplete, or does the code snippet not work?
- tome 12y agoLooks like a bug in FPComplete. There's only one use of backticks there and changing it to another form doesn't fix the error.
- mijoharas 12y agoI realised that it was the main module that needed to be run, after switching to this module (I also deleted some things causing syntax errors in base.hs) and selecting it as the build target the example worked as expected. I think it's because I'm not so familiar with fpcomplete.
- deleted 12y ago[deleted]
- agocorona 12y agoToo bad. I fixed it
- michaelochurch 12y agoOP: a question about some of your earlier work. In particular, I'm reading through your "A Monad For Reactive Programming, Part 1". https://www.fpcomplete.com/user/agocorona/a-monad-for-reactive-programming-part-1 https://www.fpcomplete.com/user/agocorona/a-monad-for-reacti... I see a lot of higher-rank types, like this: data Event = forall a. Event EvType a as opposed to: data Event a = Event EvType a These mean different things. In the former, an Event has to be able to hold any a, and that doesn't really make sense (unless I'm misinterpreting something) because the only value that inhabits all types a is undefined/bottom. Or is that what you want? Is there a reason why you use higher-rank types (which make my brain hurt, require a lot of language extensions, etc.) rather than parameterized types? If so, could you spell that out? Another example is this: data EventF = forall m b c. EventF (b → Transient m c) Again, I'm not really familiar with what you're doing so it's quite possible that using higher-rank types is exactly what you want (see: ST Monad and Lenses, where rank-2 types are crucial). I'm just having a hard time seeing it. Thanks!
- agocorona 12y agoHi In the case of events, it is because I later have to store different event types in a List so I define the list as [Event] . That is the container that feed the monad with events. If I define Event as you suggest, I would need a existential type anyway. data Event a = Event EvType a data ListEvents= forall a.[Event a] In the case of the continuations, I need to use a state monad that store this EventF data And I need to "erase" in some way the types to allow it to store them all for all events, no matter wich a and b they produce. I know that if in x :: IO a f :: a -> m b If within the monad definition I store f (the rest of the computation) in the state monad, the type of this continuation when executed will be (m b) and it accept values of type `a` so I can coerce the continuation to this type even if I "erased" it when i put it in the state monad. Anyway this approach has some problems that I solved in the second part