Functional programming in Scala
December 21, 2022 2022-12-21 16:45Functional programming in Scala
Functional programming in Scala
This course takes advantage of functional programming to make the most of the Scala programming language. It offers an introduction to the basic mechanisms of generics, implicits and lambas, as well as an in-depth analysis of three functional programming techniques which are instrumental to write idiomatic Scala code: algebraic data types, higher-order functions and type classes.
Audience
- Non-Scala programmers willing to jump into the Scala bandwagon and make the most of Scala through functional programming techniques
- Senior programmers willing to write idiomatic Scala code and be able to explain the advantages of functional programming techniques.
Course Topics
- Topics: Algebraic data types, Type classes, Higher-order functions, Scala
- References:
What students will learn
- Get used to the strongly-typed discipline of Scala
- Introduce the basic FP techniques needed to develop efficient and modular code in Scala
- Being able to discuss and explain the advantages of functional abstractions (type classes, algebraic data types and higher-order functions)
-
Module 1: Functional Scala (4 hours)
This module introduces the functional programming support provided out-of-the-box by Scala. In particular, it reviews the important concepts of compositionality and currying, and it shows how functional abstractions are mapped into object-oriented constructs.
-
Module 2: Functions and Algebraic data types (4 hours)
This module focuses on the most basic way to represent data types in functional programming: algebraic data types. Equally important, it also introduces type-driven development, the methodology par excellence to write functional programs, and illustrates its application through a number of exercises dealing with isomorphisms and logical proofs.
-
Module 3: Higher-order functions (I) (4 hours)
Functional programming excels at modularity and reuse, and this is exemplified by the de-facto standard catalog of higher-order functions introduced in this module. Examples taken from Spark will be used when possible in this module and the previous one.
-
Module 4: Higher-order functions (II) (4 hours)
The previous module exemplifies the use of HOFs for manipulating in-memory data structures such as lists. But, equally important, HOFs are also relevant for implementing imperative and applicative computations dealing with Futures, Error-handling, State, and so forth.
-
Module 5. Type classes (4 hours)
Type classes offer the most prominent functional abstraction for implementing reusable and maintainable APIs.