This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class InvariantContainer[A]() | |
case class CovariantContainer[+A]() | |
case class ContravariantContainer[-A]() | |
class Person | |
class User extends Person | |
class Admin extends User | |
val inv1: InvariantContainer[User] = InvariantContainer[User] // works |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
mkdir -p src/{main,test}/{java,resources,scala} | |
mkdir lib project target | |
# create an initial build.sbt file | |
echo 'name := "MyProject" | |
version := "1.0" | |
scalaVersion := "2.10.0"' > build.sbt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.class | |
*.log | |
# sbt specific | |
.cache | |
.history | |
.lib/ | |
dist/* | |
target/ | |
lib_managed/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.mongodb.casbah.MongoCollection | |
import com.mongodb.casbah.MongoConnection | |
object MongoFactory { | |
private val SERVER = "localhost" | |
private val PORT = 27017 | |
private val DATABASE = "portfolio" | |
private val COLLECTION = "stocks" | |
val connection = MongoConnection(SERVER) | |
val collection = connection(DATABASE)(COLLECTION) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app xmlns="http://java.sun.com/xml/ns/javaee" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee ↵ | |
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" | |
version="3.0"> | |
<listener> | |
<listener-class>org.scalatra.servlet.ScalatraListener</listener-class> | |
</listener> | |
<servlet-mapping> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<html lang="en"> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>HTML5 Structure</title> | |
<!-- Fonts --> | |
<link href='http://fonts.googleapis.com/css?family=Lato&subset=latin,latin-ext' rel='stylesheet' type='text/css'> | |
<!-- Bootstrap --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def qsort[T <% Ordered[T]](list: List[T]): List[T] = { | |
list match { | |
case Nil => Nil | |
case x:: xs => | |
val (before, after) = xs partition (_ < x ) | |
qsort (before) ++ (x :: qsort(after)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name := "My Project" version := "1.0" scalaVersion := "2.11.6" libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.4-SNAPSHOT" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** The strict identity type constructor. Can be thought of as `Tuple1`, but with no * runtime representation. */ type Id[+X] = X |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait Free[F[_], A] | |
final case class Return[F[_], A](a: A) extends Free[F, A] | |
final case class Suspend[F[_], A](s: F[Free[F, A]]) extends Free[F, A] |