Skip to content

Instantly share code, notes, and snippets.

View missingfaktor's full-sized avatar
🥔

Rahul Goma Phulore missingfaktor

🥔
View GitHub Profile
user=> (defn foobar [xs]
#_=> (match xs (clauses !empty (fn [] :empty)
#_=> (!cons (!constant 3) !empty) (fn [] :singleton-with-3)
#_=> (!cons !var !any) (fn [head] head))))
#'user/foobar
user=> (foobar [])
:empty
user=> (foobar [3])
trait Cache[R[_], W[_], Eff[_]] {
def save[V](key: String, value: V)(implicit writes: W[V]): Eff[Unit]
def retrieve[V](key: String)(implicit reads: R[V]): Eff[Option[V]]
}
// In-memory cache. Potentially backed by a Map[String, Any].
// Needs no reads or writes.
class InMemoryCache extends Cache[Tautology1, Tautology1, Id] {
def save[V](key: String, value: V)(implicit writes: Tautology1[V]): Unit = ???
data Response = SomethingWentWrong
| NoResults
| Result (Map IdType ResultType)
@missingfaktor
missingfaktor / criteria.txt
Last active September 11, 2015 14:26 — forked from gigamonkey/criteria.txt
Hiring criteria: looking for the ability to …
Write a program that does what it’s supposed to do
Write idiomatic code
Debug a program that you wrote
Debug a program someone else wrote
Debug the interaction between a system you wrote and one you didn’t
File a good bug report
Modify a program you didn’t write
Test a program you wrote
Test a program you didn’t write
Learn a new programming language
scala> new java.util.HashMap[String, Int]
res0: java.util.HashMap[String,Int] = {}
scala> res0.get("hello")
res1: Int = 0
scala> Option(res0.get("hello"))
res2: Option[Int] = None
scala> object Foo {
| implicit def foo(i: Int) = i.toString
| }
warning: there was one feature warning; re-run with -feature for details
defined object Foo
scala> object Bar {
| implicit def foo(s: Symbol) = s.toString
| }
warning: there was one feature warning; re-run with -feature for details
package nope.utils
trait Stub {
class StubbedNullaryMethod[R] {
@volatile
protected var _function: () => R = () => throw new RuntimeException("Unset.")
def setFunction(f: () => R) {
_function = f
trait Reference {
type RefType[_]
}
trait Database extends Reference {
type RefType[A] = A
}
trait REST extends Reference {
type RefType[A] = Seq[A]
trait Reference
trait Database extends Reference
trait REST extends Reference
trait NoRef extends Reference
trait RefType[A, R <: Reference] {
type Repr
}
trait Customer
def foo(): Future[Bob] = {
  if (flag) 
    someAsyncCall()
  else
    throw new RuntimeException()
}

In the above code, the exception was thrown outside a future, so it'll never reach a handle/rescue block that was defined somewhere up the call stack. The type here didn't prevent us from doing it because exceptions are an effect not seen by the type system.