Specs2

Post on 10-May-2015

981 views 0 download

description

The slides for the fp-syd presentation: http://www.youtube.com/watch?v=lMyNRUuEvNU. Sorry for the bad fonts which have been converted by SlideShare on upload.

Transcript of Specs2

Go functional!

Shame

Mutability

Concurrency

Acceptance

Why

The idea

User

DesignProgram

Go Functional!

But what

is it?!

Referential transparency

Immutabili

ty

behavior

pipelined

FPemerg

entbehavior

Processing data structures

OO

Why

The idea

User

DesignProgram

Starting point

Nesting

Precedence:+!^

FormattingText

Example

Text

Example

Example

Formatting

pbrendt, t(i)bt, bt(i)

acceptance

Context

doBefore

withDb.apply(e2)

Why

The idea

User

DesignProgram

Run

execute

levels

select

sequence

arguments

statistics

to text

to html

Laziness vs evaluation

Iterating

Traverse

A datastructure to

traversethe

accumulation

the mapping

Applicative magic?

Lots of instances:• State• List• Monad• Monoid

simple

composable Type inference is hard,Let’s go

shopping!

Reduceraggregation

“parallel” composition

mapping

specs2 reducers:• Levels• Statistics• Arguments• Text• Html

Why

The idea

User

DesignProgram

Trees

Text

Example 1

Example 2

SuiteDescript

ion

Test Descriptio

n 1

Test Descriptio

n 2

SuiteDescription

fChildren = TD1, TD2

TreeLoc

TreeLoc

<h1/>

<h2/> <h2/>

<body>

<h2>part 1</h2><h2>part 2</h2>

<h1>Title 1</h1>

</body>

Anti-XMLThe non-violent solution

Concurrency

a concurrent task

=> Promise[Seq[ExecutedFragment]]

Exceptions

Exceptions

Exceptions

Mocks

<h1/>

MutabilityBack fo

r

good

Nothing here!

Throws exception

ConfigurationPart of the flow

named parameters + defaults

nested ‘record’

ConfigurationImplicits

implicit arguments

default value

Conclusion

• Reliability• Concurrency• Composition• Less mocks• val/vars

• DSL• Type inference• Learning curve