2. nescala 2013
2 days event in Philadelphia
Day 1: 17 talks
Speakers from typesafe, twitter, tumblr, ...
Scala book authors: Bill Venners , Josh Suereth
Day 2: unconference
$50 entrance fee
3. Function Patterns for the
Asynchronous Web
by Josh Suereth @ TypeSafe, author of Scala in Depth
5. Future
ftr {
uue
/ D smtm ltr
/ o oeie ae
..
.
}mp{rsl =
a eut >
/ D smtigwt rsl
/ o oehn ih eut
..
.
}
6. Monadic Flow
dfrne(aa DRsl) Ftr[tl =ftr(tl..)
e edrdt: beut: uueHm] uueHm(.)
dfhnlRqet..:Ui ={
e adeeus(.) nt
fr{
o
dt < qey..
aa - ur(.)
hm < rne(aa
tl - edrdt)
}yedwietlsce,hm)
il rtHm(okt tl
}
7. Join
vlues Ftr[beut =
a sr: uueDRsl]
qey..
ur(.)
vlpoet:Ftr[beut =
a rjcs uueDRsl]
qey..
ur(.)
vldt:Ftr[DRsl,DRsl) =
a aa uue(beut beut]
(sr zppoet)
ues i rjcs
Ls[uueDRsl] - Ftr[itDRsl]
itFtr[beut] > uueLs[beut]
8. The Essence of the Iterator Pattern
Jeremy Gibbons and Bruno C. d. S. Oliveira @ Oxford University Computing Laboratory
Monadic Map
Applicative Functors
Monadic Applicative Functors
...
10. Not only for Dependency
Injection
tatUeRpstrCmoet{
ri sreoioyopnn
vlueRpstr:UeRpstr
a sreoioy sreoioy
casUeRpstr {
ls sreoioy
..
.
}
}
tatUeSrieopnn {
ri srevcCmoet
ti:UeRpstrCmoet=
hs sreoioyopnn >
vlueSrie UeSrie
a srevc: srevc
casUeSrie{
ls srevc
..
.
}
}
11. Traits are modules
tatUeMdl {
ri sroue
dflaUe(d Ln) Ue
e odsri: og: sr
}
tatTetoue{
ri weMdl
dfps(srd Ln,bd:Srn)
e otueI: og oy tig
}
tatMSLsroueetnsUeMdl {..}
ri yQUeMdl xed sroue .
tatTitroueetnsTetouewt UeMdl {..}
ri wteMdl xed weMdl ih sroue .
vluies =nwMSLsroue
a nvre e yQUeMdl
wt Titroue{
ih wteMdl }
12. Package is just a namespace to avoid name collision. So,
instead import, use extends/with
Explicit dependencies
13. Interesting problem #1
tatA{
ri
vlfo Srn
a o: tig
}
tatBetnsA{
ri xed
vlbr=fo+"ol"
a a o Wrd
}
casCetnsB{
ls xed
vlfo="el"
a o Hlo
pitnbr
rnl(a)
}
solution: use def or lazy val
14. Interesting problem #2
tatA{
ri
ojc suf{
bet tf
ojc Fo
bet o
ojc Br
bet a
ojc Bz
bet a
}}
tatBetnsA{
ri xed
ojc ma {
bet or
ojc Fo
bet o
ojc Bz
bet a
ojc Br
bet a
}}
solution: use val
15. abstract override
tatTat {
ri riA
dfmto1l Ls[tig) Ls[tig
e ehd(: itSrn]: itSrn]
}
tatTat etnsTat {
ri riB xed riA
oerd dfmto1l Ls[tig)=l: "riB
vrie e ehd(: itSrn] + tat"
}
tatTat etnsTat {
ri riC xed riA
asrc oerd dfmto1l Ls[tig)=sprm
btat vrie e ehd(: itSrn] ue.e
to1l : "riC
hd() + tat"
}
casCas {
ls lsA
ti:Tat =
hs riA >
dfso( {pitnmto1Ls(Cas") }
e hw) rnl(ehd(it"lsA))
}