All Projects → eli-jordan → tagless-final-jam

eli-jordan / tagless-final-jam

Licence: other
Workshop On Tagless Final Interpreters

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to tagless-final-jam

cats-helper
Helpers for cats & cats-effect
Stars: ✭ 19 (-48.65%)
Mutual labels:  cats, tagless-final, cats-effect
console4cats
💻 Effect-type agnostic Console I/O for Cats Effect (archived, use Cats Effect 3 instead)
Stars: ✭ 55 (+48.65%)
Mutual labels:  cats, cats-effect
spotify-next
Small CLI app for filtering out music on Spotify.
Stars: ✭ 45 (+21.62%)
Mutual labels:  tagless-final, cats-effect
vault4s
Vault Client Library For Scala
Stars: ✭ 15 (-59.46%)
Mutual labels:  cats, cats-effect
tinyweb
Simple and lightweight HTTP async server for micropython
Stars: ✭ 182 (+391.89%)
Mutual labels:  cats, cats-effect
telegramium
Telegramium or F[ Tg ] - pure functional Telegram Bot API implementation for Scala.
Stars: ✭ 42 (+13.51%)
Mutual labels:  cats, cats-effect
cats-effect-testing
Integration between cats-effect and test frameworks
Stars: ✭ 155 (+318.92%)
Mutual labels:  cats, cats-effect
skafka
Scala wrapper for kafka consumer and producer
Stars: ✭ 35 (-5.41%)
Mutual labels:  cats, cats-effect
swam
WebAssembly engine in Scala
Stars: ✭ 38 (+2.7%)
Mutual labels:  cats, cats-effect
classy-optics
🔎 Source code shown at my talks at Scale by the Bay 2018 and Scalar 2019
Stars: ✭ 25 (-32.43%)
Mutual labels:  cats, cats-effect
typelevel-stack.g8
📚 Unofficial Giter8 template for the Typelevel Stack (Http4s / Doobie / Circe / Cats Effect / Fs2) based on Cats v1.x.x
Stars: ✭ 63 (+70.27%)
Mutual labels:  cats, cats-effect
tradeio
A disciplined way to purely functional domain models in Scala
Stars: ✭ 19 (-48.65%)
Mutual labels:  cats, cats-effect
zenith
⚡ Functional Scala HTTP server, client, and toolkit.
Stars: ✭ 15 (-59.46%)
Mutual labels:  cats, tagless-final
pfps-examples
🏮 Standalone examples shown in the book "Practical FP in Scala: A hands-on approach"
Stars: ✭ 167 (+351.35%)
Mutual labels:  cats, cats-effect
fs2-ssh
A wrapper around Apache SSHD targeting cats-effect and fs2
Stars: ✭ 36 (-2.7%)
Mutual labels:  cats, cats-effect
fs2-ftp
Simple client for Ftp/Ftps/Sftp
Stars: ✭ 24 (-35.14%)
Mutual labels:  cats, cats-effect
scala-functional-programming-tutorial
Functional Programming in Scala Tutorial
Stars: ✭ 23 (-37.84%)
Mutual labels:  cats, cats-effect
influencer-stats
Playground for measuring performance of functional programming tools in Scala. Gathers statistics about videos.
Stars: ✭ 24 (-35.14%)
Mutual labels:  cats, cats-effect
Monix
Asynchronous, Reactive Programming for Scala and Scala.js.
Stars: ✭ 1,819 (+4816.22%)
Mutual labels:  cats, cats-effect
tutorials
🎥 Source code of the examples shown in the video tutorials
Stars: ✭ 18 (-51.35%)
Mutual labels:  cats, cats-effect

Tagless Final and Abstract Effects

Introduction

One of the core tenants of functional programming, is that the effects our programs use should be expressed in the type signatures of our functions.

For example

  • scala.Option is an effect that indicates a value may, or may not be present.
  • scala.util.Try is an effect that represents a computation that may fail, with an exception

As with all aspects of functional programming, we strive for composability. In Haskell a common approach to composing these effect types in monad transformers. However, in Scala this approach suffers from poor performance, and poor type inference.

One solution to this that has recently gained popularity is the Free Monad, which is an effect absent of interpretation. i.e. it has no inherent effect, but its effect can be defined in an arbitrary way by evaluating it using an interpreter. The free monad also has some draw backs. Performance can be an issue and there is a lot of boiler plate.

An alternative is to use Tagless Final which can be used in most of the same scenarios as the Free Monad, but achieves better performance, less boiler plate and is more simple.

The Workshop

The workshop is made up of practical exercises that introduce the tagless final style, and demonstrate how this style can be used in real world use cases.

Part 1

The first is a practical introduction to the concept of Tagless Final Interpreters with a simple first order language that can express integer arithmetic.

Part 2

The second part consists of several exercises that build out a simple reading list application using the tagless final style.

The exercises will demonstrate;

  • The use of higher-order tagless final encoding
  • Composing tagless final algebras
  • Using typeclass constraints to abstract over what capabilities are needed in different scenarios. Including, sequential computations with cats.Monad, error handling with cats.MonadError and parallelism with cats.Parallel

Setup

Building

  • Java 8 & SBT must be installed.
  • Clone this repository git clone https://github.com/eli-jordan/tagless-final-jam
  • Run sbt update in the root of the project to download and cache all the dependencies.
  • Import the project into your favorite editor, see below for options.

Groll

This repository is configured to use sbt-groll which allows the state of the repository to be updated as we progress through the exercises, including revealing the solutions.

  • To get started sbt> groll initial. This will get you ready for the first exercise.
  • Running sbt> groll next will reveal the solutions to the section
  • Running sbt> groll next will reveal the next exercise, and so on.

Each time you move to a new exercise, there will be detailed instructions under the /docs directory.

Editors

There are several editors for scala

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].