Models | Examples |
---|---|
Display ads | Yahoo! |
Search ads |
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
import scala.collection.immutable.ListMap | |
sealed abstract class Validated[+T] | |
case class Valid[+T](value:T) extends Validated[T] | |
case class Error(message:String) extends Validated[Nothing] | |
class ValidationException(s:String) extends Exception(s) |
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 Score(p1: Int, p2: Int) | |
// Alles ist eine Expression | |
val score = Score(5, 1) | |
val winner = if (score.p1 > score.p2) "Player 1" else "Player 2" | |
val looser = if (score.p1 > score.p2) "Player 2" else "Player 1" | |
// Tupel | |
val winnerLooser = |
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
trait Pointed[F[_]] { | |
def point[A](a: => A): F[A] | |
} | |
trait Functor[F[_]] { | |
def fmap[A, B](fa: F[A])(f: A => B): F[B] | |
} | |
trait Show[A] { | |
def shows(a: => A): 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
/** | |
* A functional Conway's game of life. | |
*/ | |
package object conwaydef { | |
type Coord[A] = (Int, Int) => A | |
type Calculator = Coord[Coord[Boolean] => Boolean] | |
type Size = Int | |
def nextCell(old: Boolean)(mates: Int) = if (mates > 3) false else if (mates == 3) true else (old && mates == 2) |
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
trait Functor[T[_]]{ | |
def fmap[A,B](f:A=>B)(ta:T[A]):T[B] | |
} | |
trait Applicative[T[_]] extends Functor[T]{ | |
def pure[A](a:A):T[A] | |
def <*>[A,B](tf:T[A=>B])(ta:T[A]):T[B] | |
} | |
trait Monad[M[_]] extends Applicative[M]{ |
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 pong.imperative | |
sealed trait Event | |
class PongConnection { | |
def isConnected(): Boolean = sys.error("not implemented") | |
def readEvent(): Event = sys.error("not implemented") | |
def moveUp(): Unit = sys.error("not implemented") | |
def moveDown(): Unit = sys.error("not implemented") | |
def shootMissile(): Unit = sys.error("not implemented") |
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
module Main where | |
-- A simple directory summing thing for Haskell. | |
-- by Daniel Lyons <fusion@storytotell.org> | |
-- BSD licensed. | |
import Control.Applicative | |
import Data.Either | |
import Data.Foldable |
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
{-# LANGUAGE PackageImports #-} | |
{- | |
You need to register your Twitter application at <http://dev.twitter.com/> | |
to get the consumer key and secret needed for OAuth. When connecting to | |
Twitter for the first time, do this: | |
let consumer = Consumer "consumer key" "consumer secret" | |
token <- authenticate |
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
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages. | |
# ghc-pkg-clean -f cabal/dev/packages*.conf also works. | |
function ghc-pkg-clean() { | |
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'` | |
do | |
echo unregistering $p; ghc-pkg $* unregister $p | |
done | |
} | |
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place. |
OlderNewer