Monads in Modern C++
Bloomberg Finance L.P. All rights reserved. © 2023 Bloomberg Finance L.P. All rights reserved. Monads in Modern C++ ACCU 2023 April 20, 2023 Georgi Koyrushki, Senior Software Engineer Alistair Fisher All rights reserved. Agenda • Motivation: Why do we care about monads? • Theoretical basis: What are monads? • Beyond theory: Monads in the STL and the wider world 4© 2018 Bloomberg Finance L.P. All return values in a type with additional computation. In addition to defining a wrapping monadic type, monads define two operators: one to wrap a value in the monad type, and another to compose together functions0 码力 | 94 页 | 4.56 MB | 5 月前3Applicative: The Forgotten Functional Pattern
for them I've written code that uses them, and it was good I completely understand a) functors b) monads c) applicative 6.5FIRST, A QUICK SURVEY FIRST, A QUICK SURVEY I've heard of these functional patterns completely understand a) functors b) monads c) applicative Haskell informs all my API designs 6.6OR MAYBE THIS…? OR MAYBE THIS…? Well, I thought I knew about monads until you just said that, now I'm not so sure… Well, I thought I knew about monads until you just said that, now I'm not so sure… 7OR MAYBE THIS…? OR MAYBE THIS…? Well, I thought I knew about monads until you just said that, now I'm not0 码力 | 141 页 | 11.33 MB | 5 月前3The Hitchhiker’s Guide to Logical Verification
. . . . . 87 5.7 Summary of New Lean Constructs . . . . . . . . . . . . . . . . . . . . . 91 6 Monads 93 6.1 Introductory Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 6.2 Two Operations love06 _monads_demo. lean is the main file associated with Chapter 6 (“Monads”), which is demonstrated in class, love06 _monads_ex ercise_sheet.lean is the exercise sheet, and love06 _ monads_homework_sheet propositional extensionality Tactic linarith invokes a procedure for linear arithmetic Chapter 6 Monads Pure functional programming can sometimes feel overly restrictive. Efectful func- tional programming0 码力 | 215 页 | 1.95 MB | 1 年前3Programming in Lean Release 3.4.2
Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 4 Monads 23 4.1 The option monad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . manually in the course of a computation can be tedious, but it is much more pleasant and natural using monads, which we turn to next. 3.4 Input and Output Lean can support programs that interact with the outside and Output 21 Programming in Lean, Release 3.4.2 22 Chapter 3. Basic Programming CHAPTER FOUR MONADS In this chapter, we will describe a powerful abstraction known as a monad. A monad is a type constructor0 码力 | 51 页 | 220.07 KB | 1 年前3An Introduction to Lean
. . 30 3.3 Inhabited Types, Subtypes, and Option Types . . . . . . . . . . . . . . . . 32 3.4 Monads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 3.5 Input and Output methods and techniques of functional programming, including higher types, type classes, records, monads, and other abstractions. In fact, we have the entire Lean library at our disposal. With just a few but it is much more pleasant and natural using monads, which we turn to next. 3.4 Monads This section assumes that you are familiar with the use of monads in functional program- ming languages, such as0 码力 | 48 页 | 191.92 KB | 1 年前3Leveraging a Functional Approach for More Testable and Maintainable ROS 2 Code
effects ● Functional programming is identified by the use of higher order functions, pure functions, monads, declarative syntax What is Functional Programming?● A programming paradigm characterized by the effects ● Functional programming is identified by the use of higher order functions, pure functions, monads, declarative syntax ○ C++ has all the tools to implement functional programming, including lambda effects ● Functional programming is identified by the use of higher order functions, pure functions, monads, declarative syntax ○ C++ has all the tools to implement functional programming, including lambda0 码力 | 200 页 | 1.77 MB | 5 月前3The Lean Reference Manual Release 3.3.0
Virtual Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 7.2 Monads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 56 Chapter 6. Tactics CHAPTER SEVEN PROGRAMMING 7.1 The Virtual Machine 7.2 Monads (Describe instances of monads and monadic notation.) 57 The Lean Reference Manual, Release 3.3.0 58 Chapter 70 码力 | 67 页 | 266.23 KB | 1 年前3Haskell 2010 Language Report
The Monad class defines the basic operations over a monad. See Chapter 7 for more information about monads. “do” expressions provide a convenient syntax for writing monadic expressions (see Section 3.14) module provides the Functor, Monad and MonadPlus classes, together with some useful operations on monads. 13.1 Functor and monad classes class Functor f where The Functor class is used for types that expression. instance Monad [] instance Monad IO instance Monad Maybe class Monad m => MonadPlus m where Monads that also support choice and failure. Methods mzero :: m a the identity of mplus. It should also0 码力 | 329 页 | 1.43 MB | 1 年前3Back To Basics: Functional Programming in C++
the value using another I/O action We can write join that flattens nested io_action Those are all monads. Jonathan Müller — @foonathan Back to Basics: Functional Programming in C++ CppCon 2024-09-19 78Monad operations .transform .and_then .join together with some way to build a monad from a value. Monads enable composition. Jonathan Müller — @foonathan Back to Basics: Functional Programming in C++ CppCon0 码力 | 178 页 | 918.67 KB | 5 月前3The Idris Tutorial Version 0.9.18
Applicatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.4 Monads and do-notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 f => Applicative (f : Type -> Type) where pure : a -> f a (<*>) : f (a -> b) -> f a -> f b 4.4 Monads and do-notation The Monad class allows us to encapsulate binding and computation, and is the basis0 码力 | 69 页 | 316.20 KB | 1 年前3
共 16 条
- 1
- 2