Skip to content

Instantly share code, notes, and snippets.

View jim-collins's full-sized avatar

Jim Collins jim-collins

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
package dojo
/**
* Created with IntelliJ IDEA.
* User: Jim Collins
* Date: 17/09/2015
*/
trait Lcd {
val contents: List[String]
override def toString = contents mkString "\n"
package dojo
import slick.driver.H2Driver.api._
import scala.concurrent.ExecutionContext.Implicits.global
object HelloSlick {
val db = Database.forURL("jdbc:h2:mem:test1;DB_CLOSE_DELAY=-1", driver="org.h2.Driver")
val emps = TableQuery[Emp]
package state
import State._
case class State[S,+A](run: S => (A,S)) {
def map[B](f: A => B): State[S, B] =
flatMap(a => unit(f(a)))
def map2[B,C](sb: State[S, B])(f: (A, B) => C): State[S, C] =
flatMap(a => sb.map(b => f(a, b)))