User loginNavigation |
LtU ForumFunctional Design Patterns - Relating Haskell Typeclasses to Software Design PatternsRecently, while re-reading through the Haskell Typeclassopedia I thought it would be a good exercise to map the structure of software design-patterns to the concepts found in the Haskell type class library and in functional programming in general. By searching the web I found some blog entries studying specific patterns, but I did not come across any comprehensive study. As it seemed that nobody did this kind of work yet I found it worthy to spend some time on it and write down all my findings on the subject. I think this kind of exposition could be helpful if you are either: - a programmer with an OO background who wants to get a better grip on how to implement complexer designs in functional programming I have set this up as a GitHub project with full sourcecode for all examples: By ThomasMahler at 2018-12-13 16:30 | LtU Forum | login or register to post comments | other blogs | 4226 reads
POLA Would Have Prevented the Event-Stream IncidentPOLA Would Have Prevented the Event-Stream Incident by Kate Sills
This npm / event-stream debacle is the perfect teaching moment for POLA (Principle of Least Authority), and for the need to support least authority for JavaScript libraries. My talk Securing EcmaScript, presentation to Node Security explained many of these issues prior to this particular incident. For LtU, my best explanation of POLA is Verify What? Navigating the Attack Surface given to the "Formal Methods Meets JavaScript" workshop at Imperial College. By MarkM at 2018-12-06 03:55 | LtU Forum | Site Discussion | login or register to post comments | other blogs | 3442 reads
Video on Unison/comparison to Haskell/Monads/distributed computinghttps://youtu.be/rp_Eild1aq8 Monads are passé, apparently. Previously mentioned on ltu rather a long time ago http://lambda-the-ultimate.org/node/5151 Lambdas and objects as an existential typeI’m looking at type theory from point of view of the general-purpose programming language evolution, and I’ve found something that does not look nice. There is stage when function pointers like ones in C were introduced to the languages. Differently from lambdas they are stateless and they could be only evaluated using their explicit arguments and using only constants (or global state) and by calling other stateless functions. Their type will be designated as: T ⇨ A Now let’s take usual lambdas, their type will be designated as: T → A The relationship between these two types is the following: A → B = ∃ T (T ⨉ (T ⨉ A ⇨ B)) apply: (A → B) ⨉ A ⇨ B = ? ((t, f), a), f(t, a) // unpacking existential type here curry: ((A ⨉ B) → C) ⇨ (A → B → C) = ?(t, f) ((t, f), (?((t1, f1), a1) ((t1, f1, a1), (?((t2, f2, a2), b2) f2(t2, (a2, b2)))))) Such definition is needed to support currying and to capture implicit environment, and it reflects what is actually happens in the code. Every function from T ⇨ A could be trivially converted to T → A, however stateless functions have different set operations supported. Particularly, currying is not supported. So, it is not subclass, but a separate entity type. This existential type captures difference between structured programming paradigm and object-oriented or functional programming paradigms. So, theoretically, when we would try to study paradigms, we would also need to make this distinction. I’m interested if there are some research papers that describe this distinction. The discussion in the TaPL book is somewhat unsatisfying because explicit existential types are defined using implicit existential types. Theoretically, the type theory should start from stateless functions to reflect evolution path rather than in reverse direction. Such point of view might be also useful for the compiler transformation reasoning, so there might be papers on such equivalence in that area too. Flix on the JVM for static analysisGolly, how did I never hear of this before?
By raould at 2018-10-11 22:52 | LtU Forum | login or register to post comments | other blogs | 3501 reads
Video on ContinuationsI thought I'd let you all know about a video lecture I gave on Scheme continuations, and how they can be used to generate all sorts of control structures. Enjoy! CPS for the win?My old half-baked idea/dream of a cranky day job programmer who doesn't really know what he's talking about:
This gives super powers like:
Code would still be interacted with by developers in original format. Since e.g. hypothetically anything can be converted from imperative to monadic pure fp style then e.g. Java could be set up this way. The UX for adding hooks would be nice and all at a high level, looking like source code, not some internal runtime CPS hell. Co-continuations: a dual to shift/reset?Shift/reset allow convenient expression of monadic computations, as a kind of generalized, functional version of do-notation. From the beginning of that link:
The obvious question is whether there is an analogous construct for comonads. Given that there is a codo-notation I believe there is. In a concatenative language, shift/reset can be written as:
The F block observes the future of the computation (delimited by the nearest reset) and may select a new one. I believe the comonadic dual is:
The F block observes the past of the computation (delimited by the nearest coreset) and may select a new one. This leads to a combined operator:
The F block observes the future and past of the computation (delimited by the nearest braces) and may select new ones. This is first class (co)control flow. I want to say something like "the dual of continuations is environments", as "environment" is an existing concept that seems conceptually close to "store". Note that on this page, someone posts functions analogous to shift/reset for "codensity" or "store". I believe this notation allows the convenient expression of arrows (and monads and comonads) in the same way shift/reset allows expression of monads. Arrows allow decoration of both inputs and outputs, as opposed to only inputs for comonads and only outputs for monads. This makes sense to me but I'm not totally sure since there's not much information on comonads/codo notation and such. I'd appreciate any comments. EDIT: I think the correct format is actually A pointer is an integer with a shivBy Charles Stewart at 2018-09-26 09:02 | LtU Forum | login or register to post comments | other blogs | 3376 reads
AsyncFlows: Structured Asynchronous ProgrammingI've just made a public release of AsyncFlows framework 0.1.0 that offers DSL for structured and object-oriented asynchronous programming. Some differences from competing solutions:
I would like feedback on DSL struture and on the thesis that explicit event sending to queues or channels is "go to" of asynchronous programming and that it should be avoided if we try to get understandable code. By const at 2018-09-14 18:41 | LtU Forum | login or register to post comments | other blogs | 3183 reads
|
Browse archives
Active forum topics |
Recent comments
3 weeks 3 days ago
3 weeks 3 days ago
3 weeks 4 days ago
3 weeks 4 days ago
4 weeks 22 hours ago
4 weeks 23 hours ago
4 weeks 2 days ago
4 weeks 2 days ago
4 weeks 2 days ago
4 weeks 2 days ago