What is the difference between Final Tagless and Free Monads from the Software Design point of view? What is Hierarchical Free Monads approach? How to build real applications in Haskell?
This talk was given on FPure 2019, Kazan.
We describe work in progress on the design and implementation of an SQL-like language for performing complex queries on event streams. This language aims at providing a simple, intuitive and fully non-procedural syntax, while still preserving backwards compatibility with traditional SQL. The syntax and informal semantics of the language are introduced; multiple examples of scenarios taken from past literature are then presented, and used to compare the expressiveness and intuitiveness of the proposed language with respect to existing Complex Event Processing engines.
This presentation is an introduction to Complex Event Processing (CEP) intended for an practicioners of Runtime Verification. It first describes typical CEP problems, popular tools and their query languages. It then presents BeepBeep 3, an event stream processor that attempts to bridge the gap between RV and CEP. Thanks to BeepBeep’s generic architecture and flexible input language, queries and properties from both fields can be efficiently processed.
Activity Recognition Through Complex Event Processing: First Findings Sylvain Hallé
The activities of daily living of a patient in a smart home environment can be detected to a large extent by the real-time analysis of characteristics of the habitat's electrical consumption. However, reasoning over the conduct of these activities occurs at a much higher level of abstraction than what the sensors generally produce. In this paper, we leverage the concept of Complex Event Processing (CEP), in which low-level data streams are progressively transformed into higher-level ones, to the task of activity recognition. We show how the use of an appropriate representation for each level of abstraction can greatly simplify the process. We also report on the use of an existing event stream processor to successfully implement the complete chain, from low-level sensor data up to a sequence of discrete and high-level actions.
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)Sylvain Hallé
This talk reviews the basic principles behind the BeepBeep 3 event stream processing engine, and the facilities it provides to help you design you own, domain-specific query language.
We describe work in progress on the design and implementation of an SQL-like language for performing complex queries on event streams. This language aims at providing a simple, intuitive and fully non-procedural syntax, while still preserving backwards compatibility with traditional SQL. The syntax and informal semantics of the language are introduced; multiple examples of scenarios taken from past literature are then presented, and used to compare the expressiveness and intuitiveness of the proposed language with respect to existing Complex Event Processing engines.
This presentation is an introduction to Complex Event Processing (CEP) intended for an practicioners of Runtime Verification. It first describes typical CEP problems, popular tools and their query languages. It then presents BeepBeep 3, an event stream processor that attempts to bridge the gap between RV and CEP. Thanks to BeepBeep’s generic architecture and flexible input language, queries and properties from both fields can be efficiently processed.
Activity Recognition Through Complex Event Processing: First Findings Sylvain Hallé
The activities of daily living of a patient in a smart home environment can be detected to a large extent by the real-time analysis of characteristics of the habitat's electrical consumption. However, reasoning over the conduct of these activities occurs at a much higher level of abstraction than what the sensors generally produce. In this paper, we leverage the concept of Complex Event Processing (CEP), in which low-level data streams are progressively transformed into higher-level ones, to the task of activity recognition. We show how the use of an appropriate representation for each level of abstraction can greatly simplify the process. We also report on the use of an existing event stream processor to successfully implement the complete chain, from low-level sensor data up to a sequence of discrete and high-level actions.
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)Sylvain Hallé
This talk reviews the basic principles behind the BeepBeep 3 event stream processing engine, and the facilities it provides to help you design you own, domain-specific query language.
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwiftAaron Douglas
This is an introduction to reactive concepts using Swift specifically with ReactiveX’s implementation, RxSwift. ReactiveX is an API for asynchronous programming with observable streams originally implemented with .NET and LINQ. ReactiveX is a combination of the best ideas from the Observer pattern, the Iterator pattern, and functional programming.
You’ll learn about all the basic moving parts of RxSwift and why you want to use it in your application.
Original presented 23-Aug-2016 at 360iDev 2016 - Denver, CO.
Talk at the Sydney Clojure User Group, October 2014 exploring the principles behind the deign of imminent - https://github.com/leonardoborges/imminent - a Clojure library for composable futures
An AVL tree, ordered by key insert: a standard insert; (log n) find: a standard find (without removing, of course); (log n) remove: a standard remove; (log n)
You may have heard about reactive programming. Maybe even checked out RxSwift. But if you're not using it in your daily development, you're really missing out! Rx decimates the boilerplate code you'd have to write to do the same things in the traditional, imperative manner. And, in this day and age where the answer to supporting multiple platforms has given rise to using "lowest common denominator" cross-platform development technologies, Rx shifts the focus back to developers who want to stay true to their platform of choice, by unifying the patterns and operators used to write app code on any platform. Come see how reactive programming with RxSwift will change your life and make you richer than your wildest dreams.
Reactive Programming Patterns with RxSwiftFlorent Pillet
In this introduction to reactive programming and RxSwift you'll learn how common problems are solved in a reactive way to improve your architecture and write more reliable code.
An approach for load-time hacking using LD_PRELOAD is presented.
We discuss a simple, yet intriguing, strategy for overcoming the limitations discussed in Part 1 (i.e., the first publication given in the reference) of reverse engineering and exploitation using LD_PRELOAD, a dynamic linking technique. In particular, we relax the need for exit(1) in the main function. The essence of the technique is that both the stack pointer (esp) and the base frame pointer (ebp) are carefully adjusted when the wrapper to the library function is called. The proposed solution allows us to safely return to libc after dynamically modifying the control flow in the wrapper to (library) functions.
Hierarchical free monads and software design in fpAlexander Granin
I invented the approach I call "Hierarchical Free Monads". It helps to build applications in Haskell with achieving all the needed code quality requirements. I tested this approach in several real world projects and companies, and it works very well.
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwiftAaron Douglas
This is an introduction to reactive concepts using Swift specifically with ReactiveX’s implementation, RxSwift. ReactiveX is an API for asynchronous programming with observable streams originally implemented with .NET and LINQ. ReactiveX is a combination of the best ideas from the Observer pattern, the Iterator pattern, and functional programming.
You’ll learn about all the basic moving parts of RxSwift and why you want to use it in your application.
Original presented 23-Aug-2016 at 360iDev 2016 - Denver, CO.
Talk at the Sydney Clojure User Group, October 2014 exploring the principles behind the deign of imminent - https://github.com/leonardoborges/imminent - a Clojure library for composable futures
An AVL tree, ordered by key insert: a standard insert; (log n) find: a standard find (without removing, of course); (log n) remove: a standard remove; (log n)
You may have heard about reactive programming. Maybe even checked out RxSwift. But if you're not using it in your daily development, you're really missing out! Rx decimates the boilerplate code you'd have to write to do the same things in the traditional, imperative manner. And, in this day and age where the answer to supporting multiple platforms has given rise to using "lowest common denominator" cross-platform development technologies, Rx shifts the focus back to developers who want to stay true to their platform of choice, by unifying the patterns and operators used to write app code on any platform. Come see how reactive programming with RxSwift will change your life and make you richer than your wildest dreams.
Reactive Programming Patterns with RxSwiftFlorent Pillet
In this introduction to reactive programming and RxSwift you'll learn how common problems are solved in a reactive way to improve your architecture and write more reliable code.
An approach for load-time hacking using LD_PRELOAD is presented.
We discuss a simple, yet intriguing, strategy for overcoming the limitations discussed in Part 1 (i.e., the first publication given in the reference) of reverse engineering and exploitation using LD_PRELOAD, a dynamic linking technique. In particular, we relax the need for exit(1) in the main function. The essence of the technique is that both the stack pointer (esp) and the base frame pointer (ebp) are carefully adjusted when the wrapper to the library function is called. The proposed solution allows us to safely return to libc after dynamically modifying the control flow in the wrapper to (library) functions.
Hierarchical free monads and software design in fpAlexander Granin
I invented the approach I call "Hierarchical Free Monads". It helps to build applications in Haskell with achieving all the needed code quality requirements. I tested this approach in several real world projects and companies, and it works very well.
What's the best way to model modular, composable effects in your purely functional program? In this presentation, I take a look at monad transformers and free monads, discuss their history, and compare how effectively they solve the problem.
(1) c sharp introduction_basics_dot_netNico Ludwig
This presentation comes with many additional notes (pdf): http://de.slideshare.net/nicolayludwig/1-c-sharp-introductionbasicsdotnet-38638887
- History
- Bird's Eye View of Features
On March 2014, Java 8 was released. These informal slides describe the new elements of the programming languages, focusing on those taken from the functional paradigm.
Harnessing the Power of Java 8 Streams IndicThreads
Presented at the IndicThreads.com Software Development Conference 2016 held in Pune, India. More at http://www.IndicThreads.com and http://Pune16.IndicThreads.com
--
Uma equipe de apenas 14 engenheiros (junho de 2017) cuida da Infraestrutura do principal banco de dados do Facebook. Toda ação no Instagram, Messenger, WhatsApp e claro, no FB, passa direta ou indiretamente pela infra de dezenas de milhares de servidores que rodam MySQL.
A linguagem usada pela equipe e por trás de toda a automação é Python. Nessa palestra, vamos mostrar como a linguagem possibilitou que chegássemos nessa escala, passando pela evolução, desafios e futuro:
Interfaces “tipadas” com Thrift;
Empacotamento através do Buck;
Type Checking com MyPy;
Asyncio para novos serviços;
Debugging com gdb 7 e pudb;
Além disso, durante a palestra, serão discutidas algumas decisões relacionadas a DevOps que podem inspirar soluções em outros ambientes: gerenciamento de dezenas de milhares de servidores e banco de dados, backups e restores contínuos, schema migrations, entre outros.
When embracing Java 8 we walk down the yellow brick road to the wizard of lambdas. That road usually starts from the fear and terror of learning their syntax until finally getting to understand them and opening our minds to the fruitful fields of functional programming. But this road eventually reaches a final stage: the lambda abuse.
To master the lambdas art means to know when to use them and when not to not damage your brain and, most importantly, other Java developers’. Keep your code readable and maintainable, avoid becoming a lambda addict!
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...John De Goes
Maybe you've played around with functional programming before, but don't consider yourself a functional programmer. Or maybe you program functionally, but only in a dynamically-typed programming language. Or MAYBE you just like workshops with really long, ridiculously-sounding titles!
No matter, this workshop that teaches the super hot programming language PureScript is guaranteed to cure what ails you!
Come, learn about functions, learn about types, learn about data, and learn about how to smash them all together to build beautiful programs that are easy to test, easy to combine, and easy to reason about.
Become the functional programmer you were born to be!
Alexandre Gramfort (Telecom ParisTech): “Linear predictions with scikit-learn: simple and efficient”
Abstract: Scikit-Learn offers numerous state-of-the-art models for prediction (regression and classification). Linear models (e.g. Ridge, Logistic Regression) are the simplest of these models. They have pratical benefits such as interpretability and limited computation time while offering the best performance for some applications. This talk will cover the basics of these models with examples and demonstrate how they can scale to datasets that do not fit in memory or how they can incorporate simple polynomial non-linearities.
Bio: Alexandre Gramfort is Assistant Professor at Telecom Paristech in the signal and image processing department. His field of expertise is signal and image processing, statistical machine learning, software engineering and scientific computing applied primarily to neuroscience data. He has been a core developer of Scikit-Learn since 2010.
Flying Futures at the same sky can make the sun rise at midnightWiem Zine Elabidine
Template made by Slidesgo
Implementing responsive and high-performance applications is the most obvious challenge that we face in our programming life. It’s interesting to deeply study concurrency and parallelism on the JVM. In this talk you will learn how to describe parallel tasks and the idea behind Futures and the execution context. I will cover the tricky part of concurrency when the concurrent tasks share and use the same resources and how flying Futures in the same sky can make the sun rise at midnight! At the end I will talk about some possible solutions that you can use to reduce your worries about the pitfalls of concurrency.
Selection Sort, Insertion Sort, Bubble Sort Main idea: find the smallest element put it in the first position find the next smallest element put it in the second position
The Present and The Future of Functional Programming in C++Alexander Granin
Keynote talk for C++ Siberia 2019.
I'm speaking about why Functional Programming is important in C++ world, what is the philosophy of FP in C++, and what features do we have. I'm presenting a connection of constexpr and template metaprogramming to pure FP, and talking about why monads are inevitable. I'm also discussing an upcoming features in C++.
Software transactional memory. pure functional approachAlexander Granin
Slides for C++ Russia 2018
I'm presenting my `cpp_stm_free` library: composable monadic STM for C++ on Free monads for lock-free concurrent programming.
Небольшой доклад о мифах в функциональном программировании для DevDay@2GIS.
Slides for my talk to DevDay@2GIS about functional programming: See the talk here (Rus):
https://youtu.be/jSkYvNqQWqs
Линзы - концепция функционального программирования, позволяющая легко оперировать сколь угодно сложными структурами данных. Линзы решают две проблемы: снижают сложность обработки данных и предоставляют абстракцию над запросами к данным, делая код устойчивым к поломкам при изменении структуры данных.
Доклад о дизайне кода в функциональном стиле на C++, представленный вниманию плюсовиков на C++ User Group Novosibirsk 2014.
В качестве демонстрационного проекта была реализована игра "Амбер" по мотивам "Хроник Амбера" Р. Желязны.
https://github.com/graninas/Amber
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxrickgrimesss22
Discover the essential features to incorporate in your Winzo clone app to boost business growth, enhance user engagement, and drive revenue. Learn how to create a compelling gaming experience that stands out in the competitive market.
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
Utilocate offers a comprehensive solution for locate ticket management by automating and streamlining the entire process. By integrating with Geospatial Information Systems (GIS), it provides accurate mapping and visualization of utility locations, enhancing decision-making and reducing the risk of errors. The system's advanced data analytics tools help identify trends, predict potential issues, and optimize resource allocation, making the locate ticket management process smarter and more efficient. Additionally, automated ticket management ensures consistency and reduces human error, while real-time notifications keep all relevant personnel informed and ready to respond promptly.
The system's ability to streamline workflows and automate ticket routing significantly reduces the time taken to process each ticket, making the process faster and more efficient. Mobile access allows field technicians to update ticket information on the go, ensuring that the latest information is always available and accelerating the locate process. Overall, Utilocate not only enhances the efficiency and accuracy of locate ticket management but also improves safety by minimizing the risk of utility damage through precise and timely locates.
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Crescat
Crescat is industry-trusted event management software, built by event professionals for event professionals. Founded in 2017, we have three key products tailored for the live event industry.
Crescat Event for concert promoters and event agencies. Crescat Venue for music venues, conference centers, wedding venues, concert halls and more. And Crescat Festival for festivals, conferences and complex events.
With a wide range of popular features such as event scheduling, shift management, volunteer and crew coordination, artist booking and much more, Crescat is designed for customisation and ease-of-use.
Over 125,000 events have been planned in Crescat and with hundreds of customers of all shapes and sizes, from boutique event agencies through to international concert promoters, Crescat is rigged for success. What's more, we highly value feedback from our users and we are constantly improving our software with updates, new features and improvements.
If you plan events, run a venue or produce festivals and you're looking for ways to make your life easier, then we have a solution for you. Try our software for free or schedule a no-obligation demo with one of our product specialists today at crescat.io
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
Atelier - Innover avec l’IA Générative et les graphes de connaissancesNeo4j
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Allez au-delà du battage médiatique autour de l’IA et découvrez des techniques pratiques pour utiliser l’IA de manière responsable à travers les données de votre organisation. Explorez comment utiliser les graphes de connaissances pour augmenter la précision, la transparence et la capacité d’explication dans les systèmes d’IA générative. Vous partirez avec une expérience pratique combinant les relations entre les données et les LLM pour apporter du contexte spécifique à votre domaine et améliorer votre raisonnement.
Amenez votre ordinateur portable et nous vous guiderons sur la mise en place de votre propre pile d’IA générative, en vous fournissant des exemples pratiques et codés pour démarrer en quelques minutes.
What is Augmented Reality Image Trackingpavan998932
Augmented Reality (AR) Image Tracking is a technology that enables AR applications to recognize and track images in the real world, overlaying digital content onto them. This enhances the user's interaction with their environment by providing additional information and interactive elements directly tied to physical images.
OpenMetadata Community Meeting - 5th June 2024OpenMetadata
The OpenMetadata Community Meeting was held on June 5th, 2024. In this meeting, we discussed about the data quality capabilities that are integrated with the Incident Manager, providing a complete solution to handle your data observability needs. Watch the end-to-end demo of the data quality features.
* How to run your own data quality framework
* What is the performance impact of running data quality frameworks
* How to run the test cases in your own ETL pipelines
* How the Incident Manager is integrated
* Get notified with alerts when test cases fail
Watch the meeting recording here - https://www.youtube.com/watch?v=UbNOje0kf6E
Launch Your Streaming Platforms in MinutesRoshan Dwivedi
The claim of launching a streaming platform in minutes might be a bit of an exaggeration, but there are services that can significantly streamline the process. Here's a breakdown:
Pros of Speedy Streaming Platform Launch Services:
No coding required: These services often use drag-and-drop interfaces or pre-built templates, eliminating the need for programming knowledge.
Faster setup: Compared to building from scratch, these platforms can get you up and running much quicker.
All-in-one solutions: Many services offer features like content management systems (CMS), video players, and monetization tools, reducing the need for multiple integrations.
Things to Consider:
Limited customization: These platforms may offer less flexibility in design and functionality compared to custom-built solutions.
Scalability: As your audience grows, you might need to upgrade to a more robust platform or encounter limitations with the "quick launch" option.
Features: Carefully evaluate which features are included and if they meet your specific needs (e.g., live streaming, subscription options).
Examples of Services for Launching Streaming Platforms:
Muvi [muvi com]
Uscreen [usencreen tv]
Alternatives to Consider:
Existing Streaming platforms: Platforms like YouTube or Twitch might be suitable for basic streaming needs, though monetization options might be limited.
Custom Development: While more time-consuming, custom development offers the most control and flexibility for your platform.
Overall, launching a streaming platform in minutes might not be entirely realistic, but these services can significantly speed up the process compared to building from scratch. Carefully consider your needs and budget when choosing the best option for you.
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeAftab Hussain
Understanding variable roles in code has been found to be helpful by students
in learning programming -- could variable roles help deep neural models in
performing coding tasks? We do an exploratory study.
- These are slides of the talk given at InteNSE'23: The 1st International Workshop on Interpretability and Robustness in Neural Software Engineering, co-located with the 45th International Conference on Software Engineering, ICSE 2023, Melbourne Australia
Do you want Software for your Business? Visit Deuglo
Deuglo has top Software Developers in India. They are experts in software development and help design and create custom Software solutions.
Deuglo follows seven steps methods for delivering their services to their customers. They called it the Software development life cycle process (SDLC).
Requirement — Collecting the Requirements is the first Phase in the SSLC process.
Feasibility Study — after completing the requirement process they move to the design phase.
Design — in this phase, they start designing the software.
Coding — when designing is completed, the developers start coding for the software.
Testing — in this phase when the coding of the software is done the testing team will start testing.
Installation — after completion of testing, the application opens to the live server and launches!
Maintenance — after completing the software development, customers start using the software.
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppGoogle
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-fusion-buddy-review
AI Fusion Buddy Review: Key Features
✅Create Stunning AI App Suite Fully Powered By Google's Latest AI technology, Gemini
✅Use Gemini to Build high-converting Converting Sales Video Scripts, ad copies, Trending Articles, blogs, etc.100% unique!
✅Create Ultra-HD graphics with a single keyword or phrase that commands 10x eyeballs!
✅Fully automated AI articles bulk generation!
✅Auto-post or schedule stunning AI content across all your accounts at once—WordPress, Facebook, LinkedIn, Blogger, and more.
✅With one keyword or URL, generate complete websites, landing pages, and more…
✅Automatically create & sell AI content, graphics, websites, landing pages, & all that gets you paid non-stop 24*7.
✅Pre-built High-Converting 100+ website Templates and 2000+ graphic templates logos, banners, and thumbnail images in Trending Niches.
✅Say goodbye to wasting time logging into multiple Chat GPT & AI Apps once & for all!
✅Save over $5000 per year and kick out dependency on third parties completely!
✅Brand New App: Not available anywhere else!
✅ Beginner-friendly!
✅ZERO upfront cost or any extra expenses
✅Risk-Free: 30-Day Money-Back Guarantee!
✅Commercial License included!
See My Other Reviews Article:
(1) AI Genie Review: https://sumonreview.com/ai-genie-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
#AIFusionBuddyReview,
#AIFusionBuddyFeatures,
#AIFusionBuddyPricing,
#AIFusionBuddyProsandCons,
#AIFusionBuddyTutorial,
#AIFusionBuddyUserExperience
#AIFusionBuddyforBeginners,
#AIFusionBuddyBenefits,
#AIFusionBuddyComparison,
#AIFusionBuddyInstallation,
#AIFusionBuddyRefundPolicy,
#AIFusionBuddyDemo,
#AIFusionBuddyMaintenanceFees,
#AIFusionBuddyNewbieFriendly,
#WhatIsAIFusionBuddy?,
#HowDoesAIFusionBuddyWorks
Hand Rolled Applicative User ValidationCode KataPhilip Schwarz
Could you use a simple piece of Scala validation code (granted, a very simplistic one too!) that you can rewrite, now and again, to refresh your basic understanding of Applicative operators <*>, <*, *>?
The goal is not to write perfect code showcasing validation, but rather, to provide a small, rough-and ready exercise to reinforce your muscle-memory.
Despite its grandiose-sounding title, this deck consists of just three slides showing the Scala 3 code to be rewritten whenever the details of the operators begin to fade away.
The code is my rough and ready translation of a Haskell user-validation program found in a book called Finding Success (and Failure) in Haskell - Fall in love with applicative functors.
1. Final Tagless vs Free Monad
FPure, Kazan, 2019
1
Alexander Granin
graninas@gmail.com
Twitter: @graninas
2. Plan
● About me
● A Mysterious Software Design
● Final Tagless vs Free Monad
● To Whom It May Concern
● Links
2
3. About me
Developer Haskell, C++, C#, Python
Worked for Kaspersky Lab, 2GIS, Juspay, Restaumatic, Enecuum
Researcher Functional Programming in C++
Writer Book “Functional Design and Architecture”
Conferences FPConf, C++ Russia, C++ Siberia, Dev2Dev
Meetups LambdaNsk, FProgSpb, DevDay, TechTalks, ...
3
6. cartesianclosedcomicro-che.info/ccc/28
Why academia vs engineering battles
are rarely interesting
People familiar with theory
Haskellers Painstream developers
People working on real problems
Software engineers Mathskellers
Why engineering vs academia battles
are rarely useful
6
8. Inversion of Control
Why?
Complexity reducing
Abstraction
Separation of concerns
Low coupling
Effects control
Testability
Maintainability
How? When?
8
9. Inversion of Control
Why?
Complexity reducing
Abstraction
Separation of concerns
Low coupling
Effects control
Testability
Maintainability
How?
Final Tagless
Free Monad
Service Handle Pattern
ReaderT Pattern
...
When?
9
10. Inversion of Control
Why?
Complexity reducing
Abstraction
Separation of concerns
Low coupling
Effects control
Testability
Maintainability
How?
Final Tagless
Free Monad
Service Handle Pattern
ReaderT Pattern
...
When?
Big applications
Complex domain
Long lifecycle
Team development
Sirius Business™
10
12. data Meteor = Meteor
{ _size :: Int
, _mass :: Int
}
App
State
12
13. data Meteor = Meteor
{ _size :: Int
, _mass :: Int
}
data Region
= NorthEast
| NorthWest
| SouthEast
| SouthWest
App
State
13
14. data Meteor = Meteor
{ _size :: Int
, _mass :: Int
}
data Region
= NorthEast
| NorthWest
| SouthEast
| SouthWest
type Meteors = StateVar (Set Meteor)
type Catalogue = Map Region Meteors
App
State
14
15. data Meteor = Meteor
{ _size :: Int
, _mass :: Int
}
data Region
= NorthEast
| NorthWest
| SouthEast
| SouthWest
type Meteors = StateVar (Set Meteor)
type Catalogue = Map Region Meteors
data AppState = AppState
{ _catalogue :: Catalogue
, _totalMeteors :: StateVar Int
, _channel :: StateVar (Set Meteor)
}
App
State
15
17. initState :: StateL AppState
initState = do
ne <- newVarIO Set.empty
nw <- newVarIO Set.empty
se <- newVarIO Set.empty
sw <- newVarIO Set.empty
let catalogue = Map.fromList
[ (NorthEast, ne)
, (NorthWest, nw)
, (SouthEast, se)
, (SouthWest, sw)
]
StateL
App
State
17
18. initState :: StateL AppState
initState = do
ne <- newVarIO Set.empty
nw <- newVarIO Set.empty
se <- newVarIO Set.empty
sw <- newVarIO Set.empty
let catalogue = Map.fromList
[ (NorthEast, ne)
, (NorthWest, nw)
, (SouthEast, se)
, (SouthWest, sw)
]
published <- newVarIO Set.empty
total <- newVarIO 0
pure $ AppState catalogue total published
StateL
App
State
18
19. getRandomMeteor :: Region -> RandomL Meteor
getRandomMeteor region = do
size <- getRandomInt (1, 100)
mass <- getRandomInt (size, size * 100)
pure $ Meteor size mass region
RandomLStateL
App
State
19
20. getRandomMeteor :: Region -> RandomL Meteor
getRandomMeteor region = do
size <- getRandomInt (1, 100)
mass <- getRandomInt (size, size * 100)
pure $ Meteor size mass region
publishMeteor :: AppState -> Meteor -> StateL ()
publishMeteor st meteor
= modifyVar (_channel st) $ Set.insert meteor
RandomLStateL
App
State
Business
Logic
20
21. getRandomMeteor :: Region -> RandomL Meteor
getRandomMeteor region = do
size <- getRandomInt (1, 100)
mass <- getRandomInt (size, size * 100)
pure $ Meteor size mass region
publishMeteor :: AppState -> Meteor -> StateL ()
publishMeteor st meteor
= modifyVar (_channel st) $ Set.insert meteor
meteorShower :: AppState -> Region -> LangL ()
meteorShower st region = do
meteor <- evalRandom $ getRandomMeteor region
atomically $ publishMeteor st meteor
logInfo $ "New meteor discovered: " <> show meteor
LoggerL
LangL
RandomLStateL
App
State
Business
Logic
21
22. meteorsMonitoring :: AppL ()
meteorsMonitoring = do
st <- atomically $ initState
LoggerL
LangL
RandomLStateL
AppL
App
State
Business
Logic
22
23. meteorsMonitoring :: AppL ()
meteorsMonitoring = do
st <- atomically $ initState
process $ forever $ meteorShower st NorthEast
process $ forever $ meteorShower st NorthWest
process $ forever $ meteorShower st SouthEast
process $ forever $ meteorShower st SouthWest
process $ forever $ meteorCounter st
LoggerL
LangL
RandomLStateL
ProcessL
AppL
App
State
Business
Logic
23
24. meteorsMonitoring :: AppConfig -> AppL ()
meteorsMonitoring cfg = do
st <- atomically $ initState cfg
process $ forever $ meteorShower st NorthEast
process $ forever $ meteorShower st NorthWest
process $ forever $ meteorShower st SouthEast
process $ forever $ meteorShower st SouthWest
process $ forever $ meteorCounter st
LoggerL
LangL
RandomLStateL
ProcessL
AppL
App
State
Business
Logic
App
Configs
Application
24
25. meteorsMonitoring :: AppConfig -> AppL ()
meteorsMonitoring cfg = do
st <- atomically $ initState cfg
process $ forever $ meteorShower st NorthEast
process $ forever $ meteorShower st NorthWest
process $ forever $ meteorShower st SouthEast
process $ forever $ meteorShower st SouthWest
process $ forever $ meteorCounter st
main :: IO ()
main = do
loggerRt <- createLoggerRuntime loggerCfg
appRt <- createAppRuntime loggerRt
startApp appRt $ meteorsMonitoring appCfg
LoggerL
LangL
RandomLStateL
ProcessL
AppL
Runtime, Interpreters, Configs, Environment
Application
App
State
Business
Logic
App
Configs
25
26. Implementation
Effects, Subsystems & Services
(abstracted as Free eDSLs)
Domain & Business Logic
LoggerL
LangL
RandomLStateL
ProcessL
AppL
Runtime, Interpreters, Configs, Environment
Application
App
State
Business
Logic
App
Configs
26
27. The Only Thing That Matters
LoggerL
LangL
RandomLStateL
ProcessL
AppL
Runtime, Interpreters, Configs, Environment
Application
App
State
Business
Logic
App
Configs
27
30. data LoggerF next where
LogMessage :: LogLevel -> Message
-> (() -> next) -> LoggerF next
makeFunctorInstance ''LoggerF
type LoggerL = F LoggerF
class Monad m => LoggerL m where
logMessage :: LogLevel -> Message -> m ()
30
31. data LoggerF next where
LogMessage :: LogLevel -> Message
-> (() -> next) -> LoggerF next
makeFunctorInstance ''LoggerF
type LoggerL = F LoggerF
data RandomF next where
GetRandomInt :: (Int, Int) -> (Int -> next)
-> RandomF next
makeFunctorInstance ''RandomF
type RandomL = F RandomF
class Monad m => LoggerL m where
logMessage :: LogLevel -> Message -> m ()
class Monad m => RandomL m where
getRandomInt :: (Int, Int) -> m Int
31
32. data LoggerF next where
LogMessage :: LogLevel -> Message
-> (() -> next) -> LoggerF next
makeFunctorInstance ''LoggerF
type LoggerL = F LoggerF
data RandomF next where
GetRandomInt :: (Int, Int) -> (Int -> next)
-> RandomF next
makeFunctorInstance ''RandomF
type RandomL = F RandomF
data LangF next where
EvalLogger :: LoggerL ()
-> (() -> next) -> LangF next
EvalRandom :: RandomL a
-> (a -> next) -> LangF next
makeFunctorInstance ''LangF
type LangL = F LangF
class Monad m => LoggerL m where
logMessage :: LogLevel -> Message -> m ()
class Monad m => RandomL m where
getRandomInt :: (Int, Int) -> m Int
-- <NOT NEEDED> --
32
33. data LoggerF next where
LogMessage :: LogLevel -> Message
-> (() -> next) -> LoggerF next
makeFunctorInstance ''LoggerF
type LoggerL = F LoggerF
data RandomF next where
GetRandomInt :: (Int, Int) -> (Int -> next)
-> RandomF next
makeFunctorInstance ''RandomF
type RandomL = F RandomF
data LangF next where
EvalLogger :: LoggerL ()
-> (() -> next) -> LangF next
EvalRandom :: RandomL a
-> (a -> next) -> LangF next
makeFunctorInstance ''LangF
type LangL = F LangF
class Monad m => LoggerL m where
logMessage :: LogLevel -> Message -> m ()
class Monad m => RandomL m where
getRandomInt :: (Int, Int) -> m Int
-- <NOT NEEDED> --
Boilerplate??!
33
34. data LoggerF next where
LogMessage :: LogLevel -> Message
-> (() -> next) -> LoggerF next
makeFunctorInstance ''LoggerF
type LoggerL = F LoggerF
data RandomF next where
GetRandomInt :: (Int, Int) -> (Int -> next)
-> RandomF next
makeFunctorInstance ''RandomF
type RandomL = F RandomF
data LangF next where
EvalLogger :: LoggerL ()
-> (() -> next) -> LangF next
EvalRandom :: RandomL a
-> (a -> next) -> LangF next
makeFunctorInstance ''LangF
type LangL = F LangF
class Monad m => LoggerL m where
logMessage :: LogLevel -> Message -> m ()
class Monad m => RandomL m where
getRandomInt :: (Int, Int) -> m Int
-- <NOT NEEDED> --
Functors don’t compose?!!
Boilerplate??!
34
35. data LoggerF next where
LogMessage :: LogLevel -> Message
-> (() -> next) -> LoggerF next
makeFunctorInstance ''LoggerF
type LoggerL = F LoggerF
data RandomF next where
GetRandomInt :: (Int, Int) -> (Int -> next)
-> RandomF next
makeFunctorInstance ''RandomF
type RandomL = F RandomF
data LangF next where
EvalLogger :: LoggerL ()
-> (() -> next) -> LangF next
EvalRandom :: RandomL a
-> (a -> next) -> LangF next
makeFunctorInstance ''LangF
type LangL = F LangF
class Monad m => LoggerL m where
logMessage :: LogLevel -> Message -> m ()
class Monad m => RandomL m where
getRandomInt :: (Int, Int) -> m Int
-- <NOT NEEDED> --
Functors don’t compose?!!
Boilerplate??!
Too complicated!??
35
36. The Only Thing That Matters
LoggerL
LangL
RandomLStateL
ProcessL
AppL
Runtime, Interpreters, Configs, Environment
Application
App
State
Business
Logic
App
Configs
36
38. Free Monad vs Final Tagless
Interpreters definition
38
39. interpretRandomF :: RandomF a -> IO a
interpretRandomF (GetRandomInt r n) = ...
runRandomL :: RandomL a -> IO a
runRandomL = foldF interpretRandomF
instance RandomL (ReaderT CoreRuntime m) where
getRandomInt range = liftIO $ randomRIO range
39
40. interpretRandomF :: RandomF a -> IO a
interpretRandomF (GetRandomInt r n) = ...
runRandomL :: RandomL a -> IO a
runRandomL = foldF interpretRandomF
interpretLoggerF
:: HsLoggerHandle -> LoggerF a -> IO a
interpretLoggerF _ (LogMessage lvl msg n) = ...
runLoggerL
:: HsLoggerHandle -> L.LoggerL () -> IO ()
runLoggerL h = foldF (interpretLoggerF h)
instance RandomL (ReaderT CoreRuntime m) where
getRandomInt range = liftIO $ randomRIO range
instance LoggerL (ReaderT CoreRuntime m) where
logMessage lvl msg = blaBla
40
41. interpretRandomF :: RandomF a -> IO a
interpretRandomF (GetRandomInt r n) = ...
runRandomL :: RandomL a -> IO a
runRandomL = foldF interpretRandomF
interpretLoggerF
:: HsLoggerHandle -> LoggerF a -> IO a
interpretLoggerF _ (LogMessage lvl msg n) = ...
runLoggerL
:: HsLoggerHandle -> L.LoggerL () -> IO ()
runLoggerL h = foldF (interpretLoggerF h)
interpretLangF :: CoreRuntime -> LangF a -> IO a
interpretLangF coreRt (EvalLogger l n) = ...
interpretLangF coreRt (EvalRandom r n) = ...
runLangL :: CoreRuntime -> LangL a -> IO a
runLangL coreRt = foldF (interpretLangF coreRt)
instance RandomL (ReaderT CoreRuntime m) where
getRandomInt range = liftIO $ randomRIO range
instance LoggerL (ReaderT CoreRuntime m) where
logMessage lvl msg = blaBla
-- <NOT NEEDED> --
41
42. interpretRandomF :: RandomF a -> IO a
interpretRandomF (GetRandomInt r n) = ...
runRandomL :: RandomL a -> IO a
runRandomL = foldF interpretRandomF
interpretLoggerF
:: HsLoggerHandle -> LoggerF a -> IO a
interpretLoggerF _ (LogMessage lvl msg n) = ...
runLoggerL
:: HsLoggerHandle -> L.LoggerL () -> IO ()
runLoggerL h = foldF (interpretLoggerF h)
interpretLangF :: CoreRuntime -> LangF a -> IO a
interpretLangF coreRt (EvalLogger l n) = ...
interpretLangF coreRt (EvalRandom r n) = ...
runLangL :: CoreRuntime -> LangL a -> IO a
runLangL coreRt = foldF (interpretLangF coreRt)
instance RandomL (ReaderT CoreRuntime m) where
getRandomInt range = liftIO $ randomRIO range
instance LoggerL (ReaderT CoreRuntime m) where
logMessage lvl msg = blaBla
-- <NOT NEEDED> --
Boilerplate??!
42
43. interpretRandomF :: RandomF a -> IO a
interpretRandomF (GetRandomInt r n) = ...
runRandomL :: RandomL a -> IO a
runRandomL = foldF interpretRandomF
interpretLoggerF
:: HsLoggerHandle -> LoggerF a -> IO a
interpretLoggerF _ (LogMessage lvl msg n) = ...
runLoggerL
:: HsLoggerHandle -> L.LoggerL () -> IO ()
runLoggerL h = foldF (interpretLoggerF h)
interpretLangF :: CoreRuntime -> LangF a -> IO a
interpretLangF coreRt (EvalLogger l n) = ...
interpretLangF coreRt (EvalRandom r n) = ...
runLangL :: CoreRuntime -> LangL a -> IO a
runLangL coreRt = foldF (interpretLangF coreRt)
instance RandomL (ReaderT CoreRuntime m) where
getRandomInt range = liftIO $ randomRIO range
instance LoggerL (ReaderT CoreRuntime m) where
logMessage lvl msg = blaBla
-- <NOT NEEDED> --
Boilerplate??!
Interpreters don’t compose?!!
43
44. interpretRandomF :: RandomF a -> IO a
interpretRandomF (GetRandomInt r n) = ...
runRandomL :: RandomL a -> IO a
runRandomL = foldF interpretRandomF
interpretLoggerF
:: HsLoggerHandle -> LoggerF a -> IO a
interpretLoggerF _ (LogMessage lvl msg n) = ...
runLoggerL
:: HsLoggerHandle -> L.LoggerL () -> IO ()
runLoggerL h = foldF (interpretLoggerF h)
interpretLangF :: CoreRuntime -> LangF a -> IO a
interpretLangF coreRt (EvalLogger l n) = ...
interpretLangF coreRt (EvalRandom r n) = ...
runLangL :: CoreRuntime -> LangL a -> IO a
runLangL coreRt = foldF (interpretLangF coreRt)
instance RandomL (ReaderT CoreRuntime m) where
getRandomInt range = liftIO $ randomRIO range
instance LoggerL (ReaderT CoreRuntime m) where
logMessage lvl msg = blaBla
-- <NOT NEEDED> --
Boilerplate??!
Interpreters don’t compose?!!
Slow??!!
44
52. getRandomMeteor
:: Region -> RandomL Meteor
publishMeteor
:: AppState -> Meteor -> StateL ()
getRandomMeteor
:: RandomL m => Region -> m Meteor
publishMeteor
:: AppState -> Meteor -> STM ()
52
53. getRandomMeteor
:: Region -> RandomL Meteor
publishMeteor
:: AppState -> Meteor -> StateL ()
meteorShower
:: AppState -> Region -> LangL ()
getRandomMeteor
:: RandomL m => Region -> m Meteor
publishMeteor
:: AppState -> Meteor -> STM ()
meteorShower
:: (MonadUnliftIO m, LoggerL m, RandomL m)
=> AppState -> Region -> m ()
53
54. getRandomMeteor
:: Region -> RandomL Meteor
publishMeteor
:: AppState -> Meteor -> StateL ()
meteorShower
:: AppState -> Region -> LangL ()
meteorsMonitoring
:: AppConfig -> AppL ()
getRandomMeteor
:: RandomL m => Region -> m Meteor
publishMeteor
:: AppState -> Meteor -> STM ()
meteorShower
:: (MonadUnliftIO m, LoggerL m, RandomL m)
=> AppState -> Region -> m ()
meteorsMonitoring
:: (MonadUnliftIO m, ControlFlowL m,
LoggerL m, RandomL m)
=> AppConfig -> m ()
54
55. getRandomMeteor
:: RandomL m => Region -> m Meteor
publishMeteor
:: AppState -> Meteor -> STM ()
meteorShower
:: (MonadUnliftIO m, LoggerL m, RandomL m)
=> AppState -> Region -> m ()
meteorsMonitoring
:: (MonadUnliftIO m, ControlFlowL m,
LoggerL m, RandomL m)
=> AppConfig -> m ()
55
Boilerplate.
56. getRandomMeteor
:: RandomL m => Region -> m Meteor
publishMeteor
:: AppState -> Meteor -> STM ()
meteorShower
:: (MonadUnliftIO m, LoggerL m, RandomL m)
=> AppState -> Region -> m ()
meteorsMonitoring
:: (MonadUnliftIO m, ControlFlowL m,
LoggerL m, RandomL m)
=> AppConfig -> m ()
Boilerplate.
Maintenance nightmare.
56
57. getRandomMeteor
:: RandomL m => Region -> m Meteor
publishMeteor
:: AppState -> Meteor -> STM ()
meteorShower
:: (MonadUnliftIO m, LoggerL m, RandomL m,
HasCoreRuntime m)
=> AppState -> Region -> m ()
meteorsMonitoring
:: (MonadUnliftIO m, ControlFlowL m,
LoggerL m, RandomL m, HasCoreRuntime m)
=> AppConfig -> m ()
Maintenance nightmare.
Boilerplate.
Implementation details.
57
58. getRandomMeteor
:: (MonadUnliftIO m, RandomL m)
=> Region -> m Meteor
publishMeteor
:: AppState -> Meteor -> STM ()
meteorShower
:: (MonadUnliftIO m, LoggerL m, RandomL m,
HasCoreRuntime m)
=> AppState -> Region -> m ()
meteorsMonitoring
:: (MonadUnliftIO m, ControlFlowL m,
LoggerL m, RandomL m, HasCoreRuntime m)
=> AppConfig -> m ()
Maintenance nightmare.
Boilerplate.
Illusion of control.
Implementation details.
58
59. getRandomMeteor
:: Region -> AppEff Meteor
publishMeteor
:: AppState -> Meteor -> STM ()
meteorShower
:: AppState -> Region -> AppEff ()
meteorsMonitoring
:: AppConfig -> AppEff ()
type Eff =
( MonadUnliftIO m
, ControlFlowL m
, LoggerL m
, RandomL m
)
newtype AppEff a = AppT
{ unAppT :: ReaderT CoreRuntime Eff a
}
deriving (Functor, Applicative, Monad)
59
65. Functors of free monads aren’t composable.
Interpreters of free monads aren’t composable.
65
66. Functors of free monads aren’t composable.
Interpreters of free monads aren’t composable.
Free monads aren’t composable.
66
67. Functors of free monads aren’t composable.
Interpreters of free monads aren’t composable.
Free monads aren’t composable.
Free monads are slow.
67
68. Functors of free monads aren’t composable.
Interpreters of free monads aren’t composable.
Free monads aren’t composable.
Free monads are slow.
Essentially, Free Monads are equivalent to Final Tagles.
68
69. Functors of free monads aren’t composable.
Interpreters of free monads aren’t composable.
Free monads aren’t composable.
Free monads are slow.
Essentially, Free Monads are equivalent to Final Tagles.
This paper says it’s impossible.
69
70. Functors of free monads aren’t composable.
Interpreters of free monads aren’t composable.
Free monads aren’t composable.
Free monads are slow.
Essentially, Free Monads are equivalent to Final Tagles.
This paper says it’s impossible.
This paper says it’s bad.
70
71. Functors of free monads aren’t composable.
Interpreters of free monads aren’t composable.
Free monads aren’t composable.
Free monads are slow.
Essentially, Free Monads are equivalent to Final Tagles.
This paper says it’s impossible.
This paper says it’s bad.
You haven’t read the X’s paper, how dare you?!
71
72. Software development is not “Math”.
Software development is “Physics”.
In here, experiment is the only measure of truth.
72
73. Links
Code Hydra framework
My book Functional Design and Architecture
Book’s Patreon Patreon/functional_design_and_architecture
My other talks https://graninas.com/talks-eng
My poetry ;) https://graninas.com/creations/#poetry
73
74. Free monads are powerful and fast.
FPure, Kazan, 2019
74
Alexander Granin
graninas@gmail.com
Twitter: @graninas