A talk in JSDC.tw 2014. I introduce the advantage and disadvantage to write JavaScript in functional style. It covers simple Functional Programming concepts, how JavaScript becomes more functional, and all the difficulties people may encounter.
A short talk on what makes Functional Programming - and especially Haskell - different.
We'll take a quick overview of Haskell's features and coding style, and then work through a short but complete example of using it for a Real World problem.
http://lanyrd.com/2011/geekup-liverpool-may/sdykh/
2017 02-07 - elastic & spark. building a search geo locatorAlberto Paro
Presentazione dell'evento EsInRome del 7 Febbraio 2017 - Integrazione Elasticsearch in architettura BigData e facilità di integrazione con Apache Spark.
This document provides a 3-sentence summary of the given document:
The document is a tutorial introduction to high-performance Haskell that covers topics like lazy evaluation, reasoning about space usage, benchmarking, profiling, and making Haskell code run faster. It explains concepts like laziness, thunks, and strictness and shows how to define tail-recursive functions, use foldl' for a strict left fold, and force evaluation of data constructor arguments to avoid space leaks. The goal is to help programmers optimize Haskell code and make efficient use of multiple processor cores.
This document is a Python script that modifies map elements, extents, and scales in an ArcGIS map document based on user-specified parameters. It changes the map name, location, and classification text displayed on the layout. It can also set the map extent to the bounds of a nearest city or specific MGRS grid specified by the user. The script supports setting the map scale to preset or custom values defined by the user.
Understanding Graph Databases with Neo4j and CypherRuhaim Izmeth
Inroduction of Grapgh database concepts, explained by comparing the widely popular relational databases and the the sql query language. Neo4j and cypher is used to describe how graph databases work in real life
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.
Beginning Haskell, Dive In, Its Not That Scary!priort
Haskell can get a bit of a reputation for being this lofty, academic, difficult to learn language. This talk aims to dispel this myth and offer an introduction to this beautiful and pragmatic language. From the point of view of someone who has been functional programming in Scala and Clojure for a while now, but who has, more recently been taking a dive into Haskell, this talk will give a basic introduction to Haskell. Hopefully it will encourage anyone who hasn't tried functional programming in Haskell to dive in too and give it a go.
The talk will be a whistle stop tour of some functional programming fundamentals in Haskell from basic data structures, logic constructs, functional transformations, recursion to some of the basics of Haskell's type system with data declarations and type classes.
Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...takeoutweight
I discuss Haste, which compiles Haskell code to Javascript to be run on the browser. I then cover Tagless Final Style, which is a technique for creating flexible and extensible DSLs.
This document discusses PostgreSQL indexes. It begins by explaining the difference between tables stored in heap files versus indexes. Indexes provide an entry point to locate table tuples faster than a sequential scan. The document then covers different index types like B-tree, hash, and BRIN indexes. It also discusses expression indexes, partial indexes, and creating indexes concurrently without locking tables.
ref:https://www.ggplot2-exts.org/ggtree.html
ggtree
https://bioconductor.org/packages/release/bioc/html/ggtree.html
gtree is designed for visualizing phylogenetic tree and different types of associated annotation data.
This document provides an overview of Template Haskell and how it can be used to generate Haskell code at compile time. It discusses:
1. A motivating example of using Template Haskell to generate functions like fst3 and fst4 in a generalized way.
2. How to write a Template Haskell splice using the Q monad and functions like newName.
3. How to evolve a simple splice like fst3 into a generalized version fstN.
4. How quasi-quotes can be used to embed Haskell expressions that will be parsed and converted into ASTs at compile time.
This document provides an overview of Python fundamentals including basic concepts like data types, operators, flow control, functions and classes. It begins with an introduction to Python versions and environments. The outline covers topics like Hello World, common types and operators for numeric, string and container data types. It also discusses flow control structures like if/else, while loops and for loops. Finally, it briefly mentions functions, classes, exceptions and file I/O.
This document provides an overview of functional programming using Underscore.js and Lo-Dash. It discusses key concepts of functional programming like pure functions, first class functions, and higher order functions. It then explains how Underscore.js and Lo-Dash support functional programming in JavaScript with functions like compose, map, reduce, filter, and utilities to work with functions as first class citizens. The document compares Underscore.js and Lo-Dash, noting Lo-Dash's better performance, larger feature set, and utilities like partial and result. It emphasizes applying functional concepts judiciously for benefits while avoiding rewriting all code to be purely functional.
The Ring programming language version 1.5.2 book - Part 45 of 181Mahmoud Samir Fayed
1. Initialize Allegro and load necessary addons like images.
2. Create a display and show a message box to initialize the window.
3. Draw shapes and bitmaps to the display and flip periodically to animate.
4. Set up event handling for input from keyboard, mouse, and timer to control animation.
5. Inside the game loop: handle input, update object positions, redraw, and flip display continuously.
JAVA 8 : Migration et enjeux stratégiques en entrepriseSOAT
La sortie de Java 8 est une véritable révolution dont l’enjeu dépasse de loin la simple évolution d’un langage et de ses APIs. Rdv sur notre chaîne Youtube pour revoir la conférence :
Après une version 7 peu convaincante, la version 8 replace Java au premier rang des langages objets actuels.
En parfaite adéquation avec les besoins des projets et les possibilités offertes par les environnements matériels actuels, cette nouvelle version apporte une modernisation du langage et de ses API, un suivi des performances des processeurs et des améliorations de la JVM.
Quels sont les nouveaux concepts introduits par Java 8 ? En quoi les expressions lambdas et l’API Stream représentent une avancée majeure de la plateforme ? Quelle stratégie adopter pour migrer vers Java 8 en toute sécurité et en diminuant au maximum sa dette technique ?
Lekcja Stylu - czy w Javie można jeszcze dostrzec piękno?
Przeglądając listy prezentacji na konferencjach związanych z Javą z ostatnich lat można dostrzec pewien wzorzec. Przedstawia się coraz to bardziej wyrafinowane zręby aplikacji, wskazówki integracyjne dla kolejnych JBusinessComponents oraz zręby aplikacji webowych, gdzie wypisanie "Hello World" zajmuje trzy linijki zamiast pięciu. Czyżby zapomniano już o samym języku Java? Czyżby wszyscy już przesiedli się na Scalę, Groovy lub JRuby?
Swoją prezentacją chcę wrócić do korzeni, do samego języka Java. Będę pokazywał dobre przykłady, jak należy programować, aby czytanie kodu było miłym doświadczeniem. Nie będzie jednak to wykład o wzorcach projektowych, ale o codzienności programisty, który właśnie po wypiciu porannej kawy i otwarciu edytora, pisze pierwszą tego dnia instrukcję warunkową.
Będzie to hołd książce "Implementation Patterns" Kenta Becka. W prezentacji zostaną przedstawione także ułatwiające życie biblioteki takie jak Google Guava, Google Guice oraz Mockito.
The document discusses the keyword "this" in JavaScript and how its context depends on how functions are called. It provides various ways to avoid using "this", such as binding functions, using closures to access outer variables, and defining objects without "this". Avoiding "this" can make code clearer but uses more memory, while using "this" carefully enables features like inheritance. The overall message is to understand how "this" works and avoid it when possible or bind it when needed.
The document discusses the history of object-oriented programming. It describes early computing projects like Project Whirlwind that used interactive computing. It then discusses Ivan Sutherland's 1963 PhD thesis called Sketchpad, which is considered a precursor to object-oriented programming. Sketchpad used the concept of objects and components to allow for interactive drawing with a light pen on a computer screen. The general functions developed in Sketchpad gave it the ability to operate on different types of entities, laying the foundations for object-oriented programming.
- JavaScript patterns like custom events, deferreds, and pub/sub can help manage asynchronous processes in the browser environment. Custom events allow defining and triggering custom events. Deferreds help manage callbacks and caching of asynchronous results. Pub/sub implements a publisher/subscriber pattern for loose coupling between modules. These patterns help modularize applications and decouple components.
Advanced Data Visualization in R- Somes Examples.Dr. Volkan OBAN
This document provides examples of using the geomorph package in R for advanced data visualization. It includes code snippets showing how to visualize geometric morphometric data using functions like plotspec() and plotRefToTarget(). It also includes an example of creating a customized violin plot function for comparing multiple groups and generating simulated data to plot.
Javascript Meetup in Charlottesville for CVjs.
http://www.meetup.com/Central-Virginia-Javascript-Enthusiasts-CVJSE/events/132911552/
MongoDB offers two native data processing tools: MapReduce and the Aggregation Framework. MongoDB’s built-in aggregation framework is a powerful tool for performing analytics and statistical analysis in real-time and generating pre-aggregated reports for dashboarding. In this session, we will demonstrate how to use the aggregation framework for different types of data processing including ad-hoc queries, pre-aggregated reports, and more. At the end of this talk, you should walk aways with a greater understanding of the built-in data processing options in MongoDB and how to use the aggregation framework in your next project.
My name is Neta Barkay , and I'm a data scientist at LivePerson.
I'd like to share with you a talk I presented at the Underscore Scala community on "Efficient MapReduce using Scalding".
In this talk I reviewed why Scalding fits big data analysis, how it enables writing quick and intuitive code with the full functionality vanilla MapReduce has, without compromising on efficient execution on the Hadoop cluster. In addition, I presented some examples of Scalding jobs which can be used to get you started, and talked about how you can use Scalding's ecosystem, which includes Cascading and the monoids from Algebird library.
Read more & Video: https://connect.liveperson.com/community/developers/blog/2014/02/25/scalding-reaching-efficient-mapreduce
Some Examples in R- [Data Visualization--R graphics]Dr. Volkan OBAN
This document provides examples of creating various types of charts and plots using the rCharts package in R. It includes examples of creating point, bar, pie, line, stacked area, multi-bar, box, tile and map charts from different datasets. The rCharts package allows interactive charts to be created that can be embedded within R Markdown or Shiny applications.
"Немного о функциональном программирование в JavaScript" Алексей КоваленкоFwdays
This document discusses functional programming concepts in JavaScript including imperative vs declarative programming, currying, composition, functors, and the Ramda library. It provides examples of implementing curried functions, function composition, and functors in JavaScript. Functors are discussed in the context of arrays and the Maybe datatype. The Ramda library is presented as an alternative to Underscore/Lodash that follows a more functional programming style with its use of currying and function composition.
ClickHouse Features for Advanced Users, by Aleksei MilovidovAltinity Ltd
This document summarizes key features for advanced users of ClickHouse, an open-source column-oriented database management system. It describes sample keys that can be defined in MergeTree tables to generate instant reports on large customer data. It also summarizes intermediate aggregation states, consistency modes, and tools for processing data without a server like clickhouse-local.
Let’s talk about Terraform. I adore Terraform, it is the only tool I want to orchestrate my cloud resources with. Except when it makes me stare at the screen murmuring: “WAT?!” 0_o
This document discusses refactoring Java code to Clojure using macros. It provides examples of refactoring Java code that uses method chaining to equivalent Clojure code using the threading macros (->> and -<>). It also discusses other Clojure features like type hints, the doto macro, and polyglot projects using Leiningen.
Groovy is a dynamic language for the Java Virtual Machine that aims to provide a concise, readable syntax with features like closures, metaprogramming and domain-specific language support. Some key features include dynamic typing, operator overloading, builders for generating XML/Swing code and the ability to extend any class or category of objects with additional methods. Groovy aims to be fully interoperable with Java while allowing more compact representations of common patterns.
This document discusses PostgreSQL indexes. It begins by explaining the difference between tables stored in heap files versus indexes. Indexes provide an entry point to locate table tuples faster than a sequential scan. The document then covers different index types like B-tree, hash, and BRIN indexes. It also discusses expression indexes, partial indexes, and creating indexes concurrently without locking tables.
ref:https://www.ggplot2-exts.org/ggtree.html
ggtree
https://bioconductor.org/packages/release/bioc/html/ggtree.html
gtree is designed for visualizing phylogenetic tree and different types of associated annotation data.
This document provides an overview of Template Haskell and how it can be used to generate Haskell code at compile time. It discusses:
1. A motivating example of using Template Haskell to generate functions like fst3 and fst4 in a generalized way.
2. How to write a Template Haskell splice using the Q monad and functions like newName.
3. How to evolve a simple splice like fst3 into a generalized version fstN.
4. How quasi-quotes can be used to embed Haskell expressions that will be parsed and converted into ASTs at compile time.
This document provides an overview of Python fundamentals including basic concepts like data types, operators, flow control, functions and classes. It begins with an introduction to Python versions and environments. The outline covers topics like Hello World, common types and operators for numeric, string and container data types. It also discusses flow control structures like if/else, while loops and for loops. Finally, it briefly mentions functions, classes, exceptions and file I/O.
This document provides an overview of functional programming using Underscore.js and Lo-Dash. It discusses key concepts of functional programming like pure functions, first class functions, and higher order functions. It then explains how Underscore.js and Lo-Dash support functional programming in JavaScript with functions like compose, map, reduce, filter, and utilities to work with functions as first class citizens. The document compares Underscore.js and Lo-Dash, noting Lo-Dash's better performance, larger feature set, and utilities like partial and result. It emphasizes applying functional concepts judiciously for benefits while avoiding rewriting all code to be purely functional.
The Ring programming language version 1.5.2 book - Part 45 of 181Mahmoud Samir Fayed
1. Initialize Allegro and load necessary addons like images.
2. Create a display and show a message box to initialize the window.
3. Draw shapes and bitmaps to the display and flip periodically to animate.
4. Set up event handling for input from keyboard, mouse, and timer to control animation.
5. Inside the game loop: handle input, update object positions, redraw, and flip display continuously.
JAVA 8 : Migration et enjeux stratégiques en entrepriseSOAT
La sortie de Java 8 est une véritable révolution dont l’enjeu dépasse de loin la simple évolution d’un langage et de ses APIs. Rdv sur notre chaîne Youtube pour revoir la conférence :
Après une version 7 peu convaincante, la version 8 replace Java au premier rang des langages objets actuels.
En parfaite adéquation avec les besoins des projets et les possibilités offertes par les environnements matériels actuels, cette nouvelle version apporte une modernisation du langage et de ses API, un suivi des performances des processeurs et des améliorations de la JVM.
Quels sont les nouveaux concepts introduits par Java 8 ? En quoi les expressions lambdas et l’API Stream représentent une avancée majeure de la plateforme ? Quelle stratégie adopter pour migrer vers Java 8 en toute sécurité et en diminuant au maximum sa dette technique ?
Lekcja Stylu - czy w Javie można jeszcze dostrzec piękno?
Przeglądając listy prezentacji na konferencjach związanych z Javą z ostatnich lat można dostrzec pewien wzorzec. Przedstawia się coraz to bardziej wyrafinowane zręby aplikacji, wskazówki integracyjne dla kolejnych JBusinessComponents oraz zręby aplikacji webowych, gdzie wypisanie "Hello World" zajmuje trzy linijki zamiast pięciu. Czyżby zapomniano już o samym języku Java? Czyżby wszyscy już przesiedli się na Scalę, Groovy lub JRuby?
Swoją prezentacją chcę wrócić do korzeni, do samego języka Java. Będę pokazywał dobre przykłady, jak należy programować, aby czytanie kodu było miłym doświadczeniem. Nie będzie jednak to wykład o wzorcach projektowych, ale o codzienności programisty, który właśnie po wypiciu porannej kawy i otwarciu edytora, pisze pierwszą tego dnia instrukcję warunkową.
Będzie to hołd książce "Implementation Patterns" Kenta Becka. W prezentacji zostaną przedstawione także ułatwiające życie biblioteki takie jak Google Guava, Google Guice oraz Mockito.
The document discusses the keyword "this" in JavaScript and how its context depends on how functions are called. It provides various ways to avoid using "this", such as binding functions, using closures to access outer variables, and defining objects without "this". Avoiding "this" can make code clearer but uses more memory, while using "this" carefully enables features like inheritance. The overall message is to understand how "this" works and avoid it when possible or bind it when needed.
The document discusses the history of object-oriented programming. It describes early computing projects like Project Whirlwind that used interactive computing. It then discusses Ivan Sutherland's 1963 PhD thesis called Sketchpad, which is considered a precursor to object-oriented programming. Sketchpad used the concept of objects and components to allow for interactive drawing with a light pen on a computer screen. The general functions developed in Sketchpad gave it the ability to operate on different types of entities, laying the foundations for object-oriented programming.
- JavaScript patterns like custom events, deferreds, and pub/sub can help manage asynchronous processes in the browser environment. Custom events allow defining and triggering custom events. Deferreds help manage callbacks and caching of asynchronous results. Pub/sub implements a publisher/subscriber pattern for loose coupling between modules. These patterns help modularize applications and decouple components.
Advanced Data Visualization in R- Somes Examples.Dr. Volkan OBAN
This document provides examples of using the geomorph package in R for advanced data visualization. It includes code snippets showing how to visualize geometric morphometric data using functions like plotspec() and plotRefToTarget(). It also includes an example of creating a customized violin plot function for comparing multiple groups and generating simulated data to plot.
Javascript Meetup in Charlottesville for CVjs.
http://www.meetup.com/Central-Virginia-Javascript-Enthusiasts-CVJSE/events/132911552/
MongoDB offers two native data processing tools: MapReduce and the Aggregation Framework. MongoDB’s built-in aggregation framework is a powerful tool for performing analytics and statistical analysis in real-time and generating pre-aggregated reports for dashboarding. In this session, we will demonstrate how to use the aggregation framework for different types of data processing including ad-hoc queries, pre-aggregated reports, and more. At the end of this talk, you should walk aways with a greater understanding of the built-in data processing options in MongoDB and how to use the aggregation framework in your next project.
My name is Neta Barkay , and I'm a data scientist at LivePerson.
I'd like to share with you a talk I presented at the Underscore Scala community on "Efficient MapReduce using Scalding".
In this talk I reviewed why Scalding fits big data analysis, how it enables writing quick and intuitive code with the full functionality vanilla MapReduce has, without compromising on efficient execution on the Hadoop cluster. In addition, I presented some examples of Scalding jobs which can be used to get you started, and talked about how you can use Scalding's ecosystem, which includes Cascading and the monoids from Algebird library.
Read more & Video: https://connect.liveperson.com/community/developers/blog/2014/02/25/scalding-reaching-efficient-mapreduce
Some Examples in R- [Data Visualization--R graphics]Dr. Volkan OBAN
This document provides examples of creating various types of charts and plots using the rCharts package in R. It includes examples of creating point, bar, pie, line, stacked area, multi-bar, box, tile and map charts from different datasets. The rCharts package allows interactive charts to be created that can be embedded within R Markdown or Shiny applications.
"Немного о функциональном программирование в JavaScript" Алексей КоваленкоFwdays
This document discusses functional programming concepts in JavaScript including imperative vs declarative programming, currying, composition, functors, and the Ramda library. It provides examples of implementing curried functions, function composition, and functors in JavaScript. Functors are discussed in the context of arrays and the Maybe datatype. The Ramda library is presented as an alternative to Underscore/Lodash that follows a more functional programming style with its use of currying and function composition.
ClickHouse Features for Advanced Users, by Aleksei MilovidovAltinity Ltd
This document summarizes key features for advanced users of ClickHouse, an open-source column-oriented database management system. It describes sample keys that can be defined in MergeTree tables to generate instant reports on large customer data. It also summarizes intermediate aggregation states, consistency modes, and tools for processing data without a server like clickhouse-local.
Let’s talk about Terraform. I adore Terraform, it is the only tool I want to orchestrate my cloud resources with. Except when it makes me stare at the screen murmuring: “WAT?!” 0_o
This document discusses refactoring Java code to Clojure using macros. It provides examples of refactoring Java code that uses method chaining to equivalent Clojure code using the threading macros (->> and -<>). It also discusses other Clojure features like type hints, the doto macro, and polyglot projects using Leiningen.
Groovy is a dynamic language for the Java Virtual Machine that aims to provide a concise, readable syntax with features like closures, metaprogramming and domain-specific language support. Some key features include dynamic typing, operator overloading, builders for generating XML/Swing code and the ability to extend any class or category of objects with additional methods. Groovy aims to be fully interoperable with Java while allowing more compact representations of common patterns.
This document discusses JavaScript and Haskell. It provides code examples comparing features of the two languages such as functions, recursion, lists, and higher-order functions. It also discusses Haskell concepts like lazy evaluation, monads, and type inference.
Столпы функционального программирования для адептов ООП, Николай МозговойSigma Software
This document provides an overview of functional programming concepts for object-oriented programmers. It discusses the fundamentals of FP including immutability, purity, first-class and higher-order functions, closures, and recursion. It provides examples of these concepts in languages like Lisp, F#, C#, and JavaScript. The document also compares OO and FP concepts and discusses derived FP concepts like partial application, lazy evaluation, and pattern matching.
This document compares and contrasts the programming languages Perl and Haskell. It discusses their differences in terms of being dynamic vs static, imperative vs functional, and weakly vs strongly typed. It provides examples of how similar tasks like mapping, doubling values, and finding lengths can be accomplished in both languages. It also explores some of the challenges that arise from Perl's scalar/list context and Haskell's use of monads and strong static types. Overall, the document examines the different philosophies behind Perl and Haskell while also showing how influences have flowed between the communities over time.
These are the outline slides that I used for the Pune Clojure Course.
The slides may not be much useful standalone, but I have uploaded them for reference.
Part presentation, part debate about the future of the language while touching base on the current state of the industry with respect to ES6/ES2015, and the possibilities of using it today in web applications and frameworks, the different options, and the things to keep in mind. Additionally, we will do a walk-through on the new features included in ES7/ES2016 draft, and those that are being discussed for ES8/ES2017.
Scalding - the not-so-basics @ ScalaDays 2014Konrad Malawski
This document discusses various big data technologies and how they relate to each other. It explains that Summingbird is built on top of Scalding and Storm, which are built on top of Cascading, which is built on top of Hadoop. It also discusses how Spark relates and compares to these other technologies.
The document discusses using functional programming techniques in Perl to efficiently calculate tree hashes of large files uploaded in chunks to cloud storage services. It presents a tree_fold keyword and implementation that allows recursively reducing a list of values using a block in a tail-call optimized manner to avoid stack overflows. This approach is shown to provide concise, efficient and elegant functional code for calculating tree hashes in both Perl 5 and Perl 6.
This is the slide for what I shared in JS Group meetup, 2014, Taiwan. It covers what JavaScript could do for making the program more "functional", the benefits, price and the limitation.
Monads and Monoids: from daily java to Big Data analytics in Scala
Finally, after two decades of evolution, Java 8 made a step towards functional programming. What can Java learn from other mature functional languages? How to leverage obscure mathematical abstractions such as Monad or Monoid in practice? Usually people find it scary and difficult to understand. Oleksiy will explain these concepts in simple words to give a feeling of powerful tool applicable in many domains, from daily Java and Scala routines to Big Data analytics with Storm or Hadoop.
This document provides an introduction to functional programming in JavaScript. It discusses key functional programming concepts like pure functions, immutable data, and referential transparency. It explains how JavaScript supports functional programming with features like anonymous functions, closures, and higher-order functions. The document also demonstrates functional programming tools like filter, map, reduce, currying, and function composition. It provides examples of how to write pure functions and avoid side effects. Finally, it encourages readers to start applying these concepts like writing pure functions, using currying, and embracing functional composition.
This document discusses using Groovy on Android. It provides an overview of Groovy including its syntax features like closures, GStrings, maps/lists, and operators. It also discusses Groovy's advantages like simplifying testing and seamlessly integrating with Java. The document demonstrates various Groovy features and gives examples of working with I/O. It briefly mentions AST transformations in Groovy and the SwissKnife library for injecting views and handling threading. The document concludes with recommending some Groovy literature and thanking the audience.
This document discusses functional programming concepts in Perl. It begins with a brief history of Perl and how functions like sort, grep, and map evolved over time and took on a more functional style. It then demonstrates how to write functional-style code in Perl using lexical scoping, first-class functions, and function composition. Examples include writing dice rolling and dice tower generation functions in a functional way. The document notes some limitations of functional programming in Perl, like lack of purity and difficulty making some concepts simple that are in functional languages, but suggests improvements coming in Perl 6 like static typing and better support for functional patterns.
This document provides an overview of basic usage of the Apache Spark framework for data analysis. It describes what Spark is, how to install it, and how to use it from Scala, Python, and R. It also explains the key concepts of RDDs (Resilient Distributed Datasets), transformations, and actions. Transformations like filter, map, join, and reduce return new RDDs, while actions like collect, count, and first return results to the driver program. The document provides examples of common transformations and actions in Spark.
Using Regular Expressions and Staying SaneCarl Brown
Presentation I gave to the local http://www.cocoacoder.org/ meeting on using Regular Expression in Cocoa code (although much of it applies to other languages as well).
Fancy is a JavaScript library that combines Underscore functions with functional programming concepts to allow for writing functional code in a more readable way. It constructs FancyArrays and FancyObjects from normal arrays and objects that allow chaining of Underscore functions. This functional approach to problems like evaluating poker hands avoids side effects, combines functions, and solves problems conceptually rather than using loops. While it may not implement all aspects of functional programming, Fancy emphasizes the use of functions and avoids state to make code more reusable, abstracted, and easier to write and extend.
This document provides an overview of ES6 (ECMAScript 2015) features including: let, const and var; template strings; arrow functions; destructuring; default parameters; rest and spread syntax; iterators; classes; modules; maps, sets, weakmaps and weaksets; promises; and more. It explains each feature and provides code examples to demonstrate usage and differences from ES5. Browser compatibility notes are also included to advise on safe usage of new features across environments.
Rust + python: lessons learnt from building a toy filesystemChengHui Weng
In this slides I listed what I have learnt when I was working on my toy FUSE based file system in Rust for Python. By using PyO3, to bind Rust with Python becomes really easy, but the unavoidable type conversions affect the whole Rust code design and efficiency.
This is as a lighting talk for WebHack#16 meet up: https://webhack.connpass.com/event/99735/
The document discusses the JavaScript engine architecture in SpiderMonkey. It describes the roles of the interpreter, baseline just-in-time (JIT) compiler, and IonMonkey JIT compiler. The interpreter parses JavaScript code into bytecode, which is then run by interpreting and invoking C++ functions. The baseline JIT compiles hot bytecode into optimized assembly code. IonMonkey performs a full optimization of JavaScript functions by compiling them into a graph representation. Bailouts can occur if type assumptions made during JIT compilation turn out to be incorrect.
In this WebHack talk I shared my experience about microservices, Docker, Kubernetes and Kong, an API gateway by Mashape. Since they are based on a real working system, this slides is majorly for how to build the whole thing up, not about detailed internal implementation. Although I included some details and reference in order to make it more comprehensive.
In the recent Functional Thursday meetup, I gave this talk about SpiderMonkey: Mozilla's JavaScript engine used in Firefox. The content covers the architecture and some interesting internal implementations.
As a guest speaker in NCU, I gave this second talk about some more advanced practices of JavaScript programming. It summarised our experience learned from developing Mozilla/Gaia project, including the way to deal with asynchronous code flow with the event-driven model.
As a guest speaker in NCU, I gave a talk about some best practices of JavaScript programming to college students. It covers basic JavaScript elements and some common pitfalls while dealing with asynchronous programming.
In this talk I introduced Yampa, the AFRP framework in Haskell, and the Quake-like game made by it. The content convers the basic of Functional Reactive Programming, Haskell Arrow, Yampa itself, time-space leak, etc.
Introduction to Basic Haskell Components (In Chinese)ChengHui Weng
In 2012, we had the first Chinese functional meetup about general functional programming techniques in Taipei. I gave this talk to introduce several classes in the famous Typeclassesopedia article.
⭐️ Bitcoin - Mining Race ⭐️ The fastest-growing Bitcoin movement ⭐️ english
⭐️ Referral link - https://miningrace.com/wallet/invite-activate/edA6xDgWMVLBAfCClWJy ⭐️
Invitation code - edA6xDgWMVLBAfCClWJy
Mining Race - The fastest-growing Bitcoin movement
Participate in the ultimate Bitcoin community challenge. Conquer the top in the Mining Race.
Cryptocurrencies are all about the community. And what better way to support the BTC community than with a community-based mining program?
By participating in the Mining Race, you not only support the Bitcoin blockchain, but also receive additional rewards for being a member of the Mining Race community!
Ready for the Bitcoin Mining Race Challenge?
⭐️ Referral link - https://miningrace.com/wallet/invite-activate/edA6xDgWMVLBAfCClWJy ⭐️
Invitation code - edA6xDgWMVLBAfCClWJy
stackconf 2025 | Abstract It: The Higher, The Faster! by Engin Diri.pdfNETWAYS
A recent announcement from AWS caught my attention and got me genuinely excited—it was about KRO, or Kube Resource Orchestrator. But what intrigued me wasn’t just the tool itself; it was the idea behind it: creating an abstraction layer by leveraging the Kubernetes API. While this concept isn’t entirely new—tools like Kratix and Crossplane have been doing this for a while—the possibilities it opens up are worth exploring. In this lightning talk, I’ll walk you through this approach to building abstractions with Kubernetes and the broader concept of the Platform API. In 5 minutes, you’ll gain new ideas and practical perspectives to take your platform engineering journey to the next level.
stackconf 2025 | Detect & Respond to Threats in Kubernetes with Falco by Luca...NETWAYS
Kubernetes has become the backbone of modern cloud-native applications, but its dynamic nature presents unique security challenges. In this hands-on lab session, we’ll dive deep into securing Kubernetes environments with Falco, the open-source standard for runtime threat detection. This workshop will guide attendees through the end-to-end process of setting up Kubernetes, installing Falco, and building custom detection rules to address evolving Linux threats. You’ll learn how to craft rules tailored to your specific environment, enabling more precise detection of anomalous behaviour and potential threats. Additionally, we’ll introduce Falco Talon, a powerful response engine that integrates seamlessly with Falco to mitigate threats in Kubernetes and the cloud. See how Falco Talon automates threat containment and response, minimising downtime and enhancing your cloud security posture. Whether you’re a Kubernetes beginner or a seasoned user, this session will equip you with practical tools and techniques to detect and respond to threats effectively in your cloud-native environments. I want to keep this session interactive, so ask me anything!
Microsoft Azure Data Fundamentals (DP-900) Exam Dumps & Questions 2025.pdfMinniePfeiffer
• For a full set of 640 questions. Go to
https://skillcertpro.com/product/microsoft-azure-data-fundamentals-dp-900-exam-questions/
• SkillCertPro offers detailed explanations to each question which helps to understand the concepts better.
• It is recommended to score above 85% in SkillCertPro exams before attempting a real exam.
• SkillCertPro updates exam questions every 2 weeks.
• You will get life time access and life time free updates
• SkillCertPro assures 100% pass guarantee in first attempt.
stackconf 2025 | The Power of Small Habits in Agile Teams by Maroš Kutschy.pdfNETWAYS
When I was reading books like ‘Atomic Habits’ by James Clear and ‘The Power of Habit’ by Charles Duhigg, I was thinking about how these principles related to habits could be applied in software development and testing in agile teams.
I am fascinated by connecting the IT world with the non-IT world, and I think that the small habits topic is a great example of such a connection.
In my talk I will share my ideas on how we can apply these principles in both individual and team areas.
I will provide examples related to the daily work of developers, testers, scrum masters, and DevOps/TechOps engineers, along with examples for whole teams.
I will share my experience of applying principles of small habits to myself at work and in personal life. I will tell the stories and lessons learnt about what worked and what didn’t.
The more time I spend with this topic, the more I am convinced that small habits have great power to increase the performance of agile teams.
This session will be unique, because it will be packed with many practical tips which can be applied right after the session in daily life of the attendees.
Main takeaways (lessons learnt):
– Why small habits are so powerful
– How to apply small habits principles for individual developers, testers, scrum masters, and DevOps/TechOps engineers
– How to apply small habit principles in agile teams delivering software
⭐️ Bitcoin - Mining Race ⭐️ The Fastest Driven Bitcoin Movement ⭐️ english
⭐️ Referral link - https://miningrace.com/wallet/invite-activate/edA6xDgWMVLBAfCClWJy ⭐️
Invite code - edA6xDgWMVLBAfCClWJy
Mining Race - The fastest growing Bitcoin movement
Join the Ultimate Bitcoin Community Challenge. Race to the Top in Mining Race.
Cryptocurrencies are all about the community. And what better way to fully embrace the BTC community than a community-based mining program?
By participating in the Mining Race, you will not only contribute to the support of the Bitcoin blockchain but also earn more rewards for being a part of the Mining Race community!
Ready to join the Bitcoin Mining Race Challenge?
⭐️ Referral link - https://miningrace.com/wallet/invite-activate/edA6xDgWMVLBAfCClWJy ⭐️
Invite code - edA6xDgWMVLBAfCClWJy
ICSE 2025 Keynote: Software Sustainability and its Engineering: How far have ...patricialago3459
Thanks to its digital transformation, society depends on software. This is expected to bring important benefits but at the same time is accompanied by worrisome constraints. The societal role of software and its engineering is not new. Nor is their need to be sustainable. But what does it mean, really? And how far have we come with our research?
This talk wants to trigger reflection on the research being done, its impact and its true contribution to the complex and urgent problems posed by both society and our planet.
14. This talk is about
Concepts
Features
Trade-Off
Libraries
Frameworks
15. This talk is NOT about
20 mins to write a blog (you had enough of it, right?)
42 Tools for your toolbox (although I do recommend to use some libraries)
Hammer on your hand and everything looks like a nail
Brainwash believe whatever you want; so, hacking, not blaming
Lambda Calculus ...wait, or should we put it in slides?
22. It would bring you
Re-thinking about programming
Patterns efficiently make your works done
Fun -citons
23. Features of Functional Programmings
First-class function | Closure
High-order functions | Function composition
Purity | Managed side-effects | Laziness
Recursion | Tail-recursion optimization | (Type)
24. Features of Functional Programmings
First-class function | Closure
High-order functions | Function composition
Purity | Managed side-effects | Laziness
Recursion | Tail-recursion optimization | (Type)
JavaScript Ready
Need some hard works
Impossible if runtime
doesn't support it (well)
Discuss it later...
26. function() {}
is everything
Or () => { } if you're
a lucky bastard
Use Firefox to embrace () => 'the power of ES6!'
(Fat Arrow Functions)
27. 65535 -- Number (*yes, it's a function)
65535 + 1 -- Number → Number → Number
[1] -- Array Number
[1].push(2) -- Array Number → Number →
Array Number
[1, 2, 3].length -- Array Number → Number
[1, 2, 3].map((x) => `${ x }`) -- Array Number → (Number → String)
→ Array String
Use FirefoxNightly to embrace `the ${power} of ES6!`
(Quasi-Literals)
28. About the signature
Array Number → (Number → String) → Array String
[a] → (a → b) → [b]
"return value"function as argumentargument
a, b: type variables
29. var arr = [1, 2, 3]
arr.push(4)
But what about...
30. var arr = [1, 2, 3]
arr.push(4)
But what about...
=== return a completely new Array: arr → arr'
=== Array Number → Number →
Array Number
32. Immutable Data Structure
But in JavaScript we can 'pretend' we have it
when we're playing with FP. Would discuss it later
33. Immutable Data Structure
But in JavaScript we can 'pretend' we have it
when we're playing with FP. Would discuss it later
Facebook has an 'immutable-js' library
https://github.com/facebook/immutable-js
35. 65535 -- Number (*yes, it's a function)
65535 + 1 -- Number → Number
[1] -- Array Number
[1].push(2) -- Array Number → Number →
Array Number
[1, 2, 3].length -- Array Number → Number
[1, 2, 3].map((x) => `${ x }`) -- Array Number → (Number → String)
→
Array String
So now we have the Transformation
42. High-Order Functions is useful
map:: [a] → (a → b) → [b]
reduce:: [a] → (a → b → b) → [a] → b
43. High-Order Functions is useful
map:: [a] → (a → b) → [b]
reduce:: [a] → (a → b → b) → [a] → b
-- Note: these are *NOT* correct signatures in Haskell
-- but in JavaScript, we can treat [1,2,3].map as map::[a]...
-- which makes the code matches the type better
48. for (var r = 0; r < records.length; r += 1) {
var record = records[r];
var typeStr = NfcUtils.toUTF8(record.type);
if (NfcUtils.equalArrays(record.type, NDEF.RTD_TEXT)) {
poster.text = poster.text || {};
var textData = NDEF.payload.decodeText(record.payload);
if (poster.text[textData.language]) {
// According to NFCForum-SmartPoster_RTD_1.0 3.3.2,
// there MUST NOT be two or more records with
// the same language identifier.
return null;
// to be continue...
51. return records.reduce((poster, record) => {
var typeStr = NfcUtils.toUTF8(record.type);
if (NfcUtils.equalArrays(record.type, NDEF.RTD_TEXT)) {
poster.text = poster.text || {};
var textData = NDEF.payload.decodeText(record.payload);
if (poster.text[textData.language]) {
// According to NFCForum-SmartPoster_RTD_1.0 3.3.2,
// there MUST NOT be two or more records with
// the same language identifier.
return null;
// to be continue...
52. return records.reduce((poster, record) => {
var typeStr = NfcUtils.toUTF8(record.type);
if (NfcUtils.equalArrays(record.type, NDEF.RTD_TEXT)) {
poster.text = poster.text || {};
var textData = NDEF.payload.decodeText(record.payload);
if (poster.text[textData.language]) {
// According to NFCForum-SmartPoster_RTD_1.0 3.3.2,
// there MUST NOT be two or more records with
// the same language identifier.
return null;
// to be continue...
A real case in Gaia project: Bug 1039245
53. People know what are you doing when
they saw the 'map' and 'reduce'
54. People know what are you doing when
they saw the 'map' and 'reduce'
If there is no or only few side-effects
55. It can be more powerful if you play
with the type
63. forEach:: [a] → (a → SideEffect; will discuss it later)
filter:: [a] → (a → Bool) → [a] * the type is similar with map
groupBy:: [a] → (a → a → Bool) → [[a]] * lo-dash has it
zipWith: [a] →[b] → (a → b → c) → [c] * worth to implement
64. forEach:: [a] → (a → SideEffect; will discuss it later)
filter:: [a] → (a → Bool) → [a] * the type is similar with map
groupBy:: [a] → (a → a → Bool) → [[a]] * lo-dash has it
zipWith: [a] →[b] → (a → b → c) → [c] * worth to implement
Recommends to use lo-dash library to acquire these
functions
66. var map = (xs, fn) => {
return xs.reduce((acc, x) => {
return acc.concat([ fn(x) ]);
}, []); };
Recommends to use and get understand the 'transducer.js'
81. Safety if small functions are safe, the larger one is safe, too
Reusability no need to create new functions
Flexibility compose anything you want at anytime
Composition is good for you
90. [a] → (a → b) → [b]
['1','2','3'].map( $(not, odd, read) )
91. m a → (a → b) → m b
['1','2','3'].map( $(not, odd, read) )
92. m a → (a → b) → m b
IO a → (a → b) → IO b
getString.map( $(not, odd, read) )
IO String
93. m a → (a → b) → m b
IO a → (a → b) → IO b
[] a → (a → b) → [] b
['1','2','3'].map( $(not, odd, read) )
[ ] Number
94. m a → (a → b) → m b
IO a → (a → b) → IO b
[] a → (a → b) → [] b
HTTP a → (a → b) → HTTP b
HTTPServer.map( $(not, odd, read) )
HTTP Request
95. m a → (a → b) → m b
IO a → (a → b) → IO b
[] a → (a → b) → [] b
HTTP a → (a → b) → HTTP b
Maybe a → (a → b) → Maybe b
maybeRead.map( $(not, odd, read) )
Maybe a
96. m a → (a → b) → m b
IO a → (a → b) → IO b
[] a → (a → b) → [] b
HTTP a → (a → b) → HTTP b
Maybe a → (a → b) → Maybe b
Now we have a same map & function
for the different contexts
97. m a → (a → b) → m b
IO a → (a → b) → IO b
[] a → (a → b) → [] b
HTTP a → (a → b) → HTTP b
Maybe a → (a → b) → Maybe b
Now we have a same map & function
for the different contexts
In fact this general map called 'fmap'
98. List apply the function to every element ([1,2,3])
HTTP receive request and response with the handled content
Maybe if previous one is Nothing, do not apply the function
Same fmap; different meaning
99. The fmap is a common interface
that all contexts are agreed with
142. (>>=):: m a → ( a → m b ) → m b
a → m bm a
>>=m a → a a → b; b → m b
unwrap wrap
143. Allow inject ( a → m b ) means allow
we control the way to wrap the value
144. HTTPServer
>>= (req -> login)
>>= (authReq -> case (doAuth authReq) of
True -> content
False -> authError))
145. HTTPServer
>>= (req -> login)
>>= (authReq -> case (doAuth authReq) of
True -> content
False -> authError))
the 'bind' function, infix
HTTP::403
HTTP::200
146. let content response = HTTP200 response
let authError response = HTTP403 response
(authReq -> case (doAuth authReq) of
True -> content
False -> authError)
( a → m b )
149. HTTPServer
>>= (req -> login)
>>= (authReq -> case (doAuth authReq) of
True -> content
False -> authError))
The bound function stil don't need know
how to open IO, networking, etc.
(a → m b)
150. We still keep the same interface,
different implementations feature
167. DOM
Create notification
Change container's style
UI
Append notification
Scroll container to top
Gesture
Detect gesture on notification
Sound
Play sound
Asynchronous
Manage asynchronous operations
Conditional Statements
If...else to do or not to do things
I/O
Get/write data and control device
...
Functor
Monad
Monad Transformer
High-order Function
Partial Application
Curry
...
178. HTTPServer
>>= (req -> login)
>>= (authReq -> case (doAuth authReq) of
True -> content
False -> authError))
Can only access the value when you're in the context
179. HTTPServer
>>= (req -> login)
>>= (authReq -> case (doAuth authReq) of
True -> content
False -> authError))
let HTTPValue =
doSomething HTTPValue ...
No way to do that!
extract
181. Promise(() => {...})
.then((a) => {...})
.then((b) => {...})
.then((c) => {...})
.then((d) => {...}).extract();
var promisedValue =
No way to do that!
doSomething(promisedValue); ...
182. In fact what we could learn from
Monad is not only the type & rules
183. But the idea to control different
computations in different Contexts
184. Promise(() => {...})
.then((a) => {...})
.then((b) => {...})
.then((c) => {...})
.then((d) => {...});
Context: Ensure the following
step executes only after the
previous one get done.
191. threeCoins = do
a <- randomSt
b <- randomSt
c <- randomSt
return (a,b,c)
main = do
a <- ask "Name?"
b <- ask "Age?"
return ()
IO
add mx my = do
x <- mx
y <- my
return (x + y)
MaybeState
192. threeCoins = do
a <- randomSt
b <- randomSt
c <- randomSt
return (a,b,c)
main = do
a <- ask "Name?"
b <- ask "Age?"
return ()
IO
add mx my = do
x <- mx
y <- my
return (x + y)
MaybeState
the 'do' notification
196. Lazy vs eager: sometimes it's reasonable to be lazy
Flow control for asynchronous operations is important
Type in some critical places we still need the information
Laws is it possible to follow the Monad Laws?
Requirements to get closer with real Monads
197. It's easy to make our 'Monad'
lazy with some type supporting
198. var action = (new Maybe()).Just(3)
.then((v) => {
return (new Maybe()).Just(v+99); })
.then((v) => {
return (new Maybe()).Just(v-12); })
.then((v) => {
return (new Maybe()).Nothing(); })
.then((v) => {
return (new Maybe()).Just(v+12); })
// Execute it with `action.done()`.
action = (Just 3)
>>= v -> return (v + 99)
>>= v -> return (v - 12)
>>= v -> Nothing
>>= v -> return (v + 12)
https://github.com/snowmantw/
warmfuzzything.js/blob/master/maybe.js
199. var action = (new Maybe()).Just(3)
.then((v) => {
return (new Maybe()).Just(v+99); })
.then((v) => {
return (new Maybe()).Just(v-12); })
.then((v) => {
return (new Maybe()).Nothing(); })
.then((v) => {
return (new Maybe()).Just(v+12); })
// Execute it with `action.done()`.
action = (Just 3)
>>= v -> return (v + 99)
>>= v -> return (v - 12)
>>= v -> Nothing
>>= v -> return (v + 12)
https://github.com/snowmantw/
warmfuzzything.js/blob/master/maybe.js
...?
200. But things become crazy when the
'Monad' need to mix with Promise
(to support async operations natively)
201. action = (Just 3)
>>= v -> return (v + 99)
>>= v -> return (v - 12)
>>= v -> Nothing
>>= v -> return (v + 12)
https://github.com/snowmantw/
warmfuzzything.js/blob/master/promise_maybe.js
var action = (new PromiseMaybe()).Just(3)
.then((mSelf, v) => {
mSelf.returns((new PromiseMaybe).Just(v+99)); })
.then((mSelf, v) => {
setTimeout(function() { // Only for test. Meaningless.
mSelf.returns((new PromiseMaybe).Just(v-12));
}, 3000); })
.then((mSelf, v) => {
mSelf.returns((new PromiseMaybe).Nothing()); })
.then((mSelf, v) => {
mSelf.returns((new PromiseMaybe).Just(v+12)); });
202. action = (Just 3)
>>= v -> return (v + 99)
>>= v -> return (v - 12)
>>= v -> Nothing
>>= v -> return (v + 12)
https://github.com/snowmantw/
warmfuzzything.js/blob/master/promise_maybe.js
var action = (new PromiseMaybe()).Just(3)
.then((mSelf, v) => {
mSelf.returns((new PromiseMaybe).Just(v+99)); })
.then((mSelf, v) => {
setTimeout(function() { // Only for test. Meaningless.
mSelf.returns((new PromiseMaybe).Just(v-12));
}, 3000); })
.then((mSelf, v) => {
mSelf.returns((new PromiseMaybe).Nothing()); })
.then((mSelf, v) => {
mSelf.returns((new PromiseMaybe).Just(v+12)); });
203. action = (Just 3)
>>= v -> return (v + 99)
>>= v -> return (v - 12)
>>= v -> Nothing
>>= v -> return (v + 12)
https://github.com/snowmantw/
warmfuzzything.js/blob/master/promise_maybe.js
var action = (new PromiseMaybe()).Just(3)
.then((mSelf, v) => {
mSelf.returns((new PromiseMaybe).Just(v+99)); })
.then((mSelf, v) => {
setTimeout(function() { // Only for test. Meaningless.
mSelf.returns((new PromiseMaybe).Just(v-12));
}, 3000); })
.then((mSelf, v) => {
mSelf.returns((new PromiseMaybe).Nothing()); })
.then((mSelf, v) => {
mSelf.returns((new PromiseMaybe).Just(v+12)); });
It can be better, but the real
problem is it's implementation
is very tricky
205. But the most important things is
it works!
When I see a bird that walks like a Monad and swims
like a Monad and quacks like a Monad, I call that bird a Monad
206. But the most important things is
it works!
(although it doesn't follow the laws)
216. The missing part: how to stockpile different Contexts?
List
Request
List
Response
HTTP HTTP
( Request →Response)
217. The missing part: how to stockpile different Contexts?
List
Request
List
Response
HTTP HTTP
( Request →Response)
(See Appendix. Yes, we have a 200+ slides...)
226. Behavior trigger event
Data changed
View redraw
Let's think about what is an GUI program...
Can be done purely, while
IO is relatively simple than drawing
Lots of side-effects and
trolling data anytime
237. It's great because we can build a full
Functional Programming stack on it
239. It's great because we can build a full
Functional Programming stack on it
with Function Composition, Monad, Partial Application, Curry,
Monad Transformer, and other useful features in JavaScript
259. - lo-dash is your friend
- transducer in JavaScript is a good way to understand
reducing deeply
- immutable-js make your code purer
- React & Flux bring you a whole new FRP world
260. - jQuery is a Monad (no, not really, see the comments)
- Learn You a Haskell a good way to learn about Monad
- Typeclassopedia classical article about Typeclasses
- Foldr Foldl Foldl' detailed article about reducing
- CSP and transducers about Transducer in JavaScript
267. a -> m n b
CSE230 Wi14 - Monad Transformers
When you have many Monads
268. When you have many Monads
HTTP
Request
HTTP
Response
Logger Logger
( Request →Response)
269. When you have many Monads
HTTP
Request
HTTP
Response
Logger Logger
( Request →Response)
We want to process HTTP as usual
Meanwhile we want every request-response
been logged
270. When you have many Monads
HTTP
Request
HTTP
Response
Database Database
( Request →Response)
We want to process HTTP as usual
Meanwhile we may perform some
database R/W at the same time
271. When you have many Monads
HTTP
Request
HTTP
Response
Error Error
( Request →Response)
We want to process HTTP as usual
Meanwhile we want to capture every
step's error and handle it
274. HTTP
Logger m
The transformer only know the inner one
is the target Monad it can handle with
ex: (MaybeT → Maybe, HTTPT → HTTP)
Request
HTTPT (Transformer)
>>=
How Monad Transformer Works
275. HTTP
Logger m
The transformer only know the inner one
is the target Monad it can handle with
ex: (MaybeT → Maybe, HTTPT → HTTP)
Request
HTTPT ( "T"ransformer ) would not
care what the outer monad is
HTTPT (Transformer)
>>=
How Monad Transformer Works
276. HTTP
Logger m#bind
First transformer would call the outer
one's bind function to apply the rule on
the inner monadic value, and dig into the
second layer (inner monad)Request
apply m#bind on the
HTTP monadic value
HTTPT doesn't know
what the 'm' is
How Monad Transformer Works
277. HTTP
Logger m#bind
First transformer would call the outer
one's bind function to apply the rule on
the inner monadic value
Request
apply m#bind on the
HTTP monadic value
HTTPT doesn't know
what the 'm' is
How Monad Transformer Works
For this example, it means to perform the logging
278. HTTP
Logger m#bind
And then dig into the second layer
(inner monad)
Request
apply m#bind on the
HTTP monadic value
HTTPT doesn't know
what the 'm' is
How Monad Transformer Works
Now we're in the inner monad context
279. HTTP
Logger m
Then transformer apply the specific
Monad's binding rules on the inner
monadic value, including to call the
embedded function, just like what the
ordinary Monad does, but now we get
(m n b) rather than (m b)
Request Request
HTTP
Response
>>=
Logger m
http://en.wikibooks.
org/wiki/Haskell/Monad_transformers#A_simple_mon( a → m n b )
How Monad Transformer Works
280. Step by Step
Outer 'Bind' applied on the monadic value
m (n a) → m (n a)'
Inner 'Bind' applied on the monadic value
m (n a)' → m (n b)
Wrap It Back while it still doesn't know what the m is
m (n a)' → m (n b)
281. A not so successful try to implement
it in JavaScript
282. PromiseMaybeT
Now it can stockpile arbitrary PromiseMonad on one
PromiseMaybe monadic action
https://github.com/snowmantw/
warmfuzzything.js/blob/master/maybet.js
283. PromiseMaybeT
Now it can stockpile arbitrary PromiseMonad on one
PromiseMaybe monadic action
But since our basic 'Monad' is tricky, the transformer, is tricky, too
https://github.com/snowmantw/
warmfuzzything.js/blob/master/maybet.js