Skip to content

Instantly share code, notes, and snippets.

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
@noelmarkham
noelmarkham / imports.md
Last active January 5, 2017 18:00
Cats imports cheat sheet
import... What it imports
cats.std.type Typeclass instances for standard library type (think List, Option)
cats.syntax.type “Enhanced” methods for type (.toRightXor etc)
cats.data.type Imports a type not part of the standard library (think Xor, Kleisli) and its typeclass instances
scalacOptions ++= Seq(
// "-Xprint:typer", // Turn this on if WartRemover acts up, to see full syntax tree
"-deprecation",
"-encoding", "UTF-8", // yes, this is 2 args
"-feature",
"-unchecked",
"-Xfatal-warnings", // Treat Warnings as Errors
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-dead-code", // N.B. doesn't work well with the ??? hole
@cvogt
cvogt / gist:9239494
Last active September 9, 2019 01:30
Slick app architecture cheat sheet
// Please comment in case of typos or bugs
import scala.slick.driver.H2Driver._
val db = Database.for...(...)
case class Record( ... )
class Records(tag: Tag) extends Table[Record](tag,"RECORDS"){
...
def * = ... <> (Record.tupled,Record.unapply)
// place additional methods here which return values of type Column