Workshop slides from the Alt.Net Seattle 2011 workshop. Presented by Wes Dyer and Ryan Riley. Get the slides and the workshop code at http://rxworkshop.codeplex.com/
Slides from a brief presentation about the 'docase' notation that I did at Haskell Hackathon in Cambridge. The notation makes it easier to work with monads that have some additional operations (such as Par monad or Parsers).
Workshop slides from the Alt.Net Seattle 2011 workshop. Presented by Wes Dyer and Ryan Riley. Get the slides and the workshop code at http://rxworkshop.codeplex.com/
Slides from a brief presentation about the 'docase' notation that I did at Haskell Hackathon in Cambridge. The notation makes it easier to work with monads that have some additional operations (such as Par monad or Parsers).
One of the key concepts of functional programming is compositionality – the fact that we can build complex software using several basic “building blocks” and just a few ways of combining them. In this talk, I’ll demonstrate how we can teach this concept using F#. We’ll start with a basic example of this approach that even high-school students can easily understand – numerical expressions. Then we’ll move to more exciting examples of using library for composing 3D graphics. We’ll see that creating a fractal tree is not much more complicated than calculating the area of a triangle.
The recording is available online at: http://www.communityforfsharp.net/
(Video and code at https://fsharpforfunandprofit.com/pipeline/)
Passing data through a pipeline of transformations is an alternative approach to classic OOP. The LINQ methods in .NET are designed around this, but the pipeline approach can be used for so much more than manipulating collections.
In this talk, I'll look at pipeline-oriented programming and how it relates to functional programming, the open-closed principle, unit testing, the onion architecture, and more. I'll finish up by showing how you can build a complete web app using only this approach.
Python Programming Course Lecture by IoT Code Lab Training.
Discussed Topic:
Chapter 1: Basic Programming
* Operator
* Arithmetic Operation Example
* Assignment Operation Example
* Built in Function Example
* Math Module Example
* Other Operators
* Practice Problem 1.1
* Practice Problem 1.2
* Practice Problem 1.3
following is work on Advance Python part 1 Functional Programming in Python
for code and more details plz do visit
https://lnkd.in/dnQF95z
for more free study material and Projects follow on
Github
https://lnkd.in/gYKtuB3
LinkedIn
https://lnkd.in/daSvf_P
#python #datascience #programming #machinelearning #github #deeplearning #coding #developer #projects #work #developers #linkedin #google #amazonindia#IBM
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3Philip Schwarz
(download for picture-perfect quality) Follow along as Trampolining is used to overcome Stack Overflow issues with the simple IO monad, deepening you understanding of the IO monad in the process. See Game of Life IO actions migrated to the Cats Effect IO monad, which is trampolined in its flatMap evaluation.
Errata:
slide 33: "impure factorial function" should be "initial factorial function"
slide 34: there is a pointless short vertical bar inside a speech bubble
slide 39: "it is till annoying" should be "it is still annoying"
slide 44: "values that we are interested" should be "values that we are interested in"
(video of these slides available here http://fsharpforfunandprofit.com/fppatterns/)
In object-oriented development, we are all familiar with design patterns such as the Strategy pattern and Decorator pattern, and design principles such as SOLID.
The functional programming community has design patterns and principles as well.
This talk will provide an overview of some of these, and present some demonstrations of FP design in practice.
Chapter 2 Decision Making (Python Programming Lecture)IoT Code Lab
Python Programming Course Lecture by IoT Code Lab Training.
Discussed Topic:
Chapter 2: Decision Making
* Decision Making (Conditional Statement)
* Comparisons Operator Example
* Logical Operator Example
* Bitwise Operator Example
* Practice Problem 2.1
* Practice Problem 2.2
* Practice Problem 2.3
One of the key concepts of functional programming is compositionality – the fact that we can build complex software using several basic “building blocks” and just a few ways of combining them. In this talk, I’ll demonstrate how we can teach this concept using F#. We’ll start with a basic example of this approach that even high-school students can easily understand – numerical expressions. Then we’ll move to more exciting examples of using library for composing 3D graphics. We’ll see that creating a fractal tree is not much more complicated than calculating the area of a triangle.
The recording is available online at: http://www.communityforfsharp.net/
(Video and code at https://fsharpforfunandprofit.com/pipeline/)
Passing data through a pipeline of transformations is an alternative approach to classic OOP. The LINQ methods in .NET are designed around this, but the pipeline approach can be used for so much more than manipulating collections.
In this talk, I'll look at pipeline-oriented programming and how it relates to functional programming, the open-closed principle, unit testing, the onion architecture, and more. I'll finish up by showing how you can build a complete web app using only this approach.
Python Programming Course Lecture by IoT Code Lab Training.
Discussed Topic:
Chapter 1: Basic Programming
* Operator
* Arithmetic Operation Example
* Assignment Operation Example
* Built in Function Example
* Math Module Example
* Other Operators
* Practice Problem 1.1
* Practice Problem 1.2
* Practice Problem 1.3
following is work on Advance Python part 1 Functional Programming in Python
for code and more details plz do visit
https://lnkd.in/dnQF95z
for more free study material and Projects follow on
Github
https://lnkd.in/gYKtuB3
LinkedIn
https://lnkd.in/daSvf_P
#python #datascience #programming #machinelearning #github #deeplearning #coding #developer #projects #work #developers #linkedin #google #amazonindia#IBM
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3Philip Schwarz
(download for picture-perfect quality) Follow along as Trampolining is used to overcome Stack Overflow issues with the simple IO monad, deepening you understanding of the IO monad in the process. See Game of Life IO actions migrated to the Cats Effect IO monad, which is trampolined in its flatMap evaluation.
Errata:
slide 33: "impure factorial function" should be "initial factorial function"
slide 34: there is a pointless short vertical bar inside a speech bubble
slide 39: "it is till annoying" should be "it is still annoying"
slide 44: "values that we are interested" should be "values that we are interested in"
(video of these slides available here http://fsharpforfunandprofit.com/fppatterns/)
In object-oriented development, we are all familiar with design patterns such as the Strategy pattern and Decorator pattern, and design principles such as SOLID.
The functional programming community has design patterns and principles as well.
This talk will provide an overview of some of these, and present some demonstrations of FP design in practice.
Chapter 2 Decision Making (Python Programming Lecture)IoT Code Lab
Python Programming Course Lecture by IoT Code Lab Training.
Discussed Topic:
Chapter 2: Decision Making
* Decision Making (Conditional Statement)
* Comparisons Operator Example
* Logical Operator Example
* Bitwise Operator Example
* Practice Problem 2.1
* Practice Problem 2.2
* Practice Problem 2.3
The Sad Story of the Server that Tries to Please EveryoneIulian Dogariu
Presentation for http://iasi.codecamp.ro
You're a VIP. Everyone wants a bit of your time, to help with this and that. Let's say you try to promptly serve everyone that asks for your help. What would happen to your life? We will see how to apply these learnings to build services that behave gracefully under heavy load.
Different application domains including sensor networks, social networks, science, financial services, condition monitoring systems demand the storage of a vast amount of data in the petabytes area. Prominent candidates are Google, Facebook, Yahoo!, Amazon just to name a few.
This data volume can't be tackled with convential relational database technologies anymore, either from a technical or licensing point of view or both. It demands a scale-out environment, which allows reliable, scalable and distributed processing. This trend in Big Data management is more and more approached with NoSQL solutions like Apache HBase on top of Apache Hadoop.
This session discusses big data management and their scalability challenges in general with a short introduction into Apache Hadoop/HBase and a case study on the co-existence of Apache Hadoop/HBase with Firebird in a sensor data aquisition system.
Scott Theleman - Understanding F# Workflows
F# Workflows are a powerful and elegant tool for solving many real-world problems, though they can be rather daunting at first. We'll survey some ways in which Workflows in the standard F# libraries are used for common development tasks, then dig into detail on how they work. We'll then build a workflow that provides a validation framework that can be used for parsing or other tasks.
Scott Theleman is a Software Developer with over 10 years professional design and development experience in both small startup and mid-sized corporate/Enterprise environments on applications ranging from desktop GUIs to website/web applications to server side and middleware work. He has also been Technical Lead on several government contracts.
He has worked on a diverse range of projects including a network discovery and topology product, a Learning Management System, Enterprise Service Oriented Architecture components for a large and complex search service, and atmospheric and weather sciences applications.
Language experience includes C++, Perl, Java and C#. He is currently working as a consultant on various projects including an atmospheric sciences product which will make extensive use of the latest Microsoft technologies including F# and WPF.
React is a JavaScript library for creating user interfaces by Facebook and Instagram. Many people choose to think of React as the V in MVC.
We built React to solve one problem: building large applications with data that changes over time. To do this, React uses two main ideas.
Simple
Simply express how your app should look at any given point in time, and React will automatically manage all UI updates when your underlying data changes.
Declarative
When the data changes, React conceptually hits the "refresh" button, and knows to only update the changed parts.
In this talk, I'm presenting an alternative approach to thinking about UI and navigation on iOS - one that is declarative and that I find easy to reason about in a big application. I did live coding and the link is on the last slide. Enjoy!
Building real-time collaborative apps with Ajax.org PlatformJaveline B.V.
Web trends and technologies today are converging to do one thing particularly well: collaborate. All of us dream about the possibility to weave collaborative features from products like Google Wave, EtherPad, SubEthaEdit, Mozilla Bespin, Google Docs into our own applications. Ajax.org Platform combines technology and open standards into a solution to build web applications with rich collaborative features at minimum expense. The simple-yet-elegant, declarative API makes it easier to learn, while its openness in design allows it to be extended to the level you and your team are comfortable with. Forget lock-in of vendors and other libraries or frameworks, forget waiting for the Big Boys to open source their latest inventions. In this interactive session Ruben and Mike from the Ajax.org team will be presenting a series of demos and what is needed to make them tick.
5 things cucumber is bad at by Richard LawrenceSkills Matter
This talk will look at 5 things Cucumber’s bad at, why that’s a good thing, and what it tells us about Cucumber’s sweet spot in a team’s toolkit.
Many times, when people complain about something Cucumber’s not good at, they’re unwittingly describing something Cucumber shouldn't be good at. They’re revealing that they don’t quite understand BDD and Cucumber’s role in it.
Cucumber is the world's most misunderstood collaboration tool and people need to hear this over and over again.
Patterns for slick database applicationsSkills Matter
Slick is Typesafe's open source database access library for Scala. It features a collection-style API, compact syntax, type-safe, compositional queries and explicit execution control. Community feedback helped us to identify common problems developers are facing when writing Slick applications. This talk suggests particular solutions to these problems. We will be looking at reducing boiler-plate, re-using code between queries, efficiently modeling object references and more.
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmSkills Matter
Metascala is a tiny metacircular Java Virtual Machine (JVM) written in the Scala programming language. Metascala is barely 3000 lines of Scala, and is complete enough that it is able to interpret itself metacircularly. Being written in Scala and compiled to Java bytecode, the Metascala JVM requires a host JVM in order to run.
The goal of Metascala is to create a platform to experiment with the JVM: a 3000 line JVM written in Scala is probably much more approachable than the 1,000,000 lines of C/C++ which make up HotSpot, the standard implementation, and more amenable to implementing fun features like continuations, isolates or value classes. The 3000 lines of code gives you:
The bytecode interpreter, together with all the run-time data structures
A stack-machine to SSA register-machine bytecode translator
A custom heap, complete with a stop-the-world, copying garbage collector
Implementations of parts of the JVM's native interface
Although it is far from a complete implementation, Metascala already provides the ability to run untrusted bytecode securely (albeit slowly), since every operation which could potentially cause harm (including memory allocations and CPU usage) is virtualized and can be controlled. Ongoing work includes tightening of the security guarantees, improving compatibility and increasing performance.
ENJOYIN
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Skills Matter
Code Quotations: Code-as-Data for F#
This tutorial will cover F# Code Quotations in-depth. You'll learn what Code Quotations are, how to use them, and where to apply them in your applications. We'll work through several real-world examples to highlight the important features -- and potential pitfalls -- of Code Quotations.
Cukeup nyc ian dees on elixir, erlang, and cucumberlSkills Matter
Elixir, Erlang, and Cucumberl
Elixir is a new Ruby-inspired programming language that uses the powerful concurrent machinery of Erlang behind the scenes. Cucumberl is a port of Cucumber to Erlang. Let's see what happens when we put them together.
In this talk, we'll discuss:
How Erlang's concurrency makes it easier to write robust programs
Elixir's approachable syntax
How to test Erlang and Elixir programs using Cucumberl
Attendees will walk away with a solid introduction to the principles of Erlang, and an appreciation of the way Elixir brings the joy of Ruby to the solidity of the Erlang runtime.
Cukeup nyc peter bell on getting started with cucumber.jsSkills Matter
Cukeup NYC. Peter Bell on Getting started with cucumber.js
Ever wished you could use cucumber in your javascript apps? In this talk we'll look at the current state of play of cucumber js, when you should and shouldn't use it, and how to get started writing your step definitions in javascript.
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Skills Matter
In this engaging experience report, we will present 3 different views – Developer, Tester, Business Analyst – of implementing Acceptance Test Driven Development in a complex, data-driven domain. Hear how we used ATDD for building a ubiquitous language across the entire team, promoting faster feedback, and cultivating a culture where product owners were deeply invested in the quality of both every deliverable and the system as a whole.
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Skills Matter
In this tutorial, Phil and Rachel will introduce you to the Try F# samples giving you exposure to, and an understanding of, how F# tackles some real-world scenarios. We'll help you explore, generate, and just play around with code samples, as well as talk you through some of the key principles of F#. By the end of this session, you'll have gone from zero to data science in only a few hours!
Progressive f# tutorials nyc don syme on keynote f# in the open source worldSkills Matter
F# is a powerful open-source language which Microsoft, other companies and the F# community all contribute to. In this talk, Don will discuss how the “F# space” has recently opened up significantly in interesting ways. F# now includes contributions that range from Cloud IDE platforms, Cloud Compute frameworks, Data interoperability components, Cross-platform execution, Try F#, MonoDevelop, and even Emacs editor integration with surprising tooling support, as well as the Visual F# tools from Microsoft and the broader NuGet package ecosystem. Don will also talk about some of the latest contributions from Microsoft Research, including new type provider components for F#, and describe how his team work with the Visual F# team and other teams around Microsoft. There will also be demos of some fun new stuff that’s been going on with F# at MSR and the community.
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Skills Matter
Would you like to learn how to make your software testing practices more effective? And how to use your testing strategy to better capture and reflect customer requirements? Gojko Adzic takes a critical look at the effectiveness of current software testing practices and proposes strategies to make it much more effective.
Dmitry mozorov on code quotations code as-data for f#Skills Matter
Code Quotations: Code-as-Data for F#
This tutorial will cover F# Code Quotations in-depth. You'll learn what Code Quotations are, how to use them, and where to apply them in your applications. We'll work through several real-world examples to highlight the important features -- and potential pitfalls -- of Code Quotations.
Simon Peyton Jones: Managing parallelismSkills Matter
If you want to program a parallel computer, it obviously makes sense to start with a computational paradigm in which parallelism is the default (ie functional programming), rather than one in which computation is based on sequential flow of control (the imperative paradigm). And yet, and yet ... functional programmers have been singing this tune since the 1980s, but do not yet rule the world. In this talk I’ll say why I think parallelism is too complex a beast to be slain at one blow, and how we are going to be driven, willy-nilly, towards a world in which side effects are much more tightly controlled than now. I’ll sketch a whole range of ways of writing parallel program in a functional paradigm (implicit parallelism, transactional memory, data parallelism, DSLs for GPUs, distributed processes, etc, etc), illustrating with examples from the rapidly moving Haskell community, and identifying some of the challenges we need to tackle.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
GridMate - End to end testing is a critical piece to ensure quality and avoid...ThomasParaiso2
End to end testing is a critical piece to ensure quality and avoid regressions. In this session, we share our journey building an E2E testing pipeline for GridMate components (LWC and Aura) using Cypress, JSForce, FakerJS…
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
2. A little bit about me… Real-World Functional Programming with Jon Skeet Today’s talk based on some ideas from Chapter 16 Worked on F# at MSR Internships with Don Syme Web programming and reactive programming in F# Some Visual Studio 2010 IntelliSense
3. What is this talk about? It is not about concurrent programming Multiple threads, various programming models Immutable data using Tasks or Parallel LINQ We have full control over the control flow Message passing using F# MailboxProcessor Processors react to received messages It is about reactive programming Components that react to events in general MailboxProcessoris one possible implementation Can be single-threaded – running on GUI thread
4. Single-threaded reactive programming Single-threading makes GUI simple (possible!) Reactive part of the application reacts quickly Expensive work should be done in background Declarative – what to do with received data Define data-flow using event combinators ⊕Simple & elegant ⊝Limited expressivity Imperative – how to react to received data Define control-flow using asynchronous workflows ⊝Write more code ⊕Easy for difficult tasks
5. Talk outline Writing reactive GUIs declaratively Declarative GUI programming in WPF Using F# event combinators Writing reactive GUIs imperatively Using the AwaitObservableprimitive Understanding threading Asynchronous programming with events Asynchronous HTTP web requests
6. Everybody loves declarative style! Used by numerous .NET libraries LINQ for specifying queries in C# Specifying layout of user interface in WPF/Silverlight Can be used for specifying reactive aspects too! Declarative <Button Content="Click me!"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <ei:CallMethodAction MethodName="Process"(...)/> </i:EventTrigger> </i:Interaction.Triggers> </Button> Triggered when this event occurs This action calls specified method
7. Everybody loves declarative style! (2.) Specifying more complex behaviors We can write new Triggers and Actions… For example Silverlight Experimental Hacks Library We can specify conditions for triggers Triggered only when chkAllow.Enabled == true <Button Content="Click me!"><i:Interaction.Triggers> <ex:EventTriggerEventName="Click"> <ex:EventTrigger.Conditions><ex:InvokingConditions> <ex:InvokingConditionElementName="chkAllow" Property="Enabled" Value="True" /> </ex:InvokingConditions></ex:EventTrigger.Conditions> <ex:PropertyActionPropertyName="Visible"Value="True"/> </ex:EventTrigger> </i:Interaction.Triggers></Button> Displays some control
8. Digression: Declarative list processing Essentially the same thing as LINQ queries Declarative – specify what results we want Create list of points >letpoints= [ (0.0, 50.0); (100.0, 0.0); (300.0, 100.0) ] ;; >List.map(fun (x, y) ->x+25.0, y+25.0) points ;; val it : (float * float) list = [(25.0, 75.0); (125.0, 25.0); (325.0, 125.0)] >points |>List.map (fun (x, y) ->x+25.0, y+25.0) |>List.filter (fun (x, y) ->x<200.0&&y<100.0) |>List.iter (fun (x, y) ->printf"[%f, %f] "xy) ;; [25.000000, 75.000000] [125.000000, 25.000000] Add 25 to X and Y coordinates * First add 25 * Limit range * Print points
10. Digression: Dynamic invoke in F# Access members not known at compile-time Simple version of dynamic keyword in C# We can easily define behavior of the operator How does it work? When we write… …the compiler treats it as: let (?) (this:Control) (prop:string) :'T= this.FindName(prop) :?>'T letball :Ellipse = this?Ball let ball :Ellipse = (?) this "Ball"
11. More about F# events Events in F# are first-class values Implement interface type IEvent<'T> Events carry values 'Tsuch as MouseEventArgs Can be passed as arguments, returned as results We use functions for working with event values Create new event that carries different type of value and is triggered only in some cases Event.add registers handler to the final event Event.map : ('T -> 'R) -> IEvent<'T> -> IEvent<'R> Event.filter : ('T -> bool) -> IEvent<'T> -> IEvent<'T>
12. Two interesting event combinators Merging events with Event.merge Triggered whenever first or second event occurs Note that the carried values must have same type Creating stateful events with Event.scan State is recalculated each time event occurs Triggered with new state after recalculation IEvent<'T> -> IEvent<'T> -> IEvent<'T> ('St -> 'T -> 'St) -> 'St -> IEvent<'T> -> IEvent<'St>
13. Creating ColorSelector control Three sliders for changing color components Box shows current color Data-flow diagram describes the activity Diagrams
15. Accessing F# events from C# Events in F# are values of type IEvent<'T> Enables F# way of working with events Attribute instructs F# to generate .NET event IEvent<'T> vs. IObservable<'T> in .NET 4.0 You can work with both of them from F# Using combinators such as Observable.mapetc. Observable keeps separate state for each handler Can be confusing if you add/remove handlers [<CLIEvent>] memberx.ColorChanged=colorChanged
16. Talk outline Writing reactive GUIs declaratively Declarative GUI programming in WPF Using F# event combinators Writing reactive GUIs imperatively Using the AwaitObservableprimitive Understanding threading Asynchronous programming with events Asynchronous HTTP web requests
17. Creating SemaphoreLight control Typical approach – store state as int or enum Imperative code uses mutable fields With event combinators, we use Event.scan Difficult to read – what does state represent? It is hard to see what the transitions are! Better approach – write workflow that loops between states (points in code) Asynchronous waiting on events causes transitions Diagrams
19. Workflows for GUI programming Async.AwaitObservableoperation Creates workflow that waits for the first occurrence Currently not part of F# libraries / PowerPack Sometimes, using IObservable<'T> is better Works because IEvent<'T> : IObservable<'T> Async.StartImmediateoperation Starts the workflow on the current (e.g. GUI) thread Callbacks always return to original kind of thread All code in the demo runs on GUI thread as required! AwaitObservable : IObservable<'T> -> Async<'T>
20. Writing loops using workflows Using looping constructs like whileand for Functional style – using recursion letsemaphoreStates2() =async { whiletruedo forcurrentin [ green; orange; red ] do let!md=Async.AwaitObservable(this.MouseLeftButtonDown) display(current) } “Infinite” loop letrecsemaphoreStates() =async { forcurrentin [ green; orange; red ] do let!md=Async.AwaitObservable(this.MouseLeftButtonDown) display(current) do!semaphoreStates() } Recursive call written using “do!”
22. Application for drawing rectangles Choosing between multiple transitions? AwaitObservable taking two events Resume when the first event fires complexdiagrams
24. Waiting for multiple events Choosing between two (or more) events Specify two different transitions from single state Overloads for more events available too AwaitObservable: IObservable<'T> * IObservable<'U> -> Async<Choice<'T, 'U>> Overload taking two events as parameters let!evt=Async.AwaitObservable (main.MouseLeftButtonDown, main.MouseMove) matchevtwith | Choice1Of2(up) -> // Left button was clicked | Choice2Of2(move) -> // Mouse cursor moved } Returns Choice<'T1,'T2>
25. Talk outline Writing reactive GUIs declaratively Declarative GUI programming in WPF Using F# event combinators Writing reactive GUIs imperatively Using the AwaitObservableprimitive Understanding threading Asynchronous programming with events Asynchronous HTTP web requests
26. Patterns for asynchronous programming Begin/End pattern used by standard libraries Event-based pattern used more recently Can we write this using AwaitObservable? Little tricky – need to attach handler first! lethr=HttpWebRequest.Create("http://...") let!resp=hr.AsyncGetResponse() letsr=resp.GetResponseStream() Created from Begin/EndGetResponse letwc=newWebClient() wc.DownloadStringCompleted.Add(funres-> letstring=res.Result ) wc.DownloadStringAsync("http://...") Register handler and then start
27. Performing asynchronous calls correctly Introducing GuardedAwaitObservableprimitive Calls a function after attaching event handler We cannot accidentally lose event occurrence Mixing asynchronous I/O and GUI code If started from GUI thread, will return to GUI thread We can safely access controls after HTTP request async { letwc=newWebClient() let!res= Async.GuardedAwaitObservablewc.DownloadStringCompleted (fun () ->wc.DownloadStringAsync(newUri(uri))) // (...) }
29. Brief summary of the talk Reactive code can run on the GUI thread! Two programming styles in F# Declarative or data-flow style Using Event.scan combinators Imperative or control-flow style Using AwaitEvent primitive In both cases, we can use diagrams Web requests from workflows Both common patterns work
31. References & Links What do you need to run samples? Samples will be on my blog (below) Get F# and F# PowerPack (http://www.fsharp.net) Get Silverlight Developer tools (F# included!) http://www.silverlight.net/getstarted Blog & contacts “Real-World Functional Programming” http://functional-programming.net My blog: http://tomasp.net/blog Contact: tomas@tomasp.net