Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
xuwei-k / doctest.md
Last active November 24, 2016 21:40
sbt-doctest でやりたいことまとめ
  • import 文を SettingKeyTaskKey でカスタマイズ可能にしたい
  • 現状は固定
  • やりたかったら、それぞれのテストに明示的に書くか、スコープに入るように、テストが置かれるであろうパッケージオブジェクトに色々置くしか無い?
  • 拡張ポイントをどこにするか問題
  • あくまで個人的意見としては、"sbt pluginの拡張ポイントはできるだけ汎用的" になっているべきだと思う
  • 言い換えると、あとからKeyをあまり増やしたくない。(keyが汎用的すぎて、それを設定するユーザー側が)多少面倒だとしても、少ない汎用的なKeyさえ使えば、とにかくなんでも設定可能
  • 汎用的にするには、やはりKeyは関数になっているべき
  • なので、最初に思いついたのは それぞれのテスト => Import文 という関数のKeyを作る
  • それぞれのテスト とは、現状では ParsedDoctest だろう
  • つまり ParsedDoctest => Seq[String]
@pathikrit
pathikrit / README.md
Last active April 24, 2021 17:36
My highly opinionated list of things needed to build an app in Scala

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
import org.joda.time._
import monix.execution._
import monix.execution.Scheduler.Implicits.global
import java.util.concurrent.TimeUnit
import scala.util.control.NonFatal
def scheduleOncePerDay(time: LocalTime, now: DateTime = DateTime.now())(cb: () => Unit)
(implicit s: Scheduler): Cancelable = {
val nextTick = {
@gvolpe
gvolpe / shared-state-in-fp.md
Last active March 15, 2022 20:27
Shared State in pure Functional Programming

Shared State in pure Functional Programming

Newcomers to Functional Programming are often very confused about the proper way to share state without breaking purity and end up having a mix of pure and impure code that defeats the purpose of having pure FP code in the first place.

Reason why I decided to write up a beginner friendly guide :)

Use Case

We have a program that runs three computations at the same time and updates the internal state to keep track of the

@gvolpe
gvolpe / di-in-fp.md
Last active September 16, 2024 07:18
Dependency Injection in Functional Programming

Dependency Injection in Functional Programming

There exist several DI frameworks / libraries in the Scala ecosystem. But the more functional code you write the more you'll realize there's no need to use any of them.

A few of the most claimed benefits are the following:

  • Dependency Injection.
  • Life cycle management.
  • Dependency graph rewriting.