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
| // requires Scala 2.10.0-M7 | |
| def kind[A: scala.reflect.TypeTag]: String = { | |
| import scala.reflect.runtime.universe._ | |
| def typeKind(sig: Type): String = sig match { | |
| case PolyType(params, resultType) => | |
| (params map { p => | |
| typeKind(p.typeSignature) match { | |
| case "*" => "*" | |
| case s => "(" + s + ")" | |
| } |
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
| trait Entity | |
| trait User extends Entity | |
| trait Product extends Entity | |
| case class Id[T<:Entity](id:String) | |
| def buy(pId:Id[Product],uId:Id[User])="Bought product %s for user %s".format(pId.id,uId.id) | |
| val pId=new Id[Product]("1") |
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
| // Missing support libraries | |
| object MissingLibraries { | |
| case class State[S, +A](run: S => (A, S)) { | |
| def map[B](f: A => B): State[S, B] = | |
| State(s => { | |
| val (a, t) = run(s) | |
| (f(a), t) | |
| }) | |
| def flatMap[B](f: A => State[S, B]): State[S, B] = |
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
| C:\Users\brianf>curl -I --insecure "https://repository.apache.org/service/local/ | |
| artifact/maven/redirect?r=snapshots&g=org.apache.maven&a=maven-core&v=3.1-SNAPSH | |
| OT&e=jar" | |
| HTTP/1.1 301 Moved Permanently | |
| Date: Tue, 06 Nov 2012 17:19:19 GMT | |
| Server: Noelios-Restlet-Engine/1.1.6-SONATYPE-5348-V4 | |
| Content-Type: application/xml; charset=ISO-8859-1 | |
| Location: https://repository.apache.org/service/local/repositories/snapshots/con | |
| tent/org/apache/maven/maven-core/3.1-SNAPSHOT/maven-core-3.1-20121105.160646-45. | |
| jar |
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
| package net.tixxit | |
| import shapeless._ | |
| import Nat._ | |
| final class Fizz | |
| final class Buzz | |
| trait FizzBuzzAux[A <: Nat, B <: HList] { | |
| def apply(): List[String] |
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
| package fizzbuzz | |
| // This is church encoding of natural numbers | |
| sealed trait Num { | |
| def toInt : Int | |
| override def toString = toInt.toString | |
| } | |
| final case object Z extends Num { | |
| def toInt : Int = 0 |
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
| # -*- coding: utf-8 -*- | |
| """ | |
| Builds epub book out of Paul Graham's essays: http://paulgraham.com/articles.html | |
| Author: Ola Sitarska <ola@sitarska.com> | |
| Copyright: Licensed under the GPL-3 (http://www.gnu.org/licenses/gpl-3.0.html) | |
| This script requires python-epub-library: http://code.google.com/p/python-epub-builder/ | |
| """ |
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
| // Searching for large ModAux instances can be extremely slow. | |
| // See this version for a faster solution: https://gist.github.com/4108026 | |
| import shapeless._, Nat._ | |
| trait FizzBuzz[N <: Nat] { | |
| def steps: List[String] | |
| def show = println(steps.reverse.mkString("\n")) | |
| } |
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
| Companies hiring Scala developers in the Bay Area. | |
| Created in response to a thread on scala-base. | |
| My favorites: | |
| - CloudPhysics | |
| - Wordnik | |
| Unbiased list: | |
| - 10Gen | |
| - Audax Health |
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 Monoid m where | |
| mappend :: m -> m -> m | |
| mempty :: m | |
| mconcat :: Monoid m => [m] -> m | |
| mconcat = foldr mappend mempty | |
| newtype MonadMonoid m a = | |
| MonadMonoid { getMonad :: a -> m a } |