The document provides an overview of higher-kinds, typeclasses, type-level encodings, and continuations in Scala. It discusses how kind systems classify types, how typeclasses allow abstraction over types, and examples of encoding data structures like linked lists at the type level. It also introduces delimited continuations in Scala and how they can be used to simulate control flow constructs like break statements.
Slides for my recent presentation at the CASE meetup, May 21st. Discusses functional programming features in Scala. Goes from basic FP features like higher-order functions all the way through to monads.
My Scala by the Bay 2014 talk on exploring the ideas behind the implementation of the generic library shapeless, and general ideas about how to do "type level" programming in Scala.
Watch video (in Hebrew): http://parleys.com/play/53f7a9cce4b06208c7b7ca1e
Type classes are a fundamental feature of Scala, which allows you to layer new functionality on top of existing types externally, i.e. without modifying or recompiling existing code. When combined with implicits, this is a truly remarkable tool that enables many of the advanced features offered by the Scala library ecosystem. In this talk we'll go back to basics: how type classes are defined and encoded, and cover several prominent use cases.
A talk given at the Underscore meetup on 19 August, 2014.
Slides for my recent presentation at the CASE meetup, May 21st. Discusses functional programming features in Scala. Goes from basic FP features like higher-order functions all the way through to monads.
My Scala by the Bay 2014 talk on exploring the ideas behind the implementation of the generic library shapeless, and general ideas about how to do "type level" programming in Scala.
Watch video (in Hebrew): http://parleys.com/play/53f7a9cce4b06208c7b7ca1e
Type classes are a fundamental feature of Scala, which allows you to layer new functionality on top of existing types externally, i.e. without modifying or recompiling existing code. When combined with implicits, this is a truly remarkable tool that enables many of the advanced features offered by the Scala library ecosystem. In this talk we'll go back to basics: how type classes are defined and encoded, and cover several prominent use cases.
A talk given at the Underscore meetup on 19 August, 2014.
Some languages, like SML, Haskell, and Scala, have built-in support for pattern matching, which is a generic way of branching based on the structure of data.
While not without its drawbacks, pattern matching can help eliminate a lot of boilerplate, and it's often cited as a reason why functional programming languages are so concise.
In this talk, John A. De Goes talks about the differences between built-in patterns, and so-called first-class patterns (which are "do-it-yourself" patterns implemented using other language features).
Unlike built-in patterns, first-class patterns aren't magical, so you can store them in variables and combine them in lots of interesting ways that aren't always possible with built-in patterns. In addition, almost every programming language can support first-class patterns (albeit with differing levels of effort and type-safety).
During the talk, you'll watch as a mini-pattern matching library is developed, and have the opportunity to follow along and build your own pattern matching library in the language of your choice.
Scala Intro training @ Lohika, Odessa, UA.
This is a basic Scala Programming Language overview intended to evangelize the language among any-language programmers.
Slides from my talk at the Junction (Jan 24, 2013)
Single-core performance has hit a ceiling, and building web-scale multi-core applications using imperative programming models is nightmarishly difficult. Parallel programming creates a new set of challenges, best practices and design patterns. Scala is designed to enable building scalable systems, elegantly blending functional and object oriented paradigms into an expressive and concise language, while retaining interoperability with Java. Scala is the fastest growing JVM programming language, being rapidly adopted by leading companies such as Twitter, LinkedIn and FourSquare.
This presentation provides a comprehensive overview of the language, which managed to increase type safety while feeling more dynamic, being more concise and improving readability at the same time. We will see how Scala simplifies real life problems by empowering the developer with powerful functional programming primitives, without giving up on the object oriented paradigm. The overview includes tools for multi-core programming in Scala, the type system, collection framework and domain-specific languages. We’ll explore the power of compile-time meta-programming, which is made possible by the newly released Scala 2.10, and get a glimpse into what to expect from 2.11 in 2014.
We will also see how Scala helps overcome the inherent limitations of Java, such as type erasure, array covariance and boxing overhead.
Multiple examples emphasize how Scala pushes the JVM harder than any other mainstream language through the infinite number of boilerplate busters, increased type safety and productivity boosters from a Java developer’s perspective.
A teaser talk for Scala newbies, introducing five basic elements that (in my opinion) make the transition from Java to Scala a no-brainer.
Given at the 7th JJTV (Israeli Java/JVM user group) tool night, July 2nd, 2013.
This is brief presentation on the Scala programming language. It is aimed at Java developers who are curious about Scala. It was given at a San Francisco Java User Group in January 2009.
"The joy of Scala" - Maxim Novak / Wix
Around eight years ago I started my journey as a developer. Since then, I've played around with many languages and thought that C# offers the best developer productivity. After joining Wix two years ago, I was exposed to the amazing world of Scala and Functional Programming and never looked back.
In Scala the code is much more concise, less ceremonious, immutable by default, combines functional with object oriented, seamlessly interoperates with Java, and many software engineering patterns are already baked into the language. Most importantly - Scala is FUN! By the end of the session you too will, hopefully, convert to Scala and never look back.
Recording of the lecture (Hebrew) - https://youtu.be/TcnYTwff2xU
Some notes about programming in Scala: it covers Scala syntax and semantics, programming techniques, idioms, patterns. Many Scala features are introduced, from basic to intermediate and advanced. These are not introductory notes, but they assume a working knowledge with some other programming language (Java, C#, C++), object-oriented programming (OOP) concepts, and functional programming (FP) concepts.
The Eff monad is an alternative to monad transformers. It is implemented as a library in https://github.com/atnos-org/eff-cats and https://github.com/atnos-org/eff-scalaz
Some languages, like SML, Haskell, and Scala, have built-in support for pattern matching, which is a generic way of branching based on the structure of data.
While not without its drawbacks, pattern matching can help eliminate a lot of boilerplate, and it's often cited as a reason why functional programming languages are so concise.
In this talk, John A. De Goes talks about the differences between built-in patterns, and so-called first-class patterns (which are "do-it-yourself" patterns implemented using other language features).
Unlike built-in patterns, first-class patterns aren't magical, so you can store them in variables and combine them in lots of interesting ways that aren't always possible with built-in patterns. In addition, almost every programming language can support first-class patterns (albeit with differing levels of effort and type-safety).
During the talk, you'll watch as a mini-pattern matching library is developed, and have the opportunity to follow along and build your own pattern matching library in the language of your choice.
Scala Intro training @ Lohika, Odessa, UA.
This is a basic Scala Programming Language overview intended to evangelize the language among any-language programmers.
Slides from my talk at the Junction (Jan 24, 2013)
Single-core performance has hit a ceiling, and building web-scale multi-core applications using imperative programming models is nightmarishly difficult. Parallel programming creates a new set of challenges, best practices and design patterns. Scala is designed to enable building scalable systems, elegantly blending functional and object oriented paradigms into an expressive and concise language, while retaining interoperability with Java. Scala is the fastest growing JVM programming language, being rapidly adopted by leading companies such as Twitter, LinkedIn and FourSquare.
This presentation provides a comprehensive overview of the language, which managed to increase type safety while feeling more dynamic, being more concise and improving readability at the same time. We will see how Scala simplifies real life problems by empowering the developer with powerful functional programming primitives, without giving up on the object oriented paradigm. The overview includes tools for multi-core programming in Scala, the type system, collection framework and domain-specific languages. We’ll explore the power of compile-time meta-programming, which is made possible by the newly released Scala 2.10, and get a glimpse into what to expect from 2.11 in 2014.
We will also see how Scala helps overcome the inherent limitations of Java, such as type erasure, array covariance and boxing overhead.
Multiple examples emphasize how Scala pushes the JVM harder than any other mainstream language through the infinite number of boilerplate busters, increased type safety and productivity boosters from a Java developer’s perspective.
A teaser talk for Scala newbies, introducing five basic elements that (in my opinion) make the transition from Java to Scala a no-brainer.
Given at the 7th JJTV (Israeli Java/JVM user group) tool night, July 2nd, 2013.
This is brief presentation on the Scala programming language. It is aimed at Java developers who are curious about Scala. It was given at a San Francisco Java User Group in January 2009.
"The joy of Scala" - Maxim Novak / Wix
Around eight years ago I started my journey as a developer. Since then, I've played around with many languages and thought that C# offers the best developer productivity. After joining Wix two years ago, I was exposed to the amazing world of Scala and Functional Programming and never looked back.
In Scala the code is much more concise, less ceremonious, immutable by default, combines functional with object oriented, seamlessly interoperates with Java, and many software engineering patterns are already baked into the language. Most importantly - Scala is FUN! By the end of the session you too will, hopefully, convert to Scala and never look back.
Recording of the lecture (Hebrew) - https://youtu.be/TcnYTwff2xU
Some notes about programming in Scala: it covers Scala syntax and semantics, programming techniques, idioms, patterns. Many Scala features are introduced, from basic to intermediate and advanced. These are not introductory notes, but they assume a working knowledge with some other programming language (Java, C#, C++), object-oriented programming (OOP) concepts, and functional programming (FP) concepts.
The Eff monad is an alternative to monad transformers. It is implemented as a library in https://github.com/atnos-org/eff-cats and https://github.com/atnos-org/eff-scalaz
In this presentation, Akka Team Lead and author Roland Kuhn presents the freshly released final specification for Reactive Streams on the JVM. This work was done in collaboration with engineers representing Netflix, Red Hat, Pivotal, Oracle, Typesafe and others to define a standard for passing streams of data between threads in an asynchronous and non-blocking fashion. This is a common need in Reactive systems, where handling streams of "live" data whose volume is not predetermined.
The most prominent issue facing the industry today is that resource consumption needs to be controlled such that a fast data source does not overwhelm the stream destination. Asynchrony is needed in order to enable the parallel use of computing resources, on collaborating network hosts or multiple CPU cores within a single machine.
Here we'll review the mechanisms employed by Reactive Streams, discuss the applicability of this technology to a variety of problems encountered in day to day work on the JVM, and give an overview of the tooling ecosystem that is emerging around this young standard.
JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...PROIDEA
Contact
FUNCTIONAL PROGRAMING AND EVENT SOURCING - A PAIR MADE IN HEAVEN - EXTENDED, 2 HOURS LONG BRAINWASH
TL;DR: This is talk is a solid introduction to two (supposedly) different topics: FP & ES. I will cover both the theory and the practice. We will emerage ES+FP application starting from ES+OO one.
While reading blogs or attending conferences, you might have heard about Event Sourcing. But didn't you get this feeling, that while there is a lot of theory out there, it is really hard to see a hands-on example? And even if you find some, those are always orbiting around Object Oriented concepts?
Greg Young once said "When we talk about Event Sourcing, current state is a left-fold of previous behaviours. Nothing new to Functional Programmers". If Functional Programming is such a natural concept for event sourced systems, shouldn't they fit together on a single codebase?
In this talk we will quickly introduce Event Sourcing (but without going into details), we will introduce some functional concepts as well (like State monad). Armoured with that knowledge we will try to transform sample ES application (OO-style, tightly coupled with framework) to frameworkless, FP-style solution).
Talk is targeted for beginner and intermediate audience. Examples will be in Scala but nothing fancy - normal syntax.
This talk is an extended version of a presentation "Event Sourcing & Functional Programming - a pair made in heaven". It is enriched with content of presentations: "Monads - asking the right question" and "It's all been done before - The Hitchhiker's Guide to Time Travel".
Type classes 101 - classification beyond inheritanceAlexey Raga
Inheritance and interfaces implementation are often used in languages like Java in order to express "Is-a" and "Can-do" capabilities. In Scala we can do better by separating these concerns using the concept of type classes.
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™UiPathCommunity
In questo evento online gratuito, organizzato dalla Community Italiana di UiPath, potrai esplorare le nuove funzionalità di Autopilot, il tool che integra l'Intelligenza Artificiale nei processi di sviluppo e utilizzo delle Automazioni.
📕 Vedremo insieme alcuni esempi dell'utilizzo di Autopilot in diversi tool della Suite UiPath:
Autopilot per Studio Web
Autopilot per Studio
Autopilot per Apps
Clipboard AI
GenAI applicata alla Document Understanding
👨🏫👨💻 Speakers:
Stefano Negro, UiPath MVPx3, RPA Tech Lead @ BSP Consultant
Flavio Martinelli, UiPath MVP 2023, Technical Account Manager @UiPath
Andrei Tasca, RPA Solutions Team Lead @NTT Data
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
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
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
6. A type system is a tractable syntactic method for
proving the absence of certain program behaviors
by classifying phrases according to the kinds of
values they compute. – Benjamin Pierce
7. val i: Int = 42
val j: Int = 21
val s: String = "foo"
val f: Int => String = { _.toString }
val xs: List[Int] = List(1, 1, 2, 3, 5, 8)
21. Higher-Kinds
• Kind systems classify types
• Values are to types as types are to kinds
• “Higher” kinds are the kinds of type
constructors
• Type functions
• Use any time one type is logically a function
of another
22. Typeclasses
• Forget everything you know about classes
• (it won’t help you anyway)
• Instead of “class”, think “category”
• If you’ve ever looked at Haskell…
25. trait Num[A] {
val zero: A
def add(x: A, y: A): A
}
def sum[A](nums: List[A])(tc: Num[A]) =
nums.foldLeft(tc.zero)(tc.add)
26. object IntNum extends Num[Int] {
val zero = 0
def add(x: Int, y: Int) = x + y
}
object DoubleNum extends Num[Double] {
val zero = 0d
def add(x: Double, y: Double) = x + y
}
32. object IntNum extends Num[Int] {
val zero = 0
def add(x: Int, y: Int) = x + y
}
object DoubleNum extends Num[Double] {
val zero = 0d
def add(x: Double, y: Double) = x + y
}
33. implicit object IntNum extends Num[Int] {
val zero = 0
def add(x: Int, y: Int) = x + y
}
implicit object DoubleNum extends Num[Double] {
val zero = 0d
def add(x: Double, y: Double) = x + y
}
36. Typeclasses
• Typeclasses are categories of types
• If you have a set of types with well-defined
commonalities, think about typeclasses
• Collections in 2.8
• Numeric in 2.8
37. Type-Level Encodings
• Kinds make our types into superheroes
• Typeclasses allow us to abstract over types
• How can we abuse our new-found power?
38. Type-Level Encodings
• Kinds make our types into superheroes
• Typeclasses allow us to abstract over types
• How can we abuse our new-found power?
• Maybe…data structures at the type level?
39. Type-Level Encodings
• HList is a linked-list implemented in types
• …and values
• Sort of like Tuple, but unbounded
41. val xs1 = 42 :: false :: HNil
val xs2 = "Hello" :: "World" :: HNil
val xs = xs1 ++ xs2
xs.head // => 42: Int
xs.tail.tail.head // => "Hello": String
42. object HList {
sealed trait HList {
type Head
type Tail <: HList
type Append[L <: HList] <: HList
def head: Head
def tail: Tail
def ++[L <: HList](xs: L): Append[L]
}
// ...
}
43. val x: List[Int] = ...
val y: List[Int] = ...
x ++ y
x 1 2 3 4
y 5 6 7 8 9
44. val x: List[Int] = ...
val y: List[Int] = ...
x ++ y
x 2 3 4
y 5 6 7 8 9
45. val x: List[Int] = ...
val y: List[Int] = ...
x ++ y
x 3 4
y 5 6 7 8 9
46. val x: List[Int] = ...
val y: List[Int] = ...
x ++ y
x 4
y 5 6 7 8 9
47. val x: List[Int] = ...
val y: List[Int] = ...
x ++ y
x’
y 5 6 7 8 9
48. val x: List[Int] = ...
val y: List[Int] = ...
x ++ y
x’ 4
y 5 6 7 8 9
49. val x: List[Int] = ...
val y: List[Int] = ...
x ++ y
x’ 3 4
y 5 6 7 8 9
50. val x: List[Int] = ...
val y: List[Int] = ...
x ++ y
x’ 2 3 4
y 5 6 7 8 9
51. val x: List[Int] = ...
val y: List[Int] = ...
x ++ y
x’ 1 2 3 4
y 5 6 7 8 9
52. object HList {
// ...
final class HNil extends HList {
type Head = Nothing
type Tail = Nothing
type Append[L <: HList] = L
def head = error("Head of an empty HList")
def tail = error("Tail of an empty HList")
def ::[A](a: A) = HCons(a, this)
def ++[L <: HList](xs: L) = xs
}
val HNil = new HNil
}
53. object HList {
// ...
case class HCons[A, B <: HList](head: A, tail: B)
extends HList {
type Head = A
type Tail = B
type Append[L <: HList] =
HCons[Head, Tail#Append[L]]
def ::[C](c: C) = HCons(c, this)
def ++[L <: HList](xs: L) =
head :: (tail ++ xs)
}
type ::[A, B <: HList] = HCons[A, B]
}
56. Type-Level Encodings
• What about an nth(Int) function?
• Not today!
• Church Numerals
• λ-Calculus
• We could do a lot more
• Just not in a 45 minute talk
57. Continuations
• Actually, delimited continuations
• Very different from plain continuations!
• Not like callcc
• Not considered harmful
• …though they can simulate goto!
58. case class JumpException(i: Int)
extends RuntimeException
val res = try {
val i = 42
println("before")
throw JumpException(i) // basically: `break`
val j: Int = i / 2
println("after")
println(j + 2)
j // needed for type checker
} catch {
case JumpException(i) => i
}
println("outside")
59. val (res, func) = {
val i = 42
println("before")
(i, { j: Int =>
println("after")
println(j + 2)
})
}
println("outside")
func(res / 2)
func(res / 6)
60. val (res, func) = reset {
val i = 42
println("before")
val j = shift { (k: Int => Unit) => (i, k) }
println("after")
println(j + 2)
}
println("outside")
func(res / 2)
func(res / 6)
61. val (res, func) = reset {
val i = 42
println("before")
val j = shift { (k: Int => Unit) => (i, k) }
println("after")
println(j + 2)
}
println("outside")
func(res / 2)
func(res / 6)
62. val (res, func) = reset {
val i = 42
println("before")
val j = shift { (k: Int => Unit) => (i, k) }
println("after")
println(j + 2)
}
println("outside")
func(res / 2)
func(res / 6)
63. val (res, func) = reset {
val i = 42
println("before")
val j = shift { (k: Int => Unit) => (i, k) }
println("after")
println(j + 2)
}
println("outside")
func(res / 2)
func(res / 6)
64. def gen() = {
var x = 1
var y = 1
while (true) {
shift { (k: Unit => Result) => Result(x, k) }
y += x
x = y - x
}
}
val res = reset {
gen()
error("It never ends that way, too!"): Result
}
val fib: Stream[Int] = res.toStream
(credit: PEP-255)
65. def gen() = {
var x = 1
var y = 1
while (true) {
shift { (k: Unit => Result) => Result(x, k) }
y += x
x = y - x
}
}
val res = reset {
gen()
error("It never ends that way, too!"): Result
}
val fib: Stream[Int] = res.toStream
(credit: PEP-255)
67. Continuations
• This is cool and all, but what’s it good for?
• Not as much as you would think
68. reset {
for (i <- 0 to 10) {
shift { (k: Unit => Unit) => i }
}
}
69. reset {
for (i <- 0 to 10) {
shift { (k: Unit => Unit) => i }
}
}
70. Continuations
• This is cool and all, but what’s it good for?
• Not as much as you would think
• Nonblocking I/O
• Multi-page wizards
• Framework support is needed