Category:
Combo: Talk & Workshop
Target:
Intermediate - Expected knowledge of basic Scala or Haskell syntax
(examples will be contrasted in both).
Language:
import scalaz._, Scalaz._ | |
case class ListT[F[+_], +A](stepListT: F[TStep[A, ListT[F, A]]]) { | |
def ++[AA >: A](other: ListT[F, AA])(implicit F: Monad[F]): ListT[F, AA] = ListT(for { | |
s <- stepListT | |
r <- s match { | |
case TNil() => | |
other.stepListT | |
case TCons(a, x) => | |
TStep.cons(a, x ++ other).pure[F] |
Category:
Combo: Talk & Workshop
Target:
Intermediate - Expected knowledge of basic Scala or Haskell syntax
(examples will be contrasted in both).
Language:
sealed trait Accent[A] | |
final case class Zed(n: Int) extends Accent[Int] | |
final case class Zee(s: String) extends Accent[String] | |
object Example { | |
def twice[A](accent: Accent[A]): Accent[A] = accent match { | |
case Zed(n) => Zed(n + n) | |
case Zee(s) => Zee(s + s) | |
} |
Host B | |
ProxyCommand ssh A nc -w 360 B 22 | |
Host C | |
ProxyCommand ssh B nc -w 360 C 22 | |
scalacOptions ++= Seq("-deprecation", "-unchecked", "-optimise", "-Yinline-warnings", "-feature", "-language:implicitConversions", "-language:higherKinds", "-language:postfixOps") |
import argonaut._, Argonaut._ | |
class Example(val s: String, val i: Int) | |
object Example { | |
implicit def ExampleEncodeJson: EncodeJson[Example] = | |
EncodeJson(example => Json( | |
"s" := example.s, | |
"i" := example.i)) |
;; repl session | |
(use 'lens) | |
(defrecord Address [street city postcode]) | |
(defrecord Person [name age address]) | |
(defrecord User [uid username identity password]) | |
(def -postcode (mklens :postcode)) | |
(def -city (mklens :city)) |
user=> (defn adder [x y] (+ x y)) | |
(defn adder [x y] (+ x y)) | |
#'user/adder | |
user=> (partial adder) | |
(partial adder) | |
#<user$adder user$adder@2c40072a> | |
user=> (def adderx (partial adder)) | |
(def adderx (partial adder)) | |
#'user/adderx | |
user=> (adderx 1) |
F#
.net 4.5 - immutable collections, nuget package - developed by microsoft. core library source available - including roslin, compiler as a service.
data Lens a b = Lens { | |
get :: a -> b | |
, set :: b -> a -> a | |
} | |
type Lens' a b = | |
forall f. Functor f => (b -> f b) -> a -> f a | |
newtype Identity a = | |
Identity { runIdentity :: a } |