47 Degrees joins forces with Xebia read more

# Functional Programming Fundamentals in Kotlin with Arrow

In this intensive course, we’ll cover Functional Programming essentials in Kotlin over four days / 16-hrs total. By the end of this course, you will have a solid grasp on the course concepts.

### Course Dates:

• Tuesday, July 27th - 09:00 - 13:00 CET
• Wednesday, July 28th - 09:00 - 13:00 CET
• Thursday, July 29th - 09:00 - 13:00 CET
• Friday, July 30th - 09:00 - 13:00 CET

#### Course content

##### Lesson 1: Functional Programming

Functional programming fundamentals.​

• What is it, what is it good for.
• Pure functions.
• Side effects.
• Referential transparency & substitution model.
• Local reasoning.
• Is Kotlin a functional language?
• Higher order functions.
• Deferring execution.
• Exercises.
##### Lesson 2: Domain Modeling

Modeling our domain from a functional perspective.

• Kotlin type system. Leveraging compiler aid via types.
• Modeling concerns and making them explicit with types.
• Unit and Nothing to model meaningful scenarios.
• Inline classes for type safety and preciseness.
• Algebraic Data Types: Product and Sum types.
• Complexity of ADTs.
• Modeling choice and control flow with sum types.
• Arrow data types as ADTs.
• Eliminating bugs and tests for invariants via type safety.
• Exercises.
##### Lesson 3: Immutable Data and Optics

Optimizing reusability and composition for immutable data structures using Optics.

• Immutability.
• Issues with Kotlin data class `copy`.
• Optics for working efficiently with nested immutable data.
• Optics composition and reusability.
• The Optics DSL.
• Stacking optics to create more powerful ones 🔭
• `Lens` for reading / modifying nested data.
• `Prism` for conditional reading / modification.
• `Optional` as the composition of Lens and Prism.
• `Every` for working over lists of elements.
• `FilterIndex` for working over lists of elements based on a predicate.
• `Index` for reading or modifying elements obtained by their index.
• `Iso` for isomorphic conversions.
• Exercises.
##### Lesson 4: Domain Modeling II - Error Handling

Learning how to model and handle errors in functional programs.

• Railway oriented programming 🚂 - Happy path vs alternative path.
• Making errors vs success explicit with types.
• The `Either` datatype.
• Exhaustive evaluation.
• `Either` composition and computational blocks (bindings).
• `Either` bias towards the happy case.
• Capturing third party library errors.
• Mapping third party errors to strongly typed domain errors.
• Error accumulation.
• `Validated` and `ValidatedNel`.
• `Either` and `Validated`, when to use each? Fail fast vs error accumulation.
• `Either` and `Validated` interoperability.
• Flattening lists of `Either` or `Validated`.
• `Either` or `Validated` for domain model validation.
• Modeling potential absence of a value.
• Exercises.
##### Lesson 5: Functional Effects

Keeping side effects under control.

• Recap on side effects.
• `Suspend` for tracking effects at compile time.
• The benefits of modeling effects with `suspend`.
• Making effect declaration pure.
• Concern separation - pure logics vs runtime.
• Internals of `suspend` - Continuation passing style.
• The impact of `suspend` in architecture.
• Leveraging `Either` and `Validated` in suspended contexts.
• Arrow integration with KotlinX Coroutines.
• Structured concurrency & cancellation via KotlinX Coroutines.
• Providing a runtime for our suspended program.
• Functional effect operators via Arrow Fx.
• Parallel computations, races, repeating and retrying suspended effects.
• Handling errors in suspended contexts.
• Exercises.
##### Lesson 6: Safe Resource Handling

Functional operators to work safely with resources across boundaries.

• What is a resource?
• The issues of working with resources in concurrent contexts.
• Why `try / catch` is not enough.
• Acquiring, using, and releasing a resource.
• Abstraction as a means to leverage composability.
• Ensuring resource disposal to avoid leaks.
• `bracket` and `bracketCase` operators.
• `guarantee` and `guaranteeCase` operators.
• Limitations of `bracket` and `bracketCase`.
• `Resource` data type.
• `Resource` and `bracket` to work with third party libraries.
• Exercises.
##### Lesson 7: Functional Streams

Streams able to embed and evaluate functional effects.

• The need for streams.
• The need for `suspend` support in streams.
• Streams in Kotlin via `Flow` data type.
• Modeling functional effects within a `Flow`.
• `Flow`s are cold.
• Consuming functional streams safely - `suspend` terminal operators.
• `Flow` integration with Arrow Fx operators.
• Cancellation of streams with functional effects via structured concurrency.
• Sneak peek into `Flow` builders and operators.
• Composing `Flow`s together.
• Error path vs happy path in the context of a `Flow`.
• Retrying `Flows`.
• Exercises.
##### Lesson 8: Functional Architecture

How to organize and structure functional programs.

• Concern separation from an architecture perspective.
• Keeping architecture pure edge to edge.
• The concept of algebras.
• Isolating side effects, pushing them to the edges.
• Dependency injection in functional codebases.
• Replacing side effects with test doubles.
• The importance of pure functions and determinism for testing.
• The importance of a precise self validated domain for testing.
• Removing tests for invariants with proper types.
• Testing functional codebases.
• Sneak peek into Property Based Testing (PBT) with Kotest.
• Generating input data for our tests.
• Failure shrinking to track down failing cases.
• Detecting edge cases thanks to PBT.
• Exercises.

• \$1100
• -50%

Enroll for \$550Starts on July 27 at 09:00 - 13:00 CET

Company and Private Group Training

• 4 Days
• Instructor-Led Course
• Beginner
• Online
• I would like to apply for financial aid.
• Frequently Asked Questions

### Trainers

Jorge Castillo

Senior Software Engineer

### Skills

• Kotlin
• Functional Programming Essentials
• Type classes
• Error Handling
• Output

### This Instructor-Led Course includes:

• Maximum Class Size of 15
• Certificate of Completion

### Requirements:

• One year of experience using Kotlin or similar Functional Programming-oriented languages
• coroutines
• structured concurrency
• coroutine scopes
• dispatchers
• cancellation
• suspend
• Flow

## Frequently Asked Questions

Is this course 100% online?

Yes

How do I register interest for a course with no start date or future training dates?

You can join the Academy newsletter to stay posted about upcoming courses and events.

What if I can’t find a course?

Please email your thoughts and suggestions to [email protected], and we’ll get back to you as soon as possible.

Will I receive accreditation for a course?

For any paid training courses, we intend to launch an accreditation process after the launch of Academy. If you take a paid training course before this time, we’ll make sure to send an accreditation when we’re ready.

What tools do I need to access 47 Degrees Academy content?

The only thing you need is a modern web browser and Internet connection. For training courses with code workshops or downloadable code samples, the course specifics will include the necessary tools and instructions to get going.

Will I earn university credit for completing any training?

No, at this time, the courses are not intended to replace university or other formal education courses. If you are an academic or training institution with an interest in partnering or licensing content from Academy, please get in touch at [email protected].

What languages will the training be given in?

English is the common language across 47 Degrees. If you have an interest in supporting other languages, please let us know at [email protected].

Is financial aid available for underrepresented or low-income groups?

Our industry is not diverse enough across many measures of representation. Nor is it easily accessible to many minorities or those in low-income scenarios. If you feel that you belong to an underrepresented minority or need help financially, please fill this form. We can apply a course voucher to your registered Academy account. The voucher can be redeemed against any paid course on a one-time basis. The voucher is non-transferable, non-refundable, and has no financial value.

What is the refund policy?

If you request a refund for a paid training course before taking it, we will refund your course fee during our next processing cycle. If you request a refund for a paid training course after starting or accessing it, please email us at [email protected]. Please refer to the full Terms and Conditions before requesting a refund. 47 Degrees reserves the right to refuse refunds.

Are these courses qualified for the FUNDAE (Fundación Tripartita)?

Part of the course cost is reimbursable for companies located in Spain, through Fundae ( formerly, Fundación Tripartita ). If this is your case, please contact us through [email protected] before enrolling in a course.

Do you have more questions? Contact us