This file contains 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
object NList { | |
import Nat._ | |
sealed trait NList[L <: Nat, A] { | |
def ++[B >: A, M <: Nat](other: NList[M, B]) | |
(implicit sum: Plus[L, M]): NList[sum.Out, B] | |
} | |
case object NNil extends NList[Zero, Nothing] { |
This file contains 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
/* | |
Trying to express the following GADTs in Scala. It's taken from | |
http://eb.host.cs.st-andrews.ac.uk/drafts/tfp08.pdf (page 5) | |
data Z | |
data S n | |
data Nat :: * -> * where | |
Zero :: Nat Z |
This file contains 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
As your code-base increases in size and you get more comfortable with | |
advanced Scala features you slowly reach a point where grep simply isn’t | |
sufficient to search through your projects; This has lead to the development | |
of Semantic Search, a plugin for Scala IDE for Eclipse that simplifies | |
code navigation, understanding, and refactoring. | |
In this talk Mads will show his work on Semantic Search with a live demo | |
of some of the features, including: | |
• Finding all occurrence of any Scala entity, even implicits. |
This file contains 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
Madss-MacBook-Pro:scala mads379$ ant all.clean | |
Buildfile: /Users/mads379/dev/projects/open-source/scala/build.xml | |
strap.clean: | |
[delete] Deleting directory /Users/mads379/dev/projects/open-source/scala/build/strap | |
pack.clean: | |
[delete] Deleting directory /Users/mads379/dev/projects/open-source/scala/build/pack | |
init.jars.check: |
This file contains 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 output. | |
info] ! Multiset.remove: Falsified after 1 passed tests. | |
[info] > ARG_0: (ListMultiset(, ),) <<<---- this is what looks weird, but I guess it's a ListMultiset with "" (no space)," " (a space) and the string is "" (no space) | |
[info] ! Multiset.remove: Falsified after 7 passed tests. | |
[info] > ARG_0: (ListMultiset(),) | |
// The specification | |
property("remove") = forAll(genMultisetWithString) { ((ms: Multiset[String], s: String) => |
This file contains 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
package com.sidewayscoding.usecase | |
import com.sidewayscoding.immutable.ListMultiset | |
import com.sidewayscoding.Multiset | |
object QueryExample { | |
def main(args: Array[String]) { | |
sealed abstract class WithId(val id: String) { | |
override def equals(other: Any) = other match { |
This file contains 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
object ShoppingCart { | |
/* | |
* Data has been taken from http://www.freebase.com/view/book/book_edition | |
*/ | |
implicit val mergeableItem = new Mergeable[Book] {} | |
case class Book(name: String, | |
creditedTo: Option[String], |
This file contains 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 Person(name: String, age: Int) | |
val p1 = Person("Mads",22) | |
val p2 = Person("Mikkel",22) | |
implicit val eq: Equiv[Person] = new Equiv[Person] { | |
def equiv(x: Person, y: Person) = x.age == y.age | |
} | |
Set(p1,p2) // Set(Person(Mads,22), Person(Mikkel,22)) |
This file contains 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
Hi, | |
Here's some detailed info. | |
-- DIR info | |
$ pwd | |
/Users/mads379/dev/projects/open-source/ensime | |
$ ll | |
total 64 |
This file contains 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
(defun toggle-maximize-buffer () "Maximize buffer" | |
(interactive) | |
(if (= 1 (length (window-list))) | |
(jump-to-register '_) | |
(progn | |
(set-register '_ (list (current-window-configuration))) | |
(delete-other-windows)))) | |
;; Bind it to a key. |