Talk from LambdaDays 2014 in Krakow.
The talk focuses on some of Scala's more prominent types.
Video available here: https://vimeo.com/92620078
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.
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.
This document discusses various techniques for working with types in Scala, including:
1. The main alternatives for Scala types including classical OO, algebraic, generic, and structured types. It recommends choosing styles based on use cases and setting guidelines.
2. The differences between run-time and compile-time dispatch and how they are implemented in Scala.
3. Techniques for working with types including tagged types, type aliases, and implicit evidence to provide different behaviors based on types known at compile-time.
4. Resources for learning more about advanced type-level programming in Scala, particularly the Shapeless library.
This document provides a dictionary of scala programming concepts including definitions of common jargon like ADT, typeclasses, extension methods, and call-by semantics. It defines ADT as algebraic data types, which were introduced in languages like Algol 60 and ML, and pattern matching which allows decomposing ADT values. Typeclasses are defined as rules for types like equality, with instances providing implementations. Extension methods and implicit conversions add methods to types via implicit parameters. Call-by-name and call-by-need semantics are discussed in relation to lazy evaluation.
This document provides an overview of typeclasses in Haskell. It explains that typeclasses define properties that types can have, like being comparable (Eq) or ordered (Ord). Functions can constrain their parameters to only allow types that are members of certain typeclasses. The document also demonstrates how to define your own data types and derive standard typeclass instances or implement them yourself. This allows user-defined types to work with functions that require those typeclasses.
Swift is a modern, safe, and interactive programming language. It is fast, supports modern features like closures and generics, and is type safe with static typing and ARC memory management. The document provides an overview of key Swift concepts like variables and constants, basic types, optionals, collection types like arrays and dictionaries, control flow, and switch statements. Examples are given for working with strings, integers, floating point numbers, collections, and optional values.
This document provides a cheat sheet overview of Scala concepts including packages, imports, variables, constants, classes, traits, generics, methods, functions, operators, arrays, main methods, annotations, assignments, selection, iteration and references. Key points are that Scala uses packages similarly to Java but with curly brace delimiters, imports can be used anywhere in a file, variables use 'var', constants use 'val', classes inherit from Any and can use traits for mixins, generics are defined with type parameters, functions are objects, operators are methods, arrays are classes, main returns Unit, and assignments use = while iteration prefers recursion over loops.
1. Swift includes features like subscripts, optional chaining, and error handling that improve safety and flexibility compared to earlier languages.
2. The document discusses Swift concepts like extensions, protocols, and generics that allow code reuse and abstraction. Protocols define requirements that types can conform to through extensions.
3. Generics allow algorithms to work with different types through type parameters like Stack<Element>, avoiding duplicate non-generic code. This makes code cleaner, safer, and more reusable.
This document discusses the evolution of programming languages and hardware over time. It covers older languages like FORTRAN, BASIC, and C/C++. It also discusses newer languages like Rust, Go, and Julia. It describes how memory management, concurrency models, and distributed computing have changed. It proposes using techniques like functional interpreters and macros to allow languages to be more easily extended and adapted to new hardware. The document advocates for approaches that can efficiently support both old and new programming ideas.
This document provides an overview of key concepts in Haskell including:
- Functions are defined without variables and evaluate to the same result given the same parameters.
- Haskell is a purely functional programming language that uses lazy evaluation.
- It has a static type system where types are known at compile time.
- Custom types can be defined and typeclasses like Eq and Ord can be implemented for these types.
- Type parameters allow types to be generic and type synonyms provide aliases.
The document provides an overview of the Swift programming language, summarizing that it is fast, modern, and safe. It then covers key Swift concepts like variables, strings, arrays, dictionaries, optionals, control flow, functions, closses, classes, inheritance, enums, structs, protocols, extensions, and generics in under 3 sentences each. The document encourages learning more about Swift from Apple's official documentation.
At the beggining, we had RDDs. A distributed Scala collection! Then, the DataFrame API showed up. It brought with it tons of datasource implementations and a query optimizer. But... where are our types? Are we really referring to a column with a string and then casting it? In Scala? This meant more runtime errors and made the code harder to refactor. Then, we got Datasets. We have types again! The bad thing is that lambdas kill some of the performance we can achieve with dataframes. Also, runtime errors don't completely disappear.
The Frameless library tries to solve these problems so we can get all the performance, keep our types and reduce the runtime errors. This talk explains the pros and cons of the library, and also dives deeper into some implementation details to make it possible.
This document provides an overview of Scala fundamentals including:
- Scala is a programming language for the JVM that supports both object-oriented and functional paradigms.
- It defines variables, values, lazy values, functions, types, classes, objects, traits, and higher-order functions.
- Classes can extend other classes and traits, allowing for multiple inheritance. Objects are used as singletons.
- Functional concepts like immutability, anonymous functions, and higher-order functions are supported.
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.
This document provides an introduction to Swift 2 and covers various Swift language basics including variables and constants, arrays, optionals, functions and closures, classes, structs, enums, protocols, and generics. It discusses syntax, properties, methods and gives examples for each language feature. The document is organized into sections for each language concept and provides code samples and explanations.
This the slide stack for the two videos on Data types in my YouTube series on JavaScript. The videos are at https://www.youtube.com/watch?v=UAtJXkGggOU and https://www.youtube.com/watch?v=H2sjsGZyYaw
The document discusses how to work with Cocoa and Objective-C from Swift. It covers importing Objective-C frameworks, interacting with Objective-C APIs such as initializers, properties, and methods, type remapping between Objective-C and Swift types, working with AnyObject and optionals, blocks, and integrating Swift code with Interface Builder using outlets and actions.
Scala is a powerful language for the JVM that is compatible with JDK 1.5+. It is a functional language maintained by Typesafe along with the community. Scala compiles to JVM bytecode like Java but has features like objects, traits, pattern matching and functional programming. James Gosling, the creator of Java, said that if he were to pick a language other than Java today, it would be Scala.
This document discusses refactoring Scala code to improve quality and maintainability. It provides examples of issues like stringly typed code, abuse of collections, and poor scoping. The presentation recommends addressing these by using case classes instead of tuples, parsing values instead of passing raw strings, giving intermediate steps meaningful names, and separating logic and data through traits or type classes. Well-scoped code with a small public API and private implementation details is emphasized.
Miles Sabin Introduction To Scala For Java DevelopersSkills Matter
Scala is a programming language that blends object-oriented and functional programming styles. It is designed to interoperate with Java code and runs on the Java Virtual Machine. Some key features of Scala include case classes, pattern matching, traits for mixing behavior, and immutable data structures. Scala code compiles to Java bytecode, allowing seamless use of Java libraries and tools.
Swift provides several differences from Java/Android for language features, including:
1. Access control is handled through private, internal, open instead of private, default, protected, public. Optionals and nil are used to represent empty or missing values.
2. Closures allow blocks of code to be passed around as first-class functions, similar to blocks in Objective-C. Collection types use arrays and dictionaries instead of lists.
3. Control flow includes range operators for for loops and switch statements without break. Escaping closures can capture values from the current scope and are used for callbacks.
Scala Intro training @ Lohika, Odessa, UA.
This is a basic Scala Programming Language overview intended to evangelize the language among any-language programmers.
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.
C# programs use namespaces and classes. A class defines methods and variables. C# supports inheritance, interfaces, structs, and enums. The main method runs code. Common data types include primitive types like int and reference types like string. C# can read input, perform math operations, and conditionally execute code using if/else statements. Methods can pass parameters by value or reference.
This document provides an introduction to typeclasses in Scala and functional programming. It defines typeclasses as a way to define functions that can have different implementations depending on the type of data. The document then gives examples of using typeclasses for serialization and numeric operations. It discusses how typeclasses relate to category theory and how higher kinded types allow generalizing over type constructors. Pros of typeclasses are given as decoupling functionality from types and extensibility, while a potential con is increased code complexity.
Scala has many symbols, operators, and syntax elements that can be confusing for beginners. The underscore character in particular takes on many different meanings depending on context. Type erasure in Scala means that types are not always available at runtime. Initialization order of vals follows a defined rule where traits are initialized before subclasses. Having a deep understanding of Scala's semantics is important to explain unexpected behavior.
The document provides tips and tricks for intermediate Scala developers. It discusses using type aliases to simplify APIs and type signatures. ClassTags are mentioned as a way to access reflection information without runtime overhead. Auto-lifted partial functions allow using partial functions without explicitly specifying they are partial. NoStackTrace is introduced as a way to create exceptions without stack traces for performance. Type classes are explained as a design pattern using implicits to add capabilities to types. Context bounds and implicitly make working with type classes cleaner. @ImplicitNotFound provides helpful error messages. Low priority default implicits are suggested for providing type class instances without causing issues for user-defined instances.
This document discusses the evolution of programming languages and hardware over time. It covers older languages like FORTRAN, BASIC, and C/C++. It also discusses newer languages like Rust, Go, and Julia. It describes how memory management, concurrency models, and distributed computing have changed. It proposes using techniques like functional interpreters and macros to allow languages to be more easily extended and adapted to new hardware. The document advocates for approaches that can efficiently support both old and new programming ideas.
This document provides an overview of key concepts in Haskell including:
- Functions are defined without variables and evaluate to the same result given the same parameters.
- Haskell is a purely functional programming language that uses lazy evaluation.
- It has a static type system where types are known at compile time.
- Custom types can be defined and typeclasses like Eq and Ord can be implemented for these types.
- Type parameters allow types to be generic and type synonyms provide aliases.
The document provides an overview of the Swift programming language, summarizing that it is fast, modern, and safe. It then covers key Swift concepts like variables, strings, arrays, dictionaries, optionals, control flow, functions, closses, classes, inheritance, enums, structs, protocols, extensions, and generics in under 3 sentences each. The document encourages learning more about Swift from Apple's official documentation.
At the beggining, we had RDDs. A distributed Scala collection! Then, the DataFrame API showed up. It brought with it tons of datasource implementations and a query optimizer. But... where are our types? Are we really referring to a column with a string and then casting it? In Scala? This meant more runtime errors and made the code harder to refactor. Then, we got Datasets. We have types again! The bad thing is that lambdas kill some of the performance we can achieve with dataframes. Also, runtime errors don't completely disappear.
The Frameless library tries to solve these problems so we can get all the performance, keep our types and reduce the runtime errors. This talk explains the pros and cons of the library, and also dives deeper into some implementation details to make it possible.
This document provides an overview of Scala fundamentals including:
- Scala is a programming language for the JVM that supports both object-oriented and functional paradigms.
- It defines variables, values, lazy values, functions, types, classes, objects, traits, and higher-order functions.
- Classes can extend other classes and traits, allowing for multiple inheritance. Objects are used as singletons.
- Functional concepts like immutability, anonymous functions, and higher-order functions are supported.
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.
This document provides an introduction to Swift 2 and covers various Swift language basics including variables and constants, arrays, optionals, functions and closures, classes, structs, enums, protocols, and generics. It discusses syntax, properties, methods and gives examples for each language feature. The document is organized into sections for each language concept and provides code samples and explanations.
This the slide stack for the two videos on Data types in my YouTube series on JavaScript. The videos are at https://www.youtube.com/watch?v=UAtJXkGggOU and https://www.youtube.com/watch?v=H2sjsGZyYaw
The document discusses how to work with Cocoa and Objective-C from Swift. It covers importing Objective-C frameworks, interacting with Objective-C APIs such as initializers, properties, and methods, type remapping between Objective-C and Swift types, working with AnyObject and optionals, blocks, and integrating Swift code with Interface Builder using outlets and actions.
Scala is a powerful language for the JVM that is compatible with JDK 1.5+. It is a functional language maintained by Typesafe along with the community. Scala compiles to JVM bytecode like Java but has features like objects, traits, pattern matching and functional programming. James Gosling, the creator of Java, said that if he were to pick a language other than Java today, it would be Scala.
This document discusses refactoring Scala code to improve quality and maintainability. It provides examples of issues like stringly typed code, abuse of collections, and poor scoping. The presentation recommends addressing these by using case classes instead of tuples, parsing values instead of passing raw strings, giving intermediate steps meaningful names, and separating logic and data through traits or type classes. Well-scoped code with a small public API and private implementation details is emphasized.
Miles Sabin Introduction To Scala For Java DevelopersSkills Matter
Scala is a programming language that blends object-oriented and functional programming styles. It is designed to interoperate with Java code and runs on the Java Virtual Machine. Some key features of Scala include case classes, pattern matching, traits for mixing behavior, and immutable data structures. Scala code compiles to Java bytecode, allowing seamless use of Java libraries and tools.
Swift provides several differences from Java/Android for language features, including:
1. Access control is handled through private, internal, open instead of private, default, protected, public. Optionals and nil are used to represent empty or missing values.
2. Closures allow blocks of code to be passed around as first-class functions, similar to blocks in Objective-C. Collection types use arrays and dictionaries instead of lists.
3. Control flow includes range operators for for loops and switch statements without break. Escaping closures can capture values from the current scope and are used for callbacks.
Scala Intro training @ Lohika, Odessa, UA.
This is a basic Scala Programming Language overview intended to evangelize the language among any-language programmers.
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.
C# programs use namespaces and classes. A class defines methods and variables. C# supports inheritance, interfaces, structs, and enums. The main method runs code. Common data types include primitive types like int and reference types like string. C# can read input, perform math operations, and conditionally execute code using if/else statements. Methods can pass parameters by value or reference.
This document provides an introduction to typeclasses in Scala and functional programming. It defines typeclasses as a way to define functions that can have different implementations depending on the type of data. The document then gives examples of using typeclasses for serialization and numeric operations. It discusses how typeclasses relate to category theory and how higher kinded types allow generalizing over type constructors. Pros of typeclasses are given as decoupling functionality from types and extensibility, while a potential con is increased code complexity.
Scala has many symbols, operators, and syntax elements that can be confusing for beginners. The underscore character in particular takes on many different meanings depending on context. Type erasure in Scala means that types are not always available at runtime. Initialization order of vals follows a defined rule where traits are initialized before subclasses. Having a deep understanding of Scala's semantics is important to explain unexpected behavior.
The document provides tips and tricks for intermediate Scala developers. It discusses using type aliases to simplify APIs and type signatures. ClassTags are mentioned as a way to access reflection information without runtime overhead. Auto-lifted partial functions allow using partial functions without explicitly specifying they are partial. NoStackTrace is introduced as a way to create exceptions without stack traces for performance. Type classes are explained as a design pattern using implicits to add capabilities to types. Context bounds and implicitly make working with type classes cleaner. @ImplicitNotFound provides helpful error messages. Low priority default implicits are suggested for providing type class instances without causing issues for user-defined instances.
This document provides a summary and analysis of a research study on the verbal and visual analysis of women's magazine websites from Brazil and the United States.
The study analyzed articles from the websites of the Brazilian magazine Nova and the American magazine Cosmopolitan, focusing on articles from the "Sex and Love" sections. Both verbal and visual elements of selected articles were analyzed using theories of Systemic Functional Linguistics, Critical Discourse Analysis, and gender studies.
The conclusion suggests that (1) the websites present traditional views of women's roles and responsibilities in relationships, (2) the magazines establish intimate relationships with readers to gain trust, and (3) the magazines use persuasive discourse strategically to attract more readers and
The Scottish Information Literacy Projectguest9f3d11
The Scottish Information Literacy Project aims to develop information literacy in Scotland through creating a national framework, partnerships, and research. The project has drafted an information literacy framework, conducted workplace studies, and promoted information literacy integration in education. Next steps include expanding the framework, developing training modules, and furthering partnerships in various sectors including workplaces and health.
Phantom types allow using the type system to enforce correctness by distinguishing types that are never instantiated at runtime. The summary describes how phantom types can be used to define a Form trait where the type parameter distinguishes validated and unvalidated form data, ensuring validation is performed before accessing validated data. This provides static type safety without runtime overhead from phantom types, which are never instantiated.
Scala collections provide a uniform approach to working with data structures. They are generic, immutable, and support higher-order functions like map and filter. The core abstractions are Traversable and Iterable, with subclasses including lists, sets, and maps. Collections aim to be object-oriented, persistent, and follow principles like the uniform return type. They allow fluent, expressive ways to transform, query, and manipulate data in a functional style.
Presentation at NY Scala Enthusiasts Meetup on 6/14/2010. Covers techniques for using Scala's flexible syntax and features to design internal DSLs and wrappers.
This document discusses various concepts related to polymorphism in Scala, including:
- Different types of polymorphism like subtyping, parametric polymorphism, and type classes.
- Examples of polymorphism patterns like duck typing, cake patterns, chaining polymorphism, and type constructors.
- How type classes enable retroactive polymorphism and dependency injection through implicit parameters.
This talk was delivered at JavaOne 2013, together with Andrzej Grzesik. We mention the new Date APIs, changes to Collections as well as Streams APIs and of course... Lambdas!
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
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.
Short lightning talk about the HBase plugin for Akka Persistence and how it's how key design was specifically tuned for increasing numeric sequential idenfitiers, so that the cluster can be utilised properly.
https://github.com/ktoso/akka-persistence-hbase
Need for Async: Hot pursuit for scalable applicationsKonrad Malawski
This document discusses asynchronous processing and how it relates to scalability and performance. It begins with an introduction on why asynchronous processing is important for highly parallel systems. It then covers topics like asynchronous I/O, scheduling, latency measurement, concurrent data structures, and techniques for distributed systems like backup requests and combined requests. The overall message is that asynchronous programming allows more efficient use of resources through approaches like non-blocking I/O, and that understanding these principles is key to building scalable applications.
A gentle introduction on the use of implicit values & conversions in Scala.
It also introduces some design patterns for which implicit(s) are the building blocks.
http://blog.stratio.com/developers-guide-scala-implicit-values-part/
Konrad Malawski presented on refactoring legacy code. The presentation covered refactoring to patterns, holding a legacy code retreat to refactor an existing Java codebase together, popular refactorings like extract method and rename, and tips for when refactoring like using keyboard shortcuts to find errors and hints. The retreat approach involves cycling between 25 minutes of coding to refactor the codebase followed by 5 minutes of retrospective.
Just a few simple slides for a presentation at Kraków's Scala User Group. The rest of the session is live coding where we reimplement a tiny subset of Rogue, Foursquares MongoDB DSL.
RubyConf Portugal 2014 - Why ruby must go!Gautam Rege
The document discusses the Go programming language and how it differs from Ruby. It provides examples of Go code demonstrating type declarations, embedded types, exported variables and functions, and variable redeclaration. It also discusses some concepts in Go like interfaces, channels, and concurrency that are different from Ruby. The document suggests that Go teaches programmers awareness about variables, types, and errors that can improve Ruby code.
MongoDB World 2019: BSON Transpilers: Transpiling from Any Language to Any La...MongoDB
This talk will go through the technical design of our anything-to-anything transpiler and teach attendees how they can add their own favorite language to Compass. We'll talk about classic compiler design principles and how we leveraged various technologies to create a dynamic, extensible transpiler.
This document provides an introduction to the Scala programming language. It begins with a brief history of Scala and overview of its core concepts like vals, classes, objects, traits, and functions. It also covers intermediate concepts like pattern matching, Option, XML and Futures. The document discusses Scala's support for functional and object-oriented programming and how it compiles to Java bytecode. It provides examples of using Scala's collections and control structures and describes features like classes, objects, traits and case classes.
The document discusses literal-based singleton types in Scala. Some key points:
1. Literal-based singleton types allow types like "panda!".type and 42.type, treating literals as singleton types. This enables more consistency in Scala type systems.
2. Examples are provided showing how literal-based singleton types can be used for records, residues, and ranged values.
3. The document discusses how literal-based singleton types could improve dependent types in Scala by enabling types like ((x: Int) => x > 23 && x < 42).type. This may allow integration with SMT solvers like Z3 for compile-time checking of dependent types.
This document provides an overview of JavaScript development challenges and how EcmaScript 2015 and TypeScript address these challenges. It discusses the rise of JavaScript, traditional development challenges like lack of structuring capabilities and static types, new features in EcmaScript 2015 like arrow functions and classes, and how TypeScript adds static types and interfaces to provide benefits for large application development. The document contains code examples to demonstrate various JavaScript and TypeScript language features.
Akka persistence == event sourcing in 30 minutesKonrad Malawski
Akka 2.3 introduces akka-persistence, a wonderful way of implementing event-sourced applications. Let's give it a shot and see how DDD and Akka are a match made in heaven :-)
This document discusses TypeScript, a superset of JavaScript that adds optional static typing and class-based object-oriented programming. It allows developers to gradually introduce typing into JavaScript code for improved productivity and catch errors early. The document covers TypeScript features like interfaces, classes, modules, type definitions, and comparisons to alternatives like CoffeeScript and Dart. It concludes that TypeScript allows gradual adoption of typing while following the future ECMAScript standard.
The document discusses Scala, a programming language that runs on the Java Virtual Machine but incorporates features from object-oriented and functional programming. It provides examples of Scala's type system, object model using traits and mixins, built-in support for domain specific languages like XML and actors, and how the actor model implements concurrency by treating objects as isolated message-passing actors.
The document provides an overview of reflection in Go. It discusses the laws of reflection, interfaces, and the reflect package. The key points covered are:
- The three laws of reflection: reflection goes from interface value to reflection object, reflection object to interface value, and to modify a reflection object the value must be settable.
- Interfaces are statically checked and allow for dynamic dispatch via type assertions.
- The reflect package allows examining and modifying values and types at runtime. It provides utilities for querying types and values as well as setting fields and calling methods dynamically.
- The Value type provides methods for accessing and modifying values reflectively and the Type type provides information about Go types.
The document discusses object-oriented programming concepts related to inheritance in Java, including:
- Inheritance allows a subclass to inherit attributes and behaviors from its superclass. Subclasses can add, use, or override inherited functionality.
- Abstract classes can contain abstract methods that are declared but not defined. Subclasses must define all abstract methods to be instantiated. Abstract classes prevent direct instantiation.
- Polymorphism allows calling the same method on different object types, with the actual implementation determined at runtime based on the object's type. Method overriding in subclasses enables polymorphism.
- Final methods and classes prevent overriding and extension, respectively. This can improve security or performance. All non-static methods are virtual by default
Building DSLs with Xtext - Eclipse Modeling Day 2009Heiko Behrens
Slides of Eclipse Modeling Day in New York and Toronto http://wiki.eclipse.org/Eclipse_Modeling_Day
Motivation of specific tools with apple corer analogy, Example of domain-specific language (chess notation), introduction to Xtext with demo plus outlook
The document summarizes key concepts about optionals in Swift, including:
Optionals represent possibly missing values and can be nil. Non-optional types cannot be nil. Functions can return optionals to indicate possible missing values. Optionals must be unwrapped to access their underlying value. Forced unwrapping with ! should be avoided. Optional binding with if let is safer for testing and unwrapping. Optional chaining with ? allows working with chained optionals in a concise way.
This document provides an overview of JavaScript, including its uses, syntax, data types, operators, and objects. JavaScript is an object-based scripting language used to program the behavior of web pages. It allows for client-side validation, dynamic drop-down menus, displaying data and time, and other interactive effects. JavaScript code can be embedded directly in HTML using <script> tags or linked externally. The core data types include numbers, strings, Booleans, arrays, and objects. Objects are similar to arrays but use named indexes instead of numbered indexes. Key JavaScript concepts covered include variables, literals, functions, conditionals, and more.
Java/Scala Lab 2016. Руслан Шевченко: Несколько трюков scala-разработки, приг...GeeksLab Odessa
16.4.16 Java/Scala Lab
Upcoming events: goo.gl/I2gJ4H
Рассказ о сравнительно простых техниках программирования в scala, редко применяющихся за пределами широкоизвестных библиотек из-за ореола таинственности вокруг них, вызванных чрезмерным употреблением математической терминологии при их первоначальном описании.
This document discusses various aspects of the Swift programming language such as handling optionals, initialization rules, and value types vs reference types. It provides examples of how Swift avoids null references by using optionals, describes Swift's strict initialization rules to prevent issues, and explains how value types like structs provide immutability when declared as constants unlike reference types.
Milano JS Meetup - Gabriele Petronella - Codemotion Milan 2016Codemotion
TypeError: “x" is not a function. Quale sviluppatore JavaScript non ha mai incontrato questo errore, magari su un sito in produzione? Non sarebbe invece fantastico intercettare questi errori durante lo sviluppo? In questo talk presenteremo Flow, uno static typechecker per javascript che ci può aiutare a scrivere codice più affidabile e sicuro. Il talk conterrà esempi concreti e demo. ATTENZIONE: può causare forti sbalzi di JavaScript fatigue!
The document provides an overview of the basics of C# 2008 .NET 3.0/3.5, including the basic structure of a C# program, namespaces, classes, methods, variables, data types, operators, flow control, arrays, namespaces, console input/output, and comments. It discusses key concepts such as object-oriented programming fundamentals, console applications in Visual Studio 2008, and more advanced topics such as checked and unchecked operators.
WDB005.1 - JavaScript for Java Developers (Lecture 1)Igor Khotin
This document provides an overview of JavaScript for Java developers. It discusses the origins and history of JavaScript, including how it was influenced by Java syntax but developed separately. The document outlines similarities and differences between JavaScript and Java, as well as features of JavaScript like dynamic typing, prototypes, closures, and this keyword context. It recommends leveraging good JavaScript features like objects, functions, and JSON while avoiding bad patterns like direct DOM manipulation. Resources for further learning are also provided.
This document provides an overview of advanced TypeScript concepts and best practices. It discusses the TypeScript toolchain and environment, ES2015+ features like let, modules, and unit testing. It covers the TypeScript type system including type inference, annotations, and strict checking. Other topics include decorators, structural typing, destructuring, and the differences between TypeScript and JavaScript.
Networks and Types - the Future of Akka @ ScalaDays NYC 2018Konrad Malawski
A look into the upcoming soon-to-be-stable typed Actor APIs in Akka. Shown at Scala Days NYC 2018, while Akka 2.5.13 was out. Looking at what will become the stable Akka Typed.
Konrad Malawski presents on Akka Typed Actors and building distributed systems with Akka. Some key points:
- Akka Typed Actors introduce behaviors and protocols to make actors more type-safe compared to untyped actors. Behaviors can change state and return new behaviors.
- A sample burglar alarm actor is implemented as a state machine using behaviors and protocols to handle enabled and disabled states.
- Distributed systems can be built using Akka Cluster, where actors on different nodes can communicate. A distributed burglar alarm example uses a receptionist to discover actor references across nodes.
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in'tKonrad Malawski
A talk about the implications and context around API design. How APIs come to be and how to understand them. This talk was delivered as opening keynote, setting the tone, for the ScalaSwarm conference in Porto, Portugal in 2017.
Konrad Malawski gave a talk at Scala Days CPH 2017 about the current state and future direction of Akka. He discussed how Akka is moving from the actor model to reactive streams and Akka Streams for better concurrency and distribution capabilities. Akka Cluster provides robust membership and fault tolerance for distributed actors across many nodes, while Cluster Sharding enables easy sharding of data and work across a cluster. The talk outlined Akka's past successes and hinted at upcoming improvements to further "do better than that."
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYCKonrad Malawski
Intense 3 hour workshop covering Akka Actors, Cluster, Streams, HTTP and more. Including very advanced patterns.
Presented with Henrik Engstrom at O'Reilly Software Architecture Conference in New York City in 2017
Akka-chan's Survival Guide for the Streaming WorldKonrad Malawski
In this talk we dive into the various kinds of "Streaming", what it actually means, where to use which technology and specifically take a look at Akka Streams and their specific use case and strengths.
This document summarizes a presentation about Akka streams, which is a toolkit for building highly concurrent, distributed, and resilient message-driven applications on the JVM. It provides asynchronous back pressured stream processing using sources, sinks, and flows. Key features include actors for concurrency, clustering for location transparency and resilience, and integration with technologies like Kafka, Cassandra and HTTP. The document outlines how Akka streams work, how to write stream applications, and how streams can be used for scenarios like HTTP requests/responses and streaming data. It encourages contributions to Akka and discusses next steps like improved remoting and more stream connectors.
This document summarizes Konrad Malawski's talk on reactive programming and related topics. Konrad discusses reactive streams, Akka toolkit for building concurrent applications, actors model for concurrency, and how circuit breakers can be used as a substitute for flow control. He also talks about the origins and development of reactive streams specification to provide a common set of semantics for backpressure.
Reactive Streams are a cross-company initiative first ignited by Lightbend in 2013, soon to be joined by RxJava and other implementations focused on solving a very similar problem: asynchronous non-blocking stream processing, with guaranteed over-flow protection. Fast forward to 2016 and now these interfaces are part of JSR-266 and proposed for JDK9.
In this talk we'll first disambiguate what the word Stream means in this context (as it's been overloaded recently by various different meanings), then look at how its protocol works and how one might use it in the real world showing examples using existing implementations.
We'll also have a peek into the future, to see what the next steps for such collaborative protocols and the JDK ecosystem are in general.
End to End Akka Streams / Reactive Streams - from Business to SocketKonrad Malawski
The Reactive Streams specification, along with its TCK and various implementations such as Akka Streams, is coming closer and closer with the inclusion of the RS types in JDK 9. Using an example Twitter-like streaming service implementation, this session shows why this is a game changer in terms of how you can design reactive streaming applications by connecting pipelines of back-pressured asynchronous processing stages. The presentation looks at the example from two perspectives: a raw implementation and an implementation addressing a high-level business need.
The document discusses Akka, a toolkit for building highly concurrent, distributed, and resilient message-driven applications on the JVM. It describes key components of Akka including actors for concurrency, clusters for location-transparent resilient applications, persistence for event sourcing, and HTTP for asynchronous reactive servers. It also discusses the actor model of concurrent computation and related topics like reactive streams and advantages of asynchronous messaging.
Akka Streams in Action @ ScalaDays Berlin 2016Konrad Malawski
Konrad Malawski will give a presentation on streams and Reactive Streams in action at ScalaDays Berlin. He works on the Akka team and helped develop the Reactive Streams specification and test compatibility kit (TCK). The presentation will include building examples with pre-release Akka Streams functionality and exploring the history and goals of Reactive Streams.
The things we don't see – stories of Software, Scala and AkkaKonrad Malawski
The document discusses some of the unseen aspects of software, programming languages, and distributed systems. It covers topics like tradeoffs that must be made in software but are not visible, the impact of blocking code in Akka applications, and how traits are represented differently in Scala depending on the version. Messages are emphasized as a core abstraction in Akka rather than method calls. Some hidden features of ScalaDoc are also shown.
[Japanese] How Reactive Streams and Akka Streams change the JVM Ecosystem @ R...Konrad Malawski
Japanese subtitles by Yugo Maede-san, thank you very much. Japanese subtitled version of the "How Reactive Streams and Akka Streams change the JVM Ecosystem". http://www.slideshare.net/ktoso/how-reactive-streams-akka-streams-change-the-jvm-ecosystem
This document contains the slides from a talk given by Konrad Malawski on the "Tao/Zen of Programming" using Akka. Some of the key points discussed include:
- Actors are meant to work together and each actor should focus on a single responsibility. Having only one actor limits its capabilities.
- Actors should be structured in a hierarchy with parent-child relationships to allow for supervision. Actors should also be named meaningfully based on their purpose.
- Blocking operations can starve other actors by monopolizing shared resources. Blocking code needs to be isolated on dedicated dispatchers.
- Messages should be processed asynchronously using for/flatMap instead of awaiting futures to avoid blocking
The document provides an overview of asynchronous processing and how it relates to scalability and performance. It discusses key topics like sync vs async, scheduling, latency measurement, concurrent vs lock-free vs wait-free data structures, I/O models like IO, AIO, NIO, zero-copy, and sorting algorithms. It emphasizes picking the right tools for the job and properly benchmarking and measuring performance.
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka StreamsKonrad Malawski
The document discusses Akka Typed, a new approach to typed actors in Akka. Some key differences from regular Akka actors include:
- Behaviors are used instead of receive partial functions
- Protocols are made explicit through message types and ActorRef types
- Become is replaced by returning the next behavior
- The sender reference is replaced by passing the replyTo in message types
- Actor systems and actor refs are typed based on message types
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Aqusag Technologies
In late April 2025, a significant portion of Europe, particularly Spain, Portugal, and parts of southern France, experienced widespread, rolling power outages that continue to affect millions of residents, businesses, and infrastructure systems.
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul
Artificial intelligence is changing how businesses operate. Companies are using AI agents to automate tasks, reduce time spent on repetitive work, and focus more on high-value activities. Noah Loul, an AI strategist and entrepreneur, has helped dozens of companies streamline their operations using smart automation. He believes AI agents aren't just tools—they're workers that take on repeatable tasks so your human team can focus on what matters. If you want to reduce time waste and increase output, AI agents are the next move.
Role of Data Annotation Services in AI-Powered ManufacturingAndrew Leo
From predictive maintenance to robotic automation, AI is driving the future of manufacturing. But without high-quality annotated data, even the smartest models fall short.
Discover how data annotation services are powering accuracy, safety, and efficiency in AI-driven manufacturing systems.
Precision in data labeling = Precision on the production floor.
Web & Graphics Designing Training at Erginous Technologies in Rajpura offers practical, hands-on learning for students, graduates, and professionals aiming for a creative career. The 6-week and 6-month industrial training programs blend creativity with technical skills to prepare you for real-world opportunities in design.
The course covers Graphic Designing tools like Photoshop, Illustrator, and CorelDRAW, along with logo, banner, and branding design. In Web Designing, you’ll learn HTML5, CSS3, JavaScript basics, responsive design, Bootstrap, Figma, and Adobe XD.
Erginous emphasizes 100% practical training, live projects, portfolio building, expert guidance, certification, and placement support. Graduates can explore roles like Web Designer, Graphic Designer, UI/UX Designer, or Freelancer.
For more info, visit erginous.co.in , message us on Instagram at erginoustechnologies, or call directly at +91-89684-38190 . Start your journey toward a creative and successful design career today!
Social Media App Development Company-EmizenTechSteve Jonas
EmizenTech is a trusted Social Media App Development Company with 11+ years of experience in building engaging and feature-rich social platforms. Our team of skilled developers delivers custom social media apps tailored to your business goals and user expectations. We integrate real-time chat, video sharing, content feeds, notifications, and robust security features to ensure seamless user experiences. Whether you're creating a new platform or enhancing an existing one, we offer scalable solutions that support high performance and future growth. EmizenTech empowers businesses to connect users globally, boost engagement, and stay competitive in the digital social landscape.
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveScyllaDB
Want to learn practical tips for designing systems that can scale efficiently without compromising speed?
Join us for a workshop where we’ll address these challenges head-on and explore how to architect low-latency systems using Rust. During this free interactive workshop oriented for developers, engineers, and architects, we’ll cover how Rust’s unique language features and the Tokio async runtime enable high-performance application development.
As you explore key principles of designing low-latency systems with Rust, you will learn how to:
- Create and compile a real-world app with Rust
- Connect the application to ScyllaDB (NoSQL data store)
- Negotiate tradeoffs related to data modeling and querying
- Manage and monitor the database for consistently low latencies
IT help desk outsourcing Services can assist with that by offering availability for customers and address their IT issue promptly without breaking the bank.
Spark is a powerhouse for large datasets, but when it comes to smaller data workloads, its overhead can sometimes slow things down. What if you could achieve high performance and efficiency without the need for Spark?
At S&P Global Commodity Insights, having a complete view of global energy and commodities markets enables customers to make data-driven decisions with confidence and create long-term, sustainable value. 🌍
Explore delta-rs + CDC and how these open-source innovations power lightweight, high-performance data applications beyond Spark! 🚀
Procurement Insights Cost To Value Guide.pptxJon Hansen
Procurement Insights integrated Historic Procurement Industry Archives, serves as a powerful complement — not a competitor — to other procurement industry firms. It fills critical gaps in depth, agility, and contextual insight that most traditional analyst and association models overlook.
Learn more about this value- driven proprietary service offering here.
HCL Nomad Web – Best Practices and Managing Multiuser Environmentspanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-nomad-web-best-practices-and-managing-multiuser-environments/
HCL Nomad Web is heralded as the next generation of the HCL Notes client, offering numerous advantages such as eliminating the need for packaging, distribution, and installation. Nomad Web client upgrades will be installed “automatically” in the background. This significantly reduces the administrative footprint compared to traditional HCL Notes clients. However, troubleshooting issues in Nomad Web present unique challenges compared to the Notes client.
Join Christoph and Marc as they demonstrate how to simplify the troubleshooting process in HCL Nomad Web, ensuring a smoother and more efficient user experience.
In this webinar, we will explore effective strategies for diagnosing and resolving common problems in HCL Nomad Web, including
- Accessing the console
- Locating and interpreting log files
- Accessing the data folder within the browser’s cache (using OPFS)
- Understand the difference between single- and multi-user scenarios
- Utilizing Client Clocking
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxAnoop Ashok
In today's fast-paced retail environment, efficiency is key. Every minute counts, and every penny matters. One tool that can significantly boost your store's efficiency is a well-executed planogram. These visual merchandising blueprints not only enhance store layouts but also save time and money in the process.
Big Data Analytics Quick Research Guide by Arthur MorganArthur Morgan
This is a Quick Research Guide (QRG).
QRGs include the following:
- A brief, high-level overview of the QRG topic.
- A milestone timeline for the QRG topic.
- Links to various free online resource materials to provide a deeper dive into the QRG topic.
- Conclusion and a recommendation for at least two books available in the SJPL system on the QRG topic.
QRGs planned for the series:
- Artificial Intelligence QRG
- Quantum Computing QRG
- Big Data Analytics QRG
- Spacecraft Guidance, Navigation & Control QRG (coming 2026)
- UK Home Computing & The Birth of ARM QRG (coming 2027)
Any questions or comments?
- Please contact Arthur Morgan at [email protected].
100% human made.
Semantic Cultivators : The Critical Future Role to Enable AIartmondano
By 2026, AI agents will consume 10x more enterprise data than humans, but with none of the contextual understanding that prevents catastrophic misinterpretations.
This is the keynote of the Into the Box conference, highlighting the release of the BoxLang JVM language, its key enhancements, and its vision for the future.
Unlocking the Power of IVR: A Comprehensive Guidevikasascentbpo
Streamline customer service and reduce costs with an IVR solution. Learn how interactive voice response systems automate call handling, improve efficiency, and enhance customer experience.
7. Types in Scala
Types are:
!
static
class Robot!
class Human !
!
val human: Human = new Human!
val roman: Human = new Robot!
!
!
error: type mismatch;!
!
found
: Robot!
!
required: Human!
!
val robot: Human = new Robot!
!
^
8. Types in Scala
Types are:
!
static
strong
var two = 2!
two = "two"!
!
error: type mismatch;!
found
: String("two")!
required: Int!
two = "two"!
^
9. Types in Scala
Types are:
!
static
strong
inferred
!
val n = 2!
n.getClass.toString == "int"!
!
!
!class Human!
!val p = new Human!
p.getClass.toString == "class Human"
10. Types in Scala
Types are:
!
val n: Int = 2
!
static
strong
inferred
annotated after :
!
!
!
def add(a: Int, b: Int): Int!
12. Types with Traits
Traits are:
!
interfaces
!
implementation:
trait HasName { !
def name: String!
}!
!
!
class Human extends HasName {!
def name = ""!
}
class Human(val name: String) !
extends HasName!
13. Types with Traits
Traits are:
!
interfaces
with implementation
!
trait HasName { def name = "name" }!
!
object Human extends HasName!
!
Human.name == "name"!
14. Types with Traits
Traits are:
!
interfaces
with implementation
can be “mixed in”
trait Robot!
trait Humanoid!
trait Lasers!
!
object X extends Robot !
with Humanoid!
with Lasers!
!
Multiple inheritance panic?!
15. Type linearization
trait Robot extends Lasers!
trait Humanoid!
trait Lasers
object X extends Robot !
with Humanoid!
with Lasers
// type linearization:!
X Robot Humanoid Lasers
// reverse!
X Lasers Humanoid Robot! !
!
// expand!
X Lasers Humanoid Robot Lasers
// right-keep-unique!
X Lasers Humanoid Robot Lasers!
X
Humanoid Robot Lasers
// add common!
X
Humanoid Robot Lasers Object Any
16. Type linearization
trait Robot extends Lasers!
trait Humanoid!
trait Lasers
object X extends Robot !
with Humanoid!
with Lasers
// don’t trust me, trust the compiler:!
import scala.reflect.runtime.universe._!
typeOf[X.type].baseClasses.map(_.name).mkString(“ extends ")!
!
// output:!
X extends Humanoid !
extends Robot extends Lasers !
extends Object extends Any!
17. Type linearization
reordered slightly
trait Robot extends Lasers!
trait Humanoid!
trait Lasers
object X extends Humanoid!
with Lasers!
with Robot
// type linearization:!
X Humanoid Lasers Robot
// reverse!
X Robot Lasers Humanoid! !
!
// expand!
X Robot Lasers Lasers Humanoid
// right-keep-unique!
X Robot Lasers Lasers Humanoid!
X Robot
Lasers Humanoid
// add common!
X Robot
Lasers Humanoid Object Any
18. Type linearization
trait Robot extends Lasers!
trait Humanoid!
trait Lasers
object X extends Humanoid!
with Lasers!
with Robot
// don’t trust me, trust the compiler:!
import scala.reflect.runtime.universe._!
typeOf[X.type].baseClasses.map(_.name).mkString(“ extends ")!
!
// output:!
X extends Robot !
extends Lasers extends Humanoid!
extends Object extends Any!
21. Type Refinement
trait Human!
trait Robot
val human: Human = new Human {}!
val roman: Human = new Robot with Human!
plain trait composition
type refinement
Waaah!
It’s a robot with human traits!
32. Type Variance
class C[T] // in-variant!
class C[+T] // co-variant!
class C[-T] // contra-variant!
33. Type Bounds (still variance)
class Parent!
class Bottom extends Parent!
!
Type Bounds
!
Parent >: Bottom
Bottom <: Parent
Parent =:= Parent
// parent is “more” general!
// bottom is “less” general!
// parent is “equal” parent
34. Type Variance
class C[T]
// in-variant
val x: C[Parent] = new C[Parent]!
!
val x: C[Parent] = new C[Bottom]!
error: type mismatch; found: C[Bottom] required: C[Parent]!
Note: Bottom <: Parent, but class C is invariant in type A.!
You may wish to define A as +A instead. (SLS 4.5)!
!
val x: C[Bottom] = new C[Parent]!
error: type mismatch; found: C[Parent] required: C[Bottom]!
Note: Parent >: Bottom, but class C is invariant in type A.!
You may wish to define A as -A instead. (SLS 4.5)!
35. Type Variance
class C[+T]
// co-variant
val x: C[Parent] = new C[Parent]!
!
val x: C[Parent] = new C[Bottom]!
!
val x: C[Bottom] = new C[Parent]!
error: type mismatch; found: C[Parent] required: C[Bottom]!
!
!
36. Type Variance
class C[-T]
// contra-variant
val x: C[Parent] = new C[Parent]!
!
val x: C[Parent] = new C[Bottom]!
error: type mismatch; found: C[Bottom] required: C[Parent]!
!
val x: C[Bottom] = new C[Parent]!
!
!
43. Type Member
Same goal as
Type Parameter
if List was using Type Params
trait StringList!
extends List[String]
=>
trait StringList !
extends List {!
type A = String!
}
if List was using Type Members
44. Type Member + Type Bound
Same as + / - variance
trait List {!
type A!
}
=>
trait NumbersList extends List {!
type A <: Number!
}
trait IntegerList extends NumbersList {!
type A = Integer!
}
trait FailList extends NumbersList {!
type A = Human // Human is not <: Number!!
}
46. Without Type Alias
“1st” and “2nd” type param
ALL HOPE IS LOST!
object `bytes -> string` !
extends Builder[Array[Byte], String] {!
!
def make(in: Array[Byte]): String = new String(in)!
}!
47. Without Type Alias
“1st” and “2nd” type param
Some meaning is lost!
object `bytes -> string` !
extends Builder[Array[Byte], String] {!
!
def make(in: Array[Byte]): String = new String(in)!
}!
48. Type Alias
From Type Parameter to Type Members
trait Builder[From, To]
=>
trait Builder {!
type From!
type To!
def make(in: From): To!
}
49. Type Alias
trait Builder { type From; type To; def make(in: From): To }!
trait StringBuilder extends Builder {!
type To = String!
}
trait FromBytesBuilder extends Builder {!
type From = Array[Byte]!
}
object `bytes -> string` extends Builder!
with FromBytesBuilder!
with StringBuilder {!
!
def make(in: From): To = new String(in)!
}!
50. Type Alias
trait Builder { type From; type To; def make(in: From): To }!
object `bytes -> string` extends Builder {!
type From = Array[Bytes]!
type To = String!
!
def make(in: From): To = new String(in)!
}!
61. Phantom Types
val closed = Door()!
// closed: Door[Closed]!
!
val opened = closed.open()!
// opened: Door[Open]
62. Phantom Types
val closed = Door()!
// closed: Door[Closed]!
!
val opened = closed.open()!
// opened: Door[Open]!
!
val closedAgain = opened.close()!
// closedAgain: Door[Closed]!
63. Phantom Types
val closed = Door()!
// closed: Door[Closed]!
!
val opened = closed.open()!
// opened: Door[Open]!
!
val closedAgain = opened.close()!
// closedAgain: Door[Closed]!
!
closed.close()!
error: type arguments [Closed] do not conform to method
close's type parameter bounds [T >: Closed <: Open]
64. Phantom Types
val closed = Door()!
// closed: Door[Closed]!
!
val opened = closed.open()!
// opened: Door[Open]!
!
val closedAgain = opened.close()!
// closedAgain: Door[Closed]!
!
closed.close()!
error: type arguments [Closed] do not conform to method
close's type parameter bounds [T >: Closed <: Open]!
!
opened.open()!
error: type arguments [Open] do not conform to method !
open's type parameter bounds [T >: Open <: Closed]
67. Kind: x -> x
Type Constructor
List[+A]!
scala> :kind -v List!
!
scala.collection.immutable.List's kind is F[+A]!
* -(+)-> *!
!
This is a type constructor: !
a 1st-order-kinded type.
68. Kind:
(x -> x) -> x
Higher Kind
import language.higherKinds!
!
class Functor[M[_]]!
scala> :kind -v Functor[List]!
!
Functor's kind is X[F[A]]!
(* -> *) -> *!
!
This is a type constructor that takes type constructor(s): !
a higher-kinded type
81. Type Class
// no type classes yet!
trait Writeable[Out] {!
def write: Out!
}!
!
case class Num(a: Int, b: Int) extends Writeable[Json] {!
def write = Json.toJson(this)!
}!
82. Type Class
trait Writes[In, Out] {
def write(in: In): Out!
}!
!
!
Separated “what” from “who”
trait Writeable[Self] {
def writeAs[Out]()!
(implicit writes: Writes[Self, Out]): Out =!
! ! ! !
writes write this!
}!
!
!
!
implicit val jsonNum = Writes[Num, Json] {!
! def write(n: Num) = Json.toJson(n)!
!
}!
!
case class Num(a: Int) extends Writeable[Num]
83. Type Class
trait Writes[In, Out] {
def write(in: In): Out!
}!
!
!
trait Writeable[Self] {
def writeAs[Out]()!
(implicit writes: Writes[Self, Out]): Out =!
! ! ! !
writes write this!
}!
Implicit parameter
!
!
!
implicit val jsonNum = Writes[Num, Json] {!
! def write(n: Num) = Json.toJson(n)!
!
}!
!
Implicit value
case class Num(a: Int) extends Writeable[Num]
84. Type Class
implicit val jsonNum = Writes[Num, Json] {
def (n1: Num, n2: Num) = n1.a < n1.!
}!
!
case class Num(a: Int) extends Writeable[Num]
85. Type Class
implicit val jsonNum = Writes[Num, Json] {
def (n1: Num, n2: Num) = n1.a < n1.!
}!
!
case class Num(a: Int) extends Writeable[Num]
you write:
val jsonNum = Num(12).writeAs[Json]()!
86. Type Class
implicit val jsonNum = Writes[Num, Json] {
def (n1: Num, n2: Num) = n1.a < n1.!
}!
!
case class Num(a: Int) extends Writeable[Num]
you write:
val jsonNum = Num(12).writeAs[Json]()!
compiler does:
val jsonNum = Num(12).writeAs[Json]()(jsonNum)!
89. Other Types of Types
type annotation
case class
type projection
unified type system
value class
self recursive type
bottom types
type class
type constructor
type variance
universal trait
specialized type
traits
self type annotation
dynamic type
type refinements
phantom type
existential type
type alias
structural type
type lambda
abstract type member
path dependent type
algebraic data type