-
A specification is a definition of a program’s behavior in the general case. Preferably, a specification should not deal with concrete examples of program functionality. Instead it should provide an abstract description of the behavior, that you can use both when implementing the program and when verifying it.
-
Specifications, on the other hand, give us a more complete picture of the program but they are often informal and difficult to verify formally. Instead, tests are used to verify specific cases of a specification.
-
Tests as specification is a concept that is gaining popularity in many test-driven software development processes.
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
scala> import scalaz.std.list.listInstance | |
import scalaz.std.list.listInstance | |
scala> import scalaz.Traverse | |
import scalaz.Traverse | |
scala> import scalaz.ValidationNel | |
import scalaz.ValidationNel | |
scala> import scalaz.Validation |
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 | |
main = ioA where | |
ioA = putStrLn "Hola" | |
ioB = putStrLn "Chao!" |
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 scalaz._ | |
import Scalaz._ | |
case class Cosa(str: String, f: Float, n: Int) | |
import scalaz.Order.orderBy | |
val orderByStr = orderBy { c: Cosa => c.str } | |
val orderByF = orderBy { c: Cosa => c.f } | |
val orderByN = orderBy { c: Cosa => c.n } |
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 Data.IORef | |
readAndPrint :: IORef Int -> IO () | |
readAndPrint ioRef = do | |
n <- readIORef ioRef | |
print $ "ioRef = " ++ show n | |
main = do | |
ioRef <- newIORef 3 | |
readAndPrint ioRef -- "ioRef 3" |
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
def makeFigure(size: Int, spaces: Int, characters: Int, spacesModifier: Int, charactersModifier: Int): String = { | |
val charsValsStream = Stream.iterate(characters, size)(chars => chars + charactersModifier) | |
val spacesValsStream = Stream.iterate(spaces, size)(spaces => spaces + spacesModifier) | |
(charsValsStream zip spacesValsStream).foldLeft(new StringBuilder) { case (builder,(characters,spaces)) => | |
builder append (" " * spaces) append ("*" * characters) append "%n".format() | |
}.toString() | |
} |
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
def fa[A0,A1](a: A0): A1 = ??? | |
def head[A](l: List[A]): A = l.head | |
def fmap[A,B](f: A => B)(l: List[A]): List[B] = l.map(f) | |
"head and then map is the same as map and then head" { | |
fa[A0,A1] compose head[A0] == head[A1] compose fmap[A0,A1](fa) | |
} | |
def tail[A](l: List[A]): List[A] = l.tail | |
"tail and then map is the same as map and then tail" { |
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 #:: f(a) #:: f(f(a)) #:: f(f(f(a))) #:: ... | |
def repeat[A](f: A => A)(a: => A): Stream[A] = a #:: repeat(f)(f(a)) | |
def next(n: Double)(x: Double): Double = (x + n/x)/2.0 | |
def within(eps: Double)(s: Stream[Double]): Double = s match { | |
case a #:: b #:: rest => if(Math.abs(a-b)<=eps) b else within(eps)(rest) | |
case _ => throw new Exception("El stream debería tener por lo menos dos elementos") | |
} |
- "But really, you shouldn’t use your ActorSystem‘s thread pool to manage the number of concurrent database queries either. Your ActorSystem should manage your Thread resources - your database connection pool should actually be what is used to manage database concurrency. It’s highly unlikely that your home grown concurrency system will be faster than BoneCP."
- "I just wrote a jdbc connection pool using akka. (...) I found that Akka version is slower than many other connection pool implementations such as tomcat-jdbc, BoneCP or even commons DBCP." -> Este está abierto a discusión. No hay muchos detalles de la implementación.
- [Una discusión interesante en el grupo de usuarios de akka de un tipo que está intentando implementar algo parecido pero para Redis](https://groups.google.com/forum/#!msg/akka-user/_t1ER27Df78/agxSp
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 AssemblyKeys._ | |
assemblySettings | |
name := "scala-test" | |
version := "0.0.1" | |
scalaVersion := "2.10.3" |
NewerOlder