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++.
With Ateji PX, no need to be specialized in Java threads, parallel programming on multicore, GPU, cloud and grid can be as simple as inserting a || operator in the source code.
With Ateji PX, no need to be specialized in Java threads, parallel programming on multicore, GPU, cloud and grid can be as simple as inserting a || operator in the source code.
PVS-Studio team experience: checking various open source projects, or mistake...Andrey Karpov
To let the world know about our product, we check open-source projects. By the moment we have checked 245 projects. A side effect: we found 9574 errors and notified the authors about them.
C++20 comes with some big new language features: modules, coroutines, concepts, spaceship, and many new libraries. But apart from all those, C++20 also offers many small language improvements, making C++ more powerful and expressive, but also safer and more consistent. This talk is an overview over all those smaller additions to the core language that will make your life easier. We will discuss much-needed improvements to existing facilities such as lambdas, CTAD, structured bindings, and initialisation, as well as brand-new language utilities that you may not yet have heard about!
The aptitude test consisted tricky questions on core subjects of CSE like C , C++, Java ,Data Structures, Database, Computer Networks, Theory of Computation.
This presentation is part of training session delivered during Train The Trainer (TOT) program on Embedded Software Engineer job role supported by ESSCI.
A minimal collection of most wanted and widely accepted idioms and coding conventions for C++ development presented with examples and explanations. The lecture targets performance oriented codes so emphasis is on performance-friendly techiques.
Topics covered:
1) Design issues: idioms and best practices
- Resource Aquisition Is Initialization (RAII)
- Ownership semantics and smart pointers
- Header files: dependencies and decoupling
2) Objects Construction/Destruction/Copying
- Designing constructors
- Rule Of Three
- Transactional programming
3) Namespaces
- ADL/Koenig Lookup
4) Static analyzers
PVS-Studio team experience: checking various open source projects, or mistake...Andrey Karpov
To let the world know about our product, we check open-source projects. By the moment we have checked 245 projects. A side effect: we found 9574 errors and notified the authors about them.
C++20 comes with some big new language features: modules, coroutines, concepts, spaceship, and many new libraries. But apart from all those, C++20 also offers many small language improvements, making C++ more powerful and expressive, but also safer and more consistent. This talk is an overview over all those smaller additions to the core language that will make your life easier. We will discuss much-needed improvements to existing facilities such as lambdas, CTAD, structured bindings, and initialisation, as well as brand-new language utilities that you may not yet have heard about!
The aptitude test consisted tricky questions on core subjects of CSE like C , C++, Java ,Data Structures, Database, Computer Networks, Theory of Computation.
This presentation is part of training session delivered during Train The Trainer (TOT) program on Embedded Software Engineer job role supported by ESSCI.
A minimal collection of most wanted and widely accepted idioms and coding conventions for C++ development presented with examples and explanations. The lecture targets performance oriented codes so emphasis is on performance-friendly techiques.
Topics covered:
1) Design issues: idioms and best practices
- Resource Aquisition Is Initialization (RAII)
- Ownership semantics and smart pointers
- Header files: dependencies and decoupling
2) Objects Construction/Destruction/Copying
- Designing constructors
- Rule Of Three
- Transactional programming
3) Namespaces
- ADL/Koenig Lookup
4) Static analyzers
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Brendan Eich
Slides I prepared for the 29 January 2014 Ecma TC39 meeting, on Value Objects in JS, an ES7 proposal -- this one shotgunned the roadmap-space of declarative syntax, to find the right amount per TC39 (nearly zero, turns out).
Design Patterns - Compiler Case Study - Hands-on ExamplesGanesh Samarthyam
This presentation takes a case-study based approach to design patterns. A purposefully simplified example of expression trees is used to explain how different design patterns can be used in practice. Examples are in C#, but is relevant for anyone who is from object oriented background.
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Windows Developer
Visual Studio 2015 provides the best in class C++ development experience whether you are targeting Android, iOS, Linux, Windows, or IoT. With a good mix of demos and showcase for new C++ experiences, this talk goes over six great reasons why you should migrate to Visual Studio 2015 today.
A small introduction on the C++14 improved static introspection of the IOD library and the C++14 web framework Silicon.
https://github.com/matt-42/silicon
https://github.com/matt-42/iod
Download this Presentation for free from www.ecti.co.in/downloads.html
No SIGN UP REQUIRED.
C++ Programming Training PPTs / PDFs for free.
Download free C++ Programming study material. Learn C++ Programming for free in 2 hours.
Presentation on C++ Programming Languagesatvirsandhu9
It consists information about c++ programming language which is a object oriented language. This presentation is very useful for those who want to learn c++ from beginning.
Types of C++ functions:
Standard functions
User-defined functions
C++ function structure
Function signature
Function body
Declaring and Implementing C++ 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 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.
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
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
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…
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
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
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.
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.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIVladimir Iglovikov, Ph.D.
Presented by Vladimir Iglovikov:
- https://www.linkedin.com/in/iglovikov/
- https://x.com/viglovikov
- https://www.instagram.com/ternaus/
This presentation delves into the journey of Albumentations.ai, a highly successful open-source library for data augmentation.
Created out of a necessity for superior performance in Kaggle competitions, Albumentations has grown to become a widely used tool among data scientists and machine learning practitioners.
This case study covers various aspects, including:
People: The contributors and community that have supported Albumentations.
Metrics: The success indicators such as downloads, daily active users, GitHub stars, and financial contributions.
Challenges: The hurdles in monetizing open-source projects and measuring user engagement.
Development Practices: Best practices for creating, maintaining, and scaling open-source libraries, including code hygiene, CI/CD, and fast iteration.
Community Building: Strategies for making adoption easy, iterating quickly, and fostering a vibrant, engaged community.
Marketing: Both online and offline marketing tactics, focusing on real, impactful interactions and collaborations.
Mental Health: Maintaining balance and not feeling pressured by user demands.
Key insights include the importance of automation, making the adoption process seamless, and leveraging offline interactions for marketing. The presentation also emphasizes the need for continuous small improvements and building a friendly, inclusive community that contributes to the project's growth.
Vladimir Iglovikov brings his extensive experience as a Kaggle Grandmaster, ex-Staff ML Engineer at Lyft, sharing valuable lessons and practical advice for anyone looking to enhance the adoption of their open-source projects.
Explore more about Albumentations and join the community at:
GitHub: https://github.com/albumentations-team/albumentations
Website: https://albumentations.ai/
LinkedIn: https://www.linkedin.com/company/100504475
Twitter: https://x.com/albumentations
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
5. Eric Niebler, C++ Siberia 2015
Ranges for the Standard Library
Bartosz Milewski, С++ User Group 2014
Re-discovering monads in C++
6. Eric Niebler, C++ Siberia 2015
Ranges for the Standard Library
Bartosz Milewski, С++ User Group 2014
Re-discovering monads in C++
Ivan Čukić, C++ Siberia 2017
Atom heart monad (FRP in C++)
7. My talks about Functional Programming in C++
С++ User Group 2014
Functional and Declarative Design in C++
8. My talks about Functional Programming in C++
С++ User Group 2014
Functional and Declarative Design in C++
С++ Siberia 2015
Functional Microscope: Lenses in C++
9. My talks about Functional Programming in C++
С++ User Group 2014
Functional and Declarative Design in C++
С++ Siberia 2015
Functional Microscope: Lenses in C++
С++ Russia 2016
Functional “Life”: Parallel Cellular Automata and Comonads in C++
10. С++ User Group 2014
Functional and Declarative Design in C++
С++ Siberia 2015
Functional Microscope: Lenses in C++
С++ Russia 2016
Functional “Life”: Parallel Cellular Automata and Comonads in C++
С++ Russia 2018
Functional Approach to Software Transactional Memory in C++
My talks about Functional Programming in C++
11. struct Presentation
{
Philosophy of Functional Programming in C++
Elements of Functional Programming in C++
Functional Design, Patterns and Approaches In C++
Limitations of Functional Programming in C++
};
19. C++ -> C++11/14 -> C++17/20Abstract C++ developer:
C++ Developer Evolution
20. C++ -> C++11/14 -> C++17/20
C++ -> Pain! -> C++11/14 -> My brain! -> C++17/20
Abstract C++ developer:
Real C++ developer:
C++ Developer Evolution
21. C++ -> C++11/14 -> C++17/20
C++ -> Pain! -> C++11/14 -> My brain! -> C++17/20
C++ -> WTF -> Go
Abstract C++ developer:
Real C++ developer:
Beginner C++ developer:
C++ Developer Evolution
22. C++ -> C++11/14 -> C++17/20
C++ -> Pain! -> C++11/14 -> My brain! -> C++17/20
C++ -> WTF -> Go
C++ -> C++11/14 -> Why?!! -> Haskell -> C++17/20
Abstract C++ developer:
Real C++ developer:
Beginner C++ developer:
Modern C++ developer:
C++ Developer Evolution
23. C++ -> C++11/14 -> C++17/20
C++ -> Pain! -> C++11/14 -> My brain! -> C++17/20
C++ -> WTF -> Go
C++ -> C++11/14 -> Why?!! -> Haskell -> C++17/20
C++ -> C++11/14 -> Uh-Oh -> Rust
Abstract C++ developer:
Real C++ developer:
Beginner C++ developer:
Modern C++ developer:
Tired C++ developer:
C++ Developer Evolution
24. C++ -> C++11/14 -> C++17/20
C++ -> Pain! -> C++11/14 -> My brain! -> C++17/20
C++ -> WTF -> Go
C++ -> C++11/14 -> Why?!! -> Haskell -> C++17/20
C++ -> C++11/14 -> Uh-Oh -> Rust
C++98 -> Please, leave me alone -> C++98
Abstract C++ developer:
Real C++ developer:
Beginner C++ developer:
Modern C++ developer:
Tired C++ developer:
Old School C++ developer:
C++ Developer Evolution
26. Verbosity of imperative and OO code FP data types and constructs
algebraic data types, higher order functions, lambdas, closures
pattern-matching, currying, partial application
Functional programming in my C++?!!
26
27. Verbosity of imperative and OO code
Unsafety, bugs and lack or guarantees
FP data types and constructs
Reliable FP concepts, guarantees
purity, immutability, side effects control, type level programming
recursion, range-based iteration, monoids, functors, monads...
Functional programming in my C++?!!
27
28. Verbosity of imperative and OO code
Unsafety, bugs and lack or guarantees
Leaking and heavy abstractions
FP data types and constructs
Reliable FP concepts, guarantees
Declarative and functional design
domain specific languages, persistent data types
laziness, composition, combinators, first class functions
Functional programming in my C++?!!
28
29. Verbosity of imperative and OO code
Unsafety, bugs and lack or guarantees
Leaking and heavy abstractions
Complexity of multithreaded programs
FP data types and constructs
Reliable FP concepts, guarantees
Declarative and functional design
Functional approaches
functional reactive programming, software transactional memory,
async / par / future monad, automatic parallelism
Functional programming in my C++?!!
29
31. 𝝺ambdas
[](auto i) { return i + 1; }
i -> i + 1
i => i + 1
lambda i: i + 1
| i | -> i + 1
32. 𝝺ambdas in C++
<>(int x, int y) -> int {return x + y;}
[|b|]() { return |b| -> set_text("World"); }
i => i + 1
[](auto i) { return i + 1; }
[]<>(auto i) { return i + 1; }
33. 𝝺ambdas in C++
Idea of the feature
Standard issuing
Feature adoption
Feature improvements
== You are standing here ==
Feature improvements
<>(int x, int y) -> int {return x + y;}
[|b|]() { return |b| -> set_text("World"); }
i => i + 1
[](auto i) { return i + 1; }
[]<>(auto i) { return i + 1; }
34. 𝝺ambdas in C++
Idea of the feature
Standard issuing
Feature adoption
Feature improvements
== You are standing here ==
Feature improvements
2011
...2000...
2014, 2017
...2011...
2020
2019
<>(int x, int y) -> int {return x + y;}
[|b|]() { return |b| -> set_text("World"); }
i => i + 1
[](auto i) { return i + 1; }
[]<>(auto i) { return i + 1; }
35. Idea of the feature
Pondering and thinking
Reference implementation
Discussions in Committee
Drafting in Standard
Implementation in compilers
Standard issuing
Feature adoption
Feature improvements
== You are standing here ==
Feature improvements
𝝺ambdas in C++
2011
...2000...
<>(int x, int y) -> int {return x + y;}
[|b|]() { return |b| -> set_text("World"); }
i => i + 1
[](auto i) { return i + 1; }
[]<>(auto i) { return i + 1; }
2014, 2017
...2011...
2008 - 2011
2006 - 2008
2020
2019
48. Recursive constexpr pow() function
using UInt = uint64_t;
constexpr UInt pow(UInt a, UInt b) {
return b == 0
? 1
: a * pow(a, b - 1);
}
48
49. Recursive constexpr tower() function
using UInt = uint64_t;
constexpr UInt pow(UInt a, UInt b) {
return b == 0
? 1
: a * pow(a, b - 1);
}
constexpr UInt tower(UInt a, UInt b) {
return b == 0
? throw std::invalid_argument("b == 0")
: b == 1
? a
: pow(a, tower(a, b - 1));
}
49
50. Throwing exception at compile time?
using UInt = uint64_t;
constexpr UInt pow(UInt a, UInt b) {
return b == 0
? 1
: a * pow(a, b - 1);
}
constexpr UInt tower(UInt a, UInt b) {
return b == 0
? throw std::invalid_argument("b == 0")
: b == 1
? a
: pow(a, tower(a, b - 1));
}
50
75. Monadic error handling with Expected<T, E>
template <typename T, typename E>
using Expected = std::variant<T, E>;
enum class Errors {
ZeroTowerError = 0,
ZeroDivisionError = 1
};
using UInt = uint64_t;
using SafeInt = Expected<UInt, Errors>;
constexpr SafeInt make_pure (const UInt& v) { return { v }; }
constexpr SafeInt make_error(const Errors& e) { return { e }; }
75
76. UInt pow(UInt a, UInt n) { ... }
UInt tower(UInt a, UInt b) {
return b == 0
? throw std::invalid_argument("b == 0")
: b == 1
? a
: pow(a, tower(a, b - 1));
}
Unsafe tower() function
76
77. UInt pow(UInt a, UInt n) { ... }
SafeInt safe_tower(UInt a, UInt b) {
return b == 0
? make_error(Errors::ZeroTowerError)
: b == 1
? a
: pow(a, tower(a, b - 1));
}
safe_tower() function
77
78. UInt pow(UInt a, UInt n) { ... }
SafeInt safe_tower(UInt a, UInt b) {
return b == 0
? make_error(Errors::ZeroTowerError)
: b == 1
? a
: pow(a, tower(a, b - 1));
}
safe_tower() function
78
79. UInt pow(UInt a, UInt n) { ... }
SafeInt safe_tower(UInt a, UInt b) {
return b == 0
? make_error(Errors::ZeroTowerError)
: b == 1
? a
: pow(a, tower(a, b - 1));
}
safe_tower() function
79
80. UInt pow(UInt a, UInt n) { ... }
SafeInt safe_tower(UInt a, UInt b) {
return b == 0
? make_error(Errors::ZeroTowerError)
: b == 1
? make_pure(a)
: make_pure(pow(a, tower(a, b - 1)));
}
safe_tower() function
80
81. UInt pow(UInt a, UInt n) { ... }
SafeInt safe_tower(UInt a, UInt b) {
return b == 0
? make_error(Errors::ZeroTowerError)
: b == 1
? make_pure(a)
: make_pure(pow(a, tower(a, b - 1)));
}
safe_tower() function
81
82. UInt pow(UInt a, UInt n) { ... }
SafeInt safe_tower(UInt a, UInt b) {
return b == 0
? make_error(Errors::ZeroTowerError)
: b == 1
? make_pure(a)
: make_pure(pow(a, tower(a, b - 1)));
}
safe_tower() function
82
83. UInt pow(UInt a, UInt n) { ... }
SafeInt safe_tower(UInt a, UInt b) {
return b == 0
? make_error(Errors::ZeroTowerError)
: b == 1
? make_pure(a)
: make_pure(pow(a, safe_tower(a, b - 1)));
}
safe_tower() function
83
84. UInt pow(UInt a, UInt n) { ... }
SafeInt safe_tower(UInt a, UInt b) {
return b == 0
? make_error(Errors::ZeroTowerError)
: b == 1
? make_pure(a)
: make_pure(pow(a, safe_tower(a, b - 1)));
}
safe_tower() function
84
85. UInt pow(UInt a, UInt n) { ... }
SafeInt safe_tower(UInt a, UInt b) {
return b == 0
? make_error(Errors::ZeroTowerError)
: b == 1
? make_pure(a)
: make_pure(pow(a, safe_tower(a, b - 1)));
}
safe_tower() function
85
86. UInt pow(UInt a, UInt n) { ... }
SafeInt safe_tower(UInt a, UInt b) {
return b == 0
? make_error(Errors::ZeroTowerError)
: b == 1
? make_pure(a)
: mbind(safe_tower(a, b - 1),
[=](UInt v) { return make_pure(pow(a, v)); }
);
}
Monadic binding*
86
* Almost
87. UInt pow(UInt a, UInt n) { ... }
SafeInt safe_tower(UInt a, UInt b) {
return b == 0
? make_error(Errors::ZeroTowerError)
: b == 1
? make_pure(a)
: mbind(safe_tower(a, b - 1),
[=](UInt v) { return make_pure(pow(a, v)); }
);
}
Monadic binding*
87
* Almost
SafeInt mbind (SafeInt, Func<SafeInt, UInt>)
mbind :: SafeInt -> (UInt -> SafeInt) -> SafeInt
91. auto mul10 = [](UInt i) { return make_pure(i * 10); };
SafeInt v1 = safe_tower(2, 3);
SafeInt v2 = mbind(
mbind(v1, mul10),
mul10
);
SafeInt v2 = do {
UInt i1 <- safe_tower(2, 3);
UInt i2 <- mul10(i1);
return mul10(i2);
}
Monadic chaining*, do-notation dream
91
* Almost
m i d
d e n “<-”
92. expected<int, Errors> safe_calculate(int a, int b) {
do {
UInt v <- safe_tower(a, b);
int r <- safe_divide(v, b);
return r;
}
}
Do-notation dreams
expected<int, Errors> safe_calculate(int a, int b) {
UInt v = try safe_tower(a, b);
int r = try safe_divide(v, b);
return r;
}
92
Has l-li “do”
Pro l P0650R1
“C++ Mon In e f ”
94. expected<int, Errors> safe_calculate(int a, int b) {
do {
UInt v <- safe_tower(a, b);
int r <- safe_divide(v, b);
return r;
}
}
Monads everywhere: expected<>
94
mbind :: expected<A, E> -> (A -> expected<B, E>) -> expected<B, E>
117. 117
Issues of Functional Programming in C++
● Absence of currying
● Dangerous closures
● Lambdas are verbose
● Tuple is extremely verbose
118. 118
Real Problems of Functional Programming in C++
● Poor type system
○ No real Algebraic Data Types
○ No real function type
○ Lambdas have unique types
○ No real pattern matching (yet)
■ Won’t be expression??
○ Type inference is weak
● Composition of functions is complicated
● No native support of monads (in 2019)
119. 119
Real Problems of Functional Programming in C++
C++
● Poor type system
○ No real Algebraic Data Types
○ No real function type
○ Lambdas have unique types
○ No real pattern matching (yet)
■ Won’t be expression??
○ Type inference is weak
● Composition of functions is complicated
● No native support of monads (in 2019)