https://github.com/giacomocavalieri/effects-introduction
Code with a simple introduction to some effect systems both in Scala and Haskell
https://github.com/giacomocavalieri/effects-introduction
free-monads haskell scala tagless-final unison-language
Last synced: 26 days ago
JSON representation
Code with a simple introduction to some effect systems both in Scala and Haskell
- Host: GitHub
- URL: https://github.com/giacomocavalieri/effects-introduction
- Owner: giacomocavalieri
- Created: 2022-10-03T15:50:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-09T15:14:01.000Z (over 2 years ago)
- Last Synced: 2025-03-28T17:00:00.623Z (about 1 month ago)
- Topics: free-monads, haskell, scala, tagless-final, unison-language
- Language: Scala
- Homepage:
- Size: 1.67 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# effects-introduction

The project aims to get an overview of some of the most prominent (or emerging) effect systems:
- _mtl/tagless final_
- _free monads_
- _ad hoc languages_## Project's structure
The project starts from a rather dumb function that performs an effectful computation; in plain Scala:```scala
def maybeDouble(n: Int): Int =
println("Flipping a coin!")
val heads = util.Random.nextBoolean
if head then n*2 else n
```Then, for each effect system it shows:
- how to encode the function in the effect system
- how the core logic of the resulting code can be tested
- how the program could be interpreted in different waysAll the examples are written in Haskell, Scala and Unison: the projects have almost exactly the same
structure so that if you know one of the languages it (hopefully) should not be too hard to follow the
examples in the other.## Running the examples
| | Scala | Haskell | Unison (in `ucm`) |
|-----------------------------|------------|---------------------|---------------------|
| run the interactive example | `sbt run` | `cabal run effects` | `run coinFlip.main` |
| run the tests | `sbt test` | `cabal test` | `test` |## A note on the Unison code
[Unison](https://www.unison-lang.org) is a content-addressed language and stores its code in a format that
GitHub can not currently show; that's why for now in the repository I included a simple `code.u` file with
all thee definitions that would be stored in the codebase. It's just to make it easier to keep everything
in one place. However, I highly recommend to browse the Unison code directly from its
[repository on Unison Share](https://share.unison-lang.org/@giacomocavalieri/code/latest/namespaces/public/learning/thesis/coinFlip)