- Implicit function types are a powerful way to abstract over contexts by defining types that inject implicit values into a scope. This can fundamentally change the code we write by removing boilerplate around passing implicit parameters and configurations.
- Implicit parameters are a core Scala feature that allow removing repetition through parameterization while enabling use cases like proving theorems, establishing context, and implementing type classes. Their scope may be expanded through implicit function types.
- Future Scala versions aim to tighten rules for implicit conversions while introducing features like lazy implicits, multiple implicit parameter lists, and coherence to improve the discoverability and reasoning around implicits.
Effective Java, Third Edition - Keepin' it EffectiveC4Media
Video and slides synchronized, mp3 and slide download available at URL https://bit.ly/2uOURQH.
Joshua Bloch covers some highlights from the third edition of “Effective Java”, concentrating on streams and lambdas. The recently released edition of Effective Java contains one new chapter, fourteen new items, and numerous changes to existing items. Filmed at qconnewyork.com.
Joshua Bloch is the author of Effective Java and coauthor of Java Puzzlers and Java Concurrency in Practice. He was formerly the chief Java architect at Google, a distinguished engineer at Sun Microsystems. He led the design and implementation of numerous Java platform features, including the Java 5 language enhancements and the Java Collections Framework.
Simplifying AI and Machine Learning with Watson StudioDataWorks Summit
Are you seeing benefits from big data, AI and machine learning? Some companies are challenged by the complexity of the tools, access to quality data and the ability to operationalize these technologies. IBM’s Watson Studio addresses the needs of developers, data scientists and business analysts – who need to create, train and deploy machine and deep learning models, analyze and visualize data – all in an easy-to-use platform. Watson Studio supports Apple’s Core ML with Watson Visual Recognition service. It provides a suite of tools for data scientists, application developers and subject matter experts to collaboratively and easily work with data and use that data to build, train and deploy models at scale. When coupled with IBM Watson Knowledge Catalog, it enables companies to create a secure catalog of AI assets including datasets, documents and models. In this session, you will learn how to use these new offerings to solve real world business problems and infuse AI into your business to drive innovation.
Speaker
Sumit Goyal, IBM, Software Engineer
At the heart of data processing, event-sourcing, actors, and much more is the queue—a data structure that allows producers to pass work to consumers in a flexible way. On the JVM, most libraries, including Akka, are powered by Java concurrent queues, which are reliable but were designed in a different era, for synchronous (blocking) procedural code. In this presentation, John A. De Goes—architect of the Scalaz 8 effect system—introduces IOQueue, a new type of queue powered by the Scalaz 8 IO monad. IOQueue never blocks and provides seamless, composable back-pressure across an entire application, without users having to think about the problem or write any special code. John will discuss how IOQueue achieves these remarkable properties, and show how the structure can be used to solve hard problems with just a few lines of type-safe, leak-free, composable Scala code. Come learn about the power of Scalaz to solve the hard problems of software development, in a principled way, without compromises.
Scala Intro training @ Lohika, Odessa, UA.
This is a basic Scala Programming Language overview intended to evangelize the language among any-language programmers.
Effective Java, Third Edition - Keepin' it EffectiveC4Media
Video and slides synchronized, mp3 and slide download available at URL https://bit.ly/2uOURQH.
Joshua Bloch covers some highlights from the third edition of “Effective Java”, concentrating on streams and lambdas. The recently released edition of Effective Java contains one new chapter, fourteen new items, and numerous changes to existing items. Filmed at qconnewyork.com.
Joshua Bloch is the author of Effective Java and coauthor of Java Puzzlers and Java Concurrency in Practice. He was formerly the chief Java architect at Google, a distinguished engineer at Sun Microsystems. He led the design and implementation of numerous Java platform features, including the Java 5 language enhancements and the Java Collections Framework.
Simplifying AI and Machine Learning with Watson StudioDataWorks Summit
Are you seeing benefits from big data, AI and machine learning? Some companies are challenged by the complexity of the tools, access to quality data and the ability to operationalize these technologies. IBM’s Watson Studio addresses the needs of developers, data scientists and business analysts – who need to create, train and deploy machine and deep learning models, analyze and visualize data – all in an easy-to-use platform. Watson Studio supports Apple’s Core ML with Watson Visual Recognition service. It provides a suite of tools for data scientists, application developers and subject matter experts to collaboratively and easily work with data and use that data to build, train and deploy models at scale. When coupled with IBM Watson Knowledge Catalog, it enables companies to create a secure catalog of AI assets including datasets, documents and models. In this session, you will learn how to use these new offerings to solve real world business problems and infuse AI into your business to drive innovation.
Speaker
Sumit Goyal, IBM, Software Engineer
At the heart of data processing, event-sourcing, actors, and much more is the queue—a data structure that allows producers to pass work to consumers in a flexible way. On the JVM, most libraries, including Akka, are powered by Java concurrent queues, which are reliable but were designed in a different era, for synchronous (blocking) procedural code. In this presentation, John A. De Goes—architect of the Scalaz 8 effect system—introduces IOQueue, a new type of queue powered by the Scalaz 8 IO monad. IOQueue never blocks and provides seamless, composable back-pressure across an entire application, without users having to think about the problem or write any special code. John will discuss how IOQueue achieves these remarkable properties, and show how the structure can be used to solve hard problems with just a few lines of type-safe, leak-free, composable Scala code. Come learn about the power of Scalaz to solve the hard problems of software development, in a principled way, without compromises.
Scala Intro training @ Lohika, Odessa, UA.
This is a basic Scala Programming Language overview intended to evangelize the language among any-language programmers.
Presentation provides introduction and detailed explanation of the Java 8 Lambda and Streams. Lambda covers with Method references, default methods and Streams covers with stream operations,types of streams, collectors. Also streams are elaborated with parallel streams and benchmarking comparison of sequential and parallel streams.
Additional slides are covered with Optional, Splitators, certain projects based on lambda and streams
download for better quality - Learn how to use an Applicative Functor to handle multiple independent effectful values through the work of Sergei Winitzki, Runar Bjarnason, Paul Chiusano, Debasish Ghosh and Adelbert Chang
During OOW 2013 a full day seminar was organized by ODTUG covering 4 printing scenario's for Oracle Application Express : PL/PDF, Jasper Reports, FOP and BI Publisher.
This presentation covers that last one. Alas the demo isn't viewable...
Boost your productivity with Scala tooling!MeriamLachkar1
Our rich ecosystem provides developers with powerful tools that improve productivity on small or huge projects.
In this talk, I will present the tools that allow me to focus on my projects by making tedious tasks easier. From bootstrapping projects, to code linting and refactoring, from continuous integration and automatic publication and documentation rendering, come discover my favorite tools.
This tutorial creates two machine learning models with IBM Watson Studio. The first is created in the UI and the second in Jupyter Notebook using scikit-learn. We will save and deploy bother models on IBM Cloud.
Download for better quality.
Monads do not Compose. Not in a generic way - There is no general way of composing monads.
A comment from Rúnar Bjarnason, coauthor of FP in Scala: "They do compose in a different generic way. For any two monads F and G we can take the coproduct which is roughly Free of Either F or G (up to normalization)".
Another comment from Sergei Winitzki (which caused me to upload https://www.slideshare.net/pjschwarz/addendum-to-monads-do-not-compose): "It is a mistake to think that a traversable monad can be composed with another monad. It is true that, given `Traversable`, you can implement the monad's methods (pure and flatMap) for the composition with another monad (as in your slides 21 to 26), but this is a deceptive appearance. The laws of the `Traversable` typeclass are far insufficient to guarantee the laws of the resulting composed monad. The only traversable monads that work correctly are Option, Either, and Writer. It is true that you can implement the type signature of the `swap` function for any `Traversable` monad. However, the `swap` function for monads needs to satisfy very different and stronger laws than the `sequence` function from the `Traversable` type class. I'll have to look at the "Book of Monads"; but, if my memory serves, the FPiS book does not derive any of these laws." See https://www.linkedin.com/feed/update/urn:li:groupPost:41001-6523141414614814720?commentUrn=urn%3Ali%3Acomment%3A%28groupPost%3A41001-6523141414614814720%2C6532108273053761536%29
Presented at AI NEXTCon Seattle 1/17-20, 2018
http://aisea18.xnextcon.com
join our free online AI group with 50,000+ tech engineers to learn and practice AI technology, including: latest AI news, tech articles/blogs, tech talks, tutorial videos, and hands-on workshop/codelabs, on machine learning, deep learning, data science, etc..
Real-Time Stream Processing with KSQL and Apache Kafkaconfluent
Real Time Stream Processing with KSQL and Kafka
David Peterson, Confluent APAC
APIdays Melbourne 2018
Unordered, unbounded and massive datasets are increasingly common in day-to-day business. Using this to your advantage is incredibly difficult with current system designs. We are stuck in a model where we can only take advantage of this *after* it has happened. Many times, this is too late to be useful in the enterprise.
KSQL is a streaming SQL engine for Apache Kafka. KSQL lowers the entry bar to the world of stream processing, providing a simple and completely interactive SQL interface for processing data in Kafka. KSQL (like Kafka) is open-source, distributed, scalable, and reliable.
A real time Kafka platform moves your data up the stack, closer to the heart of your business, allowing you to build scalable, mission-critical services by quickly deploying SQL-like queries in a severless pattern.
This talk will highlight key use cases for real time data, and stream processing with KSQL: Real time analytics, security and anomaly detection, real time ETL / data integration, Internet of Things, application development, and deploying Machine Learning models with KSQ.
Real time data and stream processing means that Kafka is just as important to the disrupted as it is to the disruptors.
The presentation gives an overview about the ruby programming language and Rails, the web framework built over it ruby. It does highlight some of the key features of ruby programming language and mentions the key benefits of using Rails framework for web application development.
Kyo is a next-generation effect system that introduces an approach based on algebraic effects to deliver straightforward APIs in the pure Functional Programming paradigm. Unlike similar solutions, Kyo achieves this without inundating developers with esoteric concepts from Category Theory or using cryptic symbolic operators. This results in a development experience that is both intuitive and robust.
Kyo generalizes the innovative effect rotation mechanism introduced by ZIO. While ZIO restricts effects to two channels, namely dependency injection and short-circuiting, Kyo allows for an arbitrary number of effectful channels. This enhancement offers developers greater flexibility in effect management and simplifies Kyo's internal codebase through more principled design patterns.
In addition to this novel approach to effect handling, Kyo provides seamless direct syntax inspired by Monadless and a comprehensive set of built-in effects like Aborts for short-circuiting, Envs for dependency injection, and Fibers for green threads with fine-grained uncooperative preemption.
After over two years in development, the first public release of the project will be made during Functional Scala 2023. Attendees will also be treated to benchmark results that showcase Kyo's unparalleled performance.
The talk covers foundations and applications of implicit function types. It is an updated and more condensed version of the "What to Leave Implicit Talk" given at CurryOn/PLDI 2017.
Presentation provides introduction and detailed explanation of the Java 8 Lambda and Streams. Lambda covers with Method references, default methods and Streams covers with stream operations,types of streams, collectors. Also streams are elaborated with parallel streams and benchmarking comparison of sequential and parallel streams.
Additional slides are covered with Optional, Splitators, certain projects based on lambda and streams
download for better quality - Learn how to use an Applicative Functor to handle multiple independent effectful values through the work of Sergei Winitzki, Runar Bjarnason, Paul Chiusano, Debasish Ghosh and Adelbert Chang
During OOW 2013 a full day seminar was organized by ODTUG covering 4 printing scenario's for Oracle Application Express : PL/PDF, Jasper Reports, FOP and BI Publisher.
This presentation covers that last one. Alas the demo isn't viewable...
Boost your productivity with Scala tooling!MeriamLachkar1
Our rich ecosystem provides developers with powerful tools that improve productivity on small or huge projects.
In this talk, I will present the tools that allow me to focus on my projects by making tedious tasks easier. From bootstrapping projects, to code linting and refactoring, from continuous integration and automatic publication and documentation rendering, come discover my favorite tools.
This tutorial creates two machine learning models with IBM Watson Studio. The first is created in the UI and the second in Jupyter Notebook using scikit-learn. We will save and deploy bother models on IBM Cloud.
Download for better quality.
Monads do not Compose. Not in a generic way - There is no general way of composing monads.
A comment from Rúnar Bjarnason, coauthor of FP in Scala: "They do compose in a different generic way. For any two monads F and G we can take the coproduct which is roughly Free of Either F or G (up to normalization)".
Another comment from Sergei Winitzki (which caused me to upload https://www.slideshare.net/pjschwarz/addendum-to-monads-do-not-compose): "It is a mistake to think that a traversable monad can be composed with another monad. It is true that, given `Traversable`, you can implement the monad's methods (pure and flatMap) for the composition with another monad (as in your slides 21 to 26), but this is a deceptive appearance. The laws of the `Traversable` typeclass are far insufficient to guarantee the laws of the resulting composed monad. The only traversable monads that work correctly are Option, Either, and Writer. It is true that you can implement the type signature of the `swap` function for any `Traversable` monad. However, the `swap` function for monads needs to satisfy very different and stronger laws than the `sequence` function from the `Traversable` type class. I'll have to look at the "Book of Monads"; but, if my memory serves, the FPiS book does not derive any of these laws." See https://www.linkedin.com/feed/update/urn:li:groupPost:41001-6523141414614814720?commentUrn=urn%3Ali%3Acomment%3A%28groupPost%3A41001-6523141414614814720%2C6532108273053761536%29
Presented at AI NEXTCon Seattle 1/17-20, 2018
http://aisea18.xnextcon.com
join our free online AI group with 50,000+ tech engineers to learn and practice AI technology, including: latest AI news, tech articles/blogs, tech talks, tutorial videos, and hands-on workshop/codelabs, on machine learning, deep learning, data science, etc..
Real-Time Stream Processing with KSQL and Apache Kafkaconfluent
Real Time Stream Processing with KSQL and Kafka
David Peterson, Confluent APAC
APIdays Melbourne 2018
Unordered, unbounded and massive datasets are increasingly common in day-to-day business. Using this to your advantage is incredibly difficult with current system designs. We are stuck in a model where we can only take advantage of this *after* it has happened. Many times, this is too late to be useful in the enterprise.
KSQL is a streaming SQL engine for Apache Kafka. KSQL lowers the entry bar to the world of stream processing, providing a simple and completely interactive SQL interface for processing data in Kafka. KSQL (like Kafka) is open-source, distributed, scalable, and reliable.
A real time Kafka platform moves your data up the stack, closer to the heart of your business, allowing you to build scalable, mission-critical services by quickly deploying SQL-like queries in a severless pattern.
This talk will highlight key use cases for real time data, and stream processing with KSQL: Real time analytics, security and anomaly detection, real time ETL / data integration, Internet of Things, application development, and deploying Machine Learning models with KSQ.
Real time data and stream processing means that Kafka is just as important to the disrupted as it is to the disruptors.
The presentation gives an overview about the ruby programming language and Rails, the web framework built over it ruby. It does highlight some of the key features of ruby programming language and mentions the key benefits of using Rails framework for web application development.
Kyo is a next-generation effect system that introduces an approach based on algebraic effects to deliver straightforward APIs in the pure Functional Programming paradigm. Unlike similar solutions, Kyo achieves this without inundating developers with esoteric concepts from Category Theory or using cryptic symbolic operators. This results in a development experience that is both intuitive and robust.
Kyo generalizes the innovative effect rotation mechanism introduced by ZIO. While ZIO restricts effects to two channels, namely dependency injection and short-circuiting, Kyo allows for an arbitrary number of effectful channels. This enhancement offers developers greater flexibility in effect management and simplifies Kyo's internal codebase through more principled design patterns.
In addition to this novel approach to effect handling, Kyo provides seamless direct syntax inspired by Monadless and a comprehensive set of built-in effects like Aborts for short-circuiting, Envs for dependency injection, and Fibers for green threads with fine-grained uncooperative preemption.
After over two years in development, the first public release of the project will be made during Functional Scala 2023. Attendees will also be treated to benchmark results that showcase Kyo's unparalleled performance.
The talk covers foundations and applications of implicit function types. It is an updated and more condensed version of the "What to Leave Implicit Talk" given at CurryOn/PLDI 2017.
Aim of this presentation is not to make you masters in Java 8 Concurrency, but to help you guide towards that goal. Sometimes it helps just to know that there is some API that might be suitable for a particular situation. Make use of the pointers given to search more and learn more on those topics. Refer to books, Java API Documentation, Blogs etc. to learn more. Examples and demos for all cases discussed will be added to my blog www.javajee.com.
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Raffi Khatchadourian
Java 8 is one of the largest upgrades to the popular language and framework in over a decade. In this talk, I will first overview several new, key features of Java 8 that can help make programs easier to read, write, and maintain, especially in regards to collections. These features include Lambda Expressions, the Stream API, and enhanced interfaces, many of which help bridge the gap between functional and imperative programming paradigms and allow for succinct concurrency implementations. Next, I will discuss several open issues related to automatically migrating (refactoring) legacy Java software to use such features correctly, efficiently, and as completely as possible. Solving these problems will help developers to maximally understand and adopt these new features thus improving their software.
Patterns and Anti-patterns
How to learn design patterns?
Categories of GoF patterns
The Fundamental theorem of software engineering
Real-world problems and how design patterns solve them with GoF structural patterns
The process of changing a software system in such a way that it does not alter the external (observable) behavior of the code yet improves its internal structure, to make it easier to understand and cheaper to modify.
“Lambdas in JAVA 8 is not for what they can do, It is about how we write Program”
It enables Functional Programming, It Adds a New nucleotides in the DNA of Java.
There is a Change in “The Climate” to change our Ways.
This ppt describes basics of scala upto collections covering both object oriented and functional programming concepts of the language.
References:Scala cookbook
Some of the most common and easy-to-calculate/easy-to-measure code metrics. Understanding these can help you make your code better: avoiding code rot and writing maintainable code all starts here. Content is created for C# .net, however, the underlying principles apply to other languages/frameworks as well.
Scala - The Simple Parts, SFScala presentationMartin Odersky
These are the slides of the talk I gave on May 22, 2014 to the San Francisco Scala user group. Similar talks were given before at GOTO Chicago, keynote, at Gilt Groupe and Hunter College in New York, at JAX Mainz and at FlatMap Oslo.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
3. Context is all around us
- the current configuration
- the current scope
- the meaning of “<” on this type
- the user on behalf of which the
operation is performed
- the security level in effect
…
4. - globals
rigid if immutable,
unsafe if mutable
- monkey patching
- dependency injection
at runtime (Spring, Guice)
or with macros (MacWire)
- cake pattern
close coupling + recursion
Traditional ways to express context
6. - no side effects
- type-safe
- fine-grained control
Functional is Good
7. - sea of parameters
- most of which hardly ever change
- repetitive, boring, prone to mistakes
But sometimes it’s too much of a
good thing …
8. If passing a lot of parameters gets tedious,
leave some of them implicit.
A more direct approach
9. • If there’s one feature that makes Scala “Scala”,
I would pick implicits.
• There’s hardly an API without them.
• They enable advanced and elegant
architectural designs.
• They are also misused way too often.
Implicits
10. • takes you through the most common uses of
implicits,
• gives recommendations of use patterns,
• goes through a set of proposed language
changes that will make implicits even more
powerful and safer to use.
This Talk
t
11. • If you do not give an argument to an implicit
parameter, one will be provided for you.
• Eligible are all implicit values that are visible at
the point of call.
• If there are more than one eligible candidate,
the most specific one is chosen.
• If there’s no unique most specific candidate, an
ambiguity error Is reported.
Ground Rules
12. • They are a cousin of implicit parameters.
• If the type A of an expression does not match
the expected type B …
Implicit Conversions
13. • They are a cousin of implicit parameters.
• If the type A of an expression does not match
the expected type B …
… the compiler tries to find an implicit
conversion method from A to B.
• Same rules as for implicit parameters apply.
Implicit Conversions
14. • Shorthand for defining a new class and an
implicit conversion into it.
implicit class C(x: T) { … }
expands to
class C(x: T) { … }
implicit def C(x: T) = new C(x)
Implicit Classes
15. • Implicits leverage what the compiler knows
about your code.
• They remove repetition and boilerplate.
• But taken too far, they can hurt readability.
When To Use Implicits?
16. Applicability:
Where are you allowed to elide implied information?
How do you find out this is happening?
Power:
What influence does the elided info have?
Can it change radically behavior or types?
Scope:
How much of the rest of the code do you need to know
to find out what is implied?
Is there always a clear place to look?
* Adapted from Rust’s Language Ergonomics Initiative
Reasoning Footprint of Implicitness*
20. Late Trait Implementation
Make existing classes implement new traits
without changing their code.
This was the original reason for implicits in Scala.
Discoverability: low to medium
Power: low to medium
Scope: large, but IDEs help
21. They also have some use cases, e.g.
• cached implicit classes
• context-dependent views
What about simple conversions?
22. • Conversions that go both ways
• Conversions that change semantics
E.g. collection.convert.WrapAs{Java,Scala}
Better: Use Converters
collection.convert.DecorateAs{Java,Scala}
Anti Patterns
28. Establish Context
Example: conference management system.
Reviewers should only see (directly or indirectly) the
scores of papers where they have no conflict with an
author.
33. What will change:
1. Tighten the rules for implicit conversions
2. Lazy implicits
3. Multiple implicit parameter lists
4. Coherence(?)
5. Implicit function types
34. 1. Tighten Rules for
Implicit Conversions
Question: What does this print?
Answer: java.lang.IndexOutOfBoundsException: 42
Hint: List[String] <: Function[Int, String]
35. In the future: Only implicit methods are eligible as
conversions.
A new class ImplicitConverter allows to abstract over
implicit conversions.
Converters are turned into conversions like this:
1. Tighten Rules for
Implicit Conversions
37. 2. Lazy Implicits
Problem: When synthesizing code for recursive data
structures, we get divergent implicit searches.
E.g.
will diverge if A expands recursively to Sum[A, B]
38. 2. Lazy Implicits
Solution: Delay the implicit search and tie the recursive
knot with a lazy val if a parameter is call-by-name:
This change, proposed by Miles Sabin, is a more robust
solution than the current “Lazy” type in shapeless.
40. 3. Multiple Implicit Parameter Lists
Problem: Implicit parameters are currently a bit irregular
compared to normal parameters:
• there can be only one implicit parameter section
• and it must come last.
This leads to some awkward workarounds (c.f. Aux
pattern).
Related problem: It’s sometimes confusing when a
parameter is implicit or explicit.
41. 3. Multiple Implicit Parameter Lists
Proposal:
• Allow multiple implicit parameter lists
• Implicit and explicit parameter lists can be mixed freely.
• Explicit application of an implicit parameter must be
marked with a new “magic” method, explicitly.
• Implementation status: Proposal. Main challenge is
migration from current Scala.
42. 4. Coherence
Difference between Scala’s implicits and Haskell’s type
classes: The latter are required to be coherent:
A type can implement a type class in one way only
(globally).
This is very restrictive, rules out most of the implicit use
cases we have seen.
But it also provides some benefits.
43. Coherence Rules Out Ambiguities
Say you have a capability system dealing with driver
licences:
If you can drive a truck and a cab, you should be able to
drive a car. But Scala would give you an ambiguity error.
44. Coherence Rules Out Ambiguities
Proposal:
• Allow type classes to declare themselves coherent.
• Have the compiler check that coherent traits have only
one implementation per type.
This is quite tricky. See github.com/lampepfl/dotty/issues/2047
• Drop all ambiguity checks for coherent implicits.
45. Parametricity
• It turns out that a necessary condition to ensure
coherence is to disallow operations like equals,
hashCode, isInstanceOf on coherent types.
• This restriction is useful in other contexts as well
because it gives us “theorems for free”.
• Proposal: Change Scala’s
top types to:
• AnyObj has all of current
Any’s methods. Any has only
the escape-hatch method
asInstanceOf.
47. 5. Implicit Function Types
Have another look at the conference management system:
In a large system, it gets tedious to declare all these
implicit Viewers parameters.
48. Can we do better?
Having to write
a couple of times does not look so bad.
But in the dotty compiler there are > 2600 occurrences of
the parameter
Would it not be nice to get rid of them?
51. Towards a solution
Let’s massage the definition of viewRankings a bit:
What is its type?
So far: Viewers => List[Paper]
From now on: implicit Viewers=> List[Paper]
or, desugared: ImplicitFunction1[Viewers, List[Paper]]
53. Two Rules for Typing
1. Implicit functions get implicit arguments just like implicit
methods. Given:
val f: implicit A => B
implicit val a: A
f expands to f(a).
2. Implicit functions get created on demand. If the
expected type of b is implicit A => B, then
b expands to implicit (_: A) => b
55. Efficiency
Implicit function result types can be optimized
Instead of creating a closure like this:
we can simply create a curried function like this:
This brings the cost of implicit functions down to simple
implicit parameters.
57. • The reader monad is a somewhat popular method to
pass context.
• Essentially, it wraps the implicit reading in a monad.
• One advantage: The reading is abstracted in a type.
• But I believe this is shooting sparrows with cannons.
• Monads are about sequencing, they have have nothing
to do with passing context.
The Reader Monad
58. • allow the same conciseness as the reader
monad,
• don’t force you into monadic style with explicit
sequencing,
• are fully composable,
• are more than 7x faster than the reader monad.
Implicit function types
59. Neat way to define structure-building DSLs, like this:
Natively supported in Groovy and in Kotlin via
“receiver functions”.
An encore: The Builder Pattern
61. • Any situation where an entity is implicitly
understood can be expressed with implicit
function types.
• We have seen:
“The current set of viewers”
“The structure to which current code should be added”
• Other possibilities:
“The current configuration”
“The currently running transaction”
“The capabilities needed to run this code”
"The effects this code has on the outside world”
…
Conjecture
63. • Implicit function types are a neat way to
abstract over contexts.
• It’s a very powerful feature, because it allows
one to inject implicit values in a scope simply
by defining a type.
• I expect it will fundamentally affect the kind of
code we will write in the future.
Summary (1)
64. • Implicit parameters are a fundamental and
powerful language construct.
• They are “just” parameterization, but remove
the boilerplate.
• One construct multifaceted use cases
• Abstractable using implicit function types.
• Implicit conversions are also very convenient,
but should be used with care.
Summary (2)
65. When Can I Expect This?
Scala 2.12
Scala 2.13
Scala 3.0
TASTY,
middle end?
stdlib
collections
dotty MVP
dotty 0.x releases
2016
backend, classpath handling
Scala 2.14
2017
2018
This is open source work, depends on community’s contributions.
Roadmap is tentative, no promises:
“MVP” = minimal
viable
prototype
66. Dotty:
Dmitry Petrashko Nicolas Stucki
Guillaume Martres Sebastien Douraene
Felix Mulder Ondrej Lhotak
Liu Fengyun Enno Runne
Close collaboration with scalac team @ Lightbend:
Adriaan Moors Seth Tisue
Jason Zaugg Stefan Zeiger
Lukas Rytz
Credits
OPEN GAMBIT
Multicore. Cloud computing. Containers. You’ll likely agree that the infrastructure for amazing scalability is in place, it’s been well funded. It’s the underpinning that’s required for enterprises to movie en masse to the cloud. But what are they moving?
Applications.
Applications that run their business, engage their customers, allow them to innovate and enter new markets.
Without applications, this infinitely scalable infrastructure is nothing.
OPEN GAMBIT
Multicore. Cloud computing. Containers. You’ll likely agree that the infrastructure for amazing scalability is in place, it’s been well funded. It’s the underpinning that’s required for enterprises to movie en masse to the cloud. But what are they moving?
Applications.
Applications that run their business, engage their customers, allow them to innovate and enter new markets.
Without applications, this infinitely scalable infrastructure is nothing.