Skip to content

Instantly share code, notes, and snippets.

sealed trait Interact[A]
case class Ask(prompt: String)
extends Interact[String]
case class Tell(msg: String)
extends Interact[Unit]
trait Monad[M[_]] {
def pure[A](a: A): M[A]
@cluno
cluno / tree.sh
Last active August 29, 2015 14:03
Binary Tree in Scala
#!/bin/sh
exec scala -savecompiled "$0" "$@"
# Output
# --------------------------------------------------------
# Node(1,Node(2,Leaf(4),Leaf(5)),Node(3,Leaf(6),Leaf(7)))
# ========================================================
# size 7
# height 3
# leafCount 4
@cluno
cluno / denotational.scala
Last active March 7, 2021 14:32
Erik Meijer's Denotational Semantics Code Example in ScalaDay 2014
import Denotational._
/**
* Video: http://www.parleys.com/play/53a7d2c9e4b0543940d9e553
* Slide: https://dl.dropboxusercontent.com/u/7083182/scaladays-slides/DenotationalSemantics.compressed.pdf
*
* For being a better Functional Programmer
* "Fold and unfold for program semantics" by Graham Hutton
* - http://eprints.nottingham.ac.uk/230/1/semantics.pdf
*

Installing pdnsd from homebrew as root user.

$ brew install pdnsd

$ sudo chown -R nobody /usr/local/var/cache/pdnsd

$ curl -L http://goo.gl/kMlyQ -o pdnsd.conf
$ mv pdnsd.conf /usr/local/etc
$ sudo chown root /usr/local/etc/pdnsd.conf
// Questions about \/ and Validation
object scalaz {
/*
This explanation might help. This is a compilable source file with revisions
available at https://gist.github.com/tonymorris/8263051
Fact: All monads are applicative functors. As has been seen we can witness the
`Applicative` that arises from the `Monad` primitives. Let's illustrate this: