SlideShare una empresa de Scribd logo
1 de 73
Descargar para leer sin conexión
Problemas que o Elm resolve
só com o compilador
sem nada mais
@cuducos
cuducos.me
1 / 73
2 / 73
3 / 73
4 / 73
5 / 73
6 / 73
“O melhor caso de uso de Haskell”
— Felipe de Morais
7 / 73
$ elm-make Main.elm  --warn
8 / 73
Propriedades que podem não existir
1
9 / 73
user = {
name: 'Eduardo Cuducos',
twitter: 'cuducos'
}
const getSocialMedia = (user) => user.facebook
getSocialMedia(user)
10 / 73
user = {
name: 'Eduardo Cuducos',
twitter: 'cuducos'
}
const getSocialMedia = (user) => user.facebook
getSocialMedia(user)
undefined
11 / 73
class User:
def __init__(self, name, twitter):
self.name = name
self.twitter = twitter
user = User('Eduardo Cuducos', 'cuducos')
def get_social_media(user):
return user.facebook
get_social_media(user)
12 / 73
class User:
def __init__(self, name, twitter):
self.name = name
self.twitter = twitter
user = User('Eduardo Cuducos', 'cuducos')
def get_social_media(user):
return user.facebook
get_social_media(user)
AttributeError: 'User' object has no attribute 'facebook'
13 / 73
type alias User =
{ name : String
, twitter : String
}
getSocialMedia : User -> String
getSocialMedia user =
user.facebook
14 / 73
type alias User =
{ name : String
, twitter : String
}
getSocialMedia : User -> String
getSocialMedia user =
user.facebook
-- TYPE MISMATCH ------------------------------------------------------ Main.elm
`user` does not have a field named `facebook`.
15| user.facebook
^^^^^^^^^^^^^
The type of `user` is:
User
Which does not contain a field named `facebook`.
Hint: The record fields do not match up. One has name and twitter. The other has
facebook.
15 / 73
type alias User =
{ name : String
, twitter : String
}
getSocialMedia : User -> String
getSocialMedia user =
user.twitter
16 / 73
type alias User =
{ name : String
, twitter : String
}
getSocialMedia : User -> String
getSocialMedia user =
user.twitter
Success! Compiled 1 module.
17 / 73
Elm não te deixa com
o undefined na mão!
18 / 73
Objetos que podem não existir
2
19 / 73
users = [
{ name: 'Eduardo Cuducos', twitter: 'cuducos' },
{ name: 'Hugo Bessa', twitter: 'hugobessaa' }
]
const firstUserName = (users) => users[0].name
firstUserName(users)
20 / 73
users = [
{ name: 'Eduardo Cuducos', twitter: 'cuducos' },
{ name: 'Hugo Bessa', twitter: 'hugobessaa' }
]
const firstUserName = (users) => users[0].name
firstUserName(users)
'Eduardo Cuducos'
21 / 73
users = []
firstUserName(users)
22 / 73
users = []
firstUserName(users)
TypeError: Cannot read property 'name' of undefined
23 / 73
users = [
User('Eduardo Cuducos', 'cuducos'),
User('Hugo Bessa', 'hugobessaa')
]
def first_user_name(users):
return users[0].name
first_user_name(users)
24 / 73
users = [
User('Eduardo Cuducos', 'cuducos'),
User('Hugo Bessa', 'hugobessaa')
]
def first_user_name(users):
return users[0].name
first_user_name(users)
'Eduardo Cuducos'
25 / 73
users = []
first_user_name(users)
26 / 73
users = []
first_user_name(users)
IndexError: list index out of range
27 / 73
users = []
first_user_name(users)
IndexError: list index out of range
def first_user_name(users):
first_user, *_ = users
return first_use.name
28 / 73
users = []
first_user_name(users)
IndexError: list index out of range
def first_user_name(users):
first_user, *_ = users
return first_use.name
ValueError: not enough values to unpack (expected at least 1, got 0)
29 / 73
firstUserName : List User -> String
firstUserName users =
let
firstUser = List.head users
in
firstUser.name
30 / 73
firstUserName : List User -> String
firstUserName users =
let
firstUser = List.head users
in
firstUser.name
-- TYPE MISMATCH --------------------------------------------- Main.elm
`firstUser` does not have a field named `name`.
29| firstUser.name
^^^^^^^^^^^^^^
The type of `firstUser` is:
Maybe User
Which does not contain a field named `name`.
31 / 73
firstUserName : List User -> String
firstUserName users =
case List.head users of
Just user ->
user.name
Nothing ->
"User not found"
32 / 73
firstUserName : List User -> String
firstUserName users =
case List.head users of
Just user ->
user.name
Nothing ->
"User not found"
Success! Compiled 1 module.
33 / 73
Elm te obri a a preparar a
aplicação para casos raros, extremos!
34 / 73
Missão impossível
3
35 / 73
const tomorrow = (today) => parseInt(today) + 1
tomorrow('18')
36 / 73
const tomorrow = (today) => parseInt(today) + 1
tomorrow('18')
19
37 / 73
tomorrow(undefined)
38 / 73
tomorrow(undefined)
NaN
39 / 73
def tomorrow(today):
return int(today) + 1
tomorrow('18')
40 / 73
def tomorrow(today):
return int(today) + 1
tomorrow('18')
19
41 / 73
tomorrow(None)
42 / 73
tomorrow(None)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
43 / 73
tomorrow(None)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
tomorrow('NaN')
44 / 73
tomorrow(None)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
tomorrow('NaN')
ValueError: invalid literal for int() with base 10: 'NaN'
45 / 73
tomorrow : String -> Int
tomorrow today =
(String.toInt today) + 1
46 / 73
tomorrow : String -> Int
tomorrow today =
(String.toInt today) + 1
-- TYPE MISMATCH ------------------------------------------------------ Main.elm
The left argument of (+) is causing a type mismatch.
45| (String.toInt today) + 1
^^^^^^^^^^^^^^^^^^
(+) is expecting the left argument to be a:
number
But the left argument is:
Result String Int
47 / 73
tomorrow : String -> Int
tomorrow today =
case String.toInt today of
Ok day ->
day + 1
Err _ ->
Debug.crash "TODO"
48 / 73
tomorrow : String -> Int
tomorrow today =
case String.toInt today of
Ok day ->
day + 1
Err _ ->
Debug.crash "TODO"
Success! Compiled 1 module.
49 / 73
Elm te obri a a se antecipar a erros
em tempo de execução.
50 / 73
Mas e o Debug.crash?
51 / 73
view : String -> Html msg
view today =
case String.toInt today of
Ok day ->
viewMyApp
Err error ->
viewErroMsg error
52 / 73
Ações de usuário não previstas
4
53 / 73
‑ 41 +
54 / 73
const counter = (state, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1
case 'DECREMENT':
return state - 1
}
}
55 / 73
const counter = (state, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1
case 'DECREMENT':
return state - 1
}
}
const render = () => ReactDOM.render(
<p>
<button onClick={() => store.dispatch({ type: 'DECREMENT'})}>-</button>
{store.getState()}
<button onClick={() => store.dispatch({ type: 'INCREMENT'})}>+</button>
</p>
)
56 / 73
const counter = (state, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1
case 'DECREMENT':
return state - 1
}
}
const render = () => ReactDOM.render(
<p>
<button onClick={() => store.dispatch({ type: 'DECREMENT'})}>-</button>
{store.getState()}
<button onClick={() => store.dispatch({ type: 'INCREMENT'})}>+</button>
</p>
)
+
57 / 73
const counter = (state, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1
case 'DECREMENT':
return state - 1
}
}
const render = () => ReactDOM.render(
<p>
<button onClick={() => store.dispatch({ type: 'DECREMENT'})}>-</button>
{store.getState()}
<button onClick={() => store.dispatch({ type: 'INCREMENT'})}>+</button>
</p>
)
+
42
58 / 73
‑ 21 + x2
59 / 73
const render = () => ReactDOM.render(
<p>
<button onClick={() => store.dispatch({ type: 'DECREMENT'})}>-</button>
{store.getSate()}
<button onClick={() => store.dispatch({ type: 'INCREMENT'})}>+</button>
<button onClick={() => store.dispatch({ type: 'DOUBLE'})}>x2</button>
</p>
)
60 / 73
const render = () => ReactDOM.render(
<p>
<button onClick={() => store.dispatch({ type: 'DECREMENT'})}>-</button>
{store.getSate()}
<button onClick={() => store.dispatch({ type: 'INCREMENT'})}>+</button>
<button onClick={() => store.dispatch({ type: 'DOUBLE'})}>x2</button>
</p>
)
x2
61 / 73
const render = () => ReactDOM.render(
<p>
<button onClick={() => store.dispatch({ type: 'DECREMENT'})}>-</button>
{store.getSate()}
<button onClick={() => store.dispatch({ type: 'INCREMENT'})}>+</button>
<button onClick={() => store.dispatch({ type: 'DOUBLE'})}>x2</button>
</p>
)
x2
21
62 / 73
type Msg = Increment | Decrement
update : Msg -> Int -> Int
update msg model =
case msg of
Increment -> model + 1
Decrement -> model - 1
view : Int -> Html Msg
view model =
p
[]
[ button [ onClick Increment ] [ text "+" ]
, text (toString model)
, button [ onClick Decrement ] [ text "-" ]
]
63 / 73
type Msg = Increment | Decrement
update : Msg -> Int -> Int
update msg model =
case msg of
Increment -> model + 1
Decrement -> model - 1
view : Int -> Html Msg
view model =
p
[]
[ button [ onClick Increment ] [ text "+" ]
, text (toString model)
, button [ onClick Decrement ] [ text "-" ]
]
‑ 21 +
64 / 73
view : Int -> Html Msg
view model =
p
[]
[ button [ onClick Increment ] [ text "+" ]
, text (toString model)
, button [ onClick Decrement ] [ text "-" ]
, button [ onClick Double ] [ text "2x" ]
]
65 / 73
view : Int -> Html Msg
view model =
p
[]
[ button [ onClick Increment ] [ text "+" ]
, text (toString model)
, button [ onClick Decrement ] [ text "-" ]
, button [ onClick Double ] [ text "2x" ]
]
-- NAMING ERROR ------------------------------------------------------- Main.elm
Cannot find variable `Double`
82| , button [ onClick Double ] [ text "2x" ]
66 / 73
type Msg = Increment | Decrement | Double
67 / 73
type Msg = Increment | Decrement | Double
-- MISSING PATTERNS --------------------------------------------------- Main.elm
This `case` does not have branches for all possibilities.
68|> case msg of
69|> Increment ->
70|> model + 1
71|>
72|> Decrement ->
73|> model - 1
You need to account for the following values:
Main.Double
Add a branch to cover this pattern!
68 / 73
update : Msg -> Int -> Int
update msg model =
case msg of
Increment -> model + 1
Decrement -> model - 1
Double -> model * 2
69 / 73
update : Msg -> Int -> Int
update msg model =
case msg of
Increment -> model + 1
Decrement -> model - 1
Double -> model * 2
Success! Compiled 1 module.
70 / 73
A arquitetura do Elm te dá arantia de que todas
as ações dos usuários estão previstas!
71 / 73
“Quem aprendeu al o novo hoje?”
— Raymond Hettin er
72 / 73
Muito obri ado : )
@cuducos
cuducos.me/blo
Vamos aprender Elm!
73 / 73

Más contenido relacionado

La actualidad más candente

Drupal csu-open atriumname
Drupal csu-open atriumnameDrupal csu-open atriumname
Drupal csu-open atriumnameEmanuele Quinto
 
Groovy puzzlers jug-moscow-part 2
Groovy puzzlers jug-moscow-part 2Groovy puzzlers jug-moscow-part 2
Groovy puzzlers jug-moscow-part 2Evgeny Borisov
 
RxSwift 시작하기
RxSwift 시작하기RxSwift 시작하기
RxSwift 시작하기Suyeol Jeon
 
Intro to programming games with clojure
Intro to programming games with clojureIntro to programming games with clojure
Intro to programming games with clojureJuio Barros
 
Python data structures
Python data structuresPython data structures
Python data structuresHarry Potter
 
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFrom java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFabio Collini
 
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2Kevin Chun-Hsien Hsu
 
Python avanzado - parte 1
Python avanzado - parte 1Python avanzado - parte 1
Python avanzado - parte 1coto
 
The Ring programming language version 1.10 book - Part 71 of 212
The Ring programming language version 1.10 book - Part 71 of 212The Ring programming language version 1.10 book - Part 71 of 212
The Ring programming language version 1.10 book - Part 71 of 212Mahmoud Samir Fayed
 
Creating masterpieces with raphael
Creating masterpieces with raphaelCreating masterpieces with raphael
Creating masterpieces with raphaelPippi Labradoodle
 

La actualidad más candente (15)

Drupal csu-open atriumname
Drupal csu-open atriumnameDrupal csu-open atriumname
Drupal csu-open atriumname
 
Groovy puzzlers jug-moscow-part 2
Groovy puzzlers jug-moscow-part 2Groovy puzzlers jug-moscow-part 2
Groovy puzzlers jug-moscow-part 2
 
RxSwift 시작하기
RxSwift 시작하기RxSwift 시작하기
RxSwift 시작하기
 
Intro to programming games with clojure
Intro to programming games with clojureIntro to programming games with clojure
Intro to programming games with clojure
 
Python data structures
Python data structuresPython data structures
Python data structures
 
Library management
Library managementLibrary management
Library management
 
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFrom java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
 
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2
 
Data types
Data typesData types
Data types
 
Lenses
LensesLenses
Lenses
 
Upload text JAVA SCRIPT
Upload text JAVA SCRIPTUpload text JAVA SCRIPT
Upload text JAVA SCRIPT
 
Python avanzado - parte 1
Python avanzado - parte 1Python avanzado - parte 1
Python avanzado - parte 1
 
Rspec and Rails
Rspec and RailsRspec and Rails
Rspec and Rails
 
The Ring programming language version 1.10 book - Part 71 of 212
The Ring programming language version 1.10 book - Part 71 of 212The Ring programming language version 1.10 book - Part 71 of 212
The Ring programming language version 1.10 book - Part 71 of 212
 
Creating masterpieces with raphael
Creating masterpieces with raphaelCreating masterpieces with raphael
Creating masterpieces with raphael
 

Similar a Problemas que o Elm resolve só com o compilador sem nada mais

RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”apostlion
 
Where's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord MigrationsWhere's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord MigrationsEleanor McHugh
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88Mahmoud Samir Fayed
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたAkira Maruoka
 
Polygon.javapublic class Polygon { private int numSides; priva.pdf
Polygon.javapublic class Polygon { private int numSides; priva.pdfPolygon.javapublic class Polygon { private int numSides; priva.pdf
Polygon.javapublic class Polygon { private int numSides; priva.pdfapnafreez
 
Polygon.javapublic class Polygon { private int numSides; priva.pdf
Polygon.javapublic class Polygon { private int numSides; priva.pdfPolygon.javapublic class Polygon { private int numSides; priva.pdf
Polygon.javapublic class Polygon { private int numSides; priva.pdfapnafreez
 
Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS ProgrammersDavid Rodenas
 
JavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your codeJavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your codeLaurence Svekis ✔
 
Idioms in swift 2016 05c
Idioms in swift 2016 05cIdioms in swift 2016 05c
Idioms in swift 2016 05cKaz Yoshikawa
 
Swift 함수 커링 사용하기
Swift 함수 커링 사용하기Swift 함수 커링 사용하기
Swift 함수 커링 사용하기진성 오
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologyDaniel Knell
 
JavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptJavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptLaurence Svekis ✔
 
Structures
StructuresStructures
StructuresSV.CO
 

Similar a Problemas que o Elm resolve só com o compilador sem nada mais (20)

RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”
 
PureScript & Pux
PureScript & PuxPureScript & Pux
PureScript & Pux
 
Where's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord MigrationsWhere's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord Migrations
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
 
Django - sql alchemy - jquery
Django - sql alchemy - jqueryDjango - sql alchemy - jquery
Django - sql alchemy - jquery
 
Polygon.javapublic class Polygon { private int numSides; priva.pdf
Polygon.javapublic class Polygon { private int numSides; priva.pdfPolygon.javapublic class Polygon { private int numSides; priva.pdf
Polygon.javapublic class Polygon { private int numSides; priva.pdf
 
Polygon.javapublic class Polygon { private int numSides; priva.pdf
Polygon.javapublic class Polygon { private int numSides; priva.pdfPolygon.javapublic class Polygon { private int numSides; priva.pdf
Polygon.javapublic class Polygon { private int numSides; priva.pdf
 
Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS Programmers
 
JavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your codeJavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your code
 
Idioms in swift 2016 05c
Idioms in swift 2016 05cIdioms in swift 2016 05c
Idioms in swift 2016 05c
 
Cc code cards
Cc code cardsCc code cards
Cc code cards
 
JavaScript Refactoring
JavaScript RefactoringJavaScript Refactoring
JavaScript Refactoring
 
C++ L09-Classes Part2
C++ L09-Classes Part2C++ L09-Classes Part2
C++ L09-Classes Part2
 
Swift 함수 커링 사용하기
Swift 함수 커링 사용하기Swift 함수 커링 사용하기
Swift 함수 커링 사용하기
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
JavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptJavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScript
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
 
Structures
StructuresStructures
Structures
 

Más de tdc-globalcode

TDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidade
TDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidadeTDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidade
TDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidadetdc-globalcode
 
TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...
TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...
TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...tdc-globalcode
 
TDC2019 Intel Software Day - ACATE - Cases de Sucesso
TDC2019 Intel Software Day - ACATE - Cases de SucessoTDC2019 Intel Software Day - ACATE - Cases de Sucesso
TDC2019 Intel Software Day - ACATE - Cases de Sucessotdc-globalcode
 
TDC2019 Intel Software Day - Otimizacao grafica com o Intel GPA
TDC2019 Intel Software Day - Otimizacao grafica com o Intel GPATDC2019 Intel Software Day - Otimizacao grafica com o Intel GPA
TDC2019 Intel Software Day - Otimizacao grafica com o Intel GPAtdc-globalcode
 
TDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVino
TDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVinoTDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVino
TDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVinotdc-globalcode
 
TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...
TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...
TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...tdc-globalcode
 
TDC2019 Intel Software Day - Inferencia de IA em edge devices
TDC2019 Intel Software Day - Inferencia de IA em edge devicesTDC2019 Intel Software Day - Inferencia de IA em edge devices
TDC2019 Intel Software Day - Inferencia de IA em edge devicestdc-globalcode
 
Trilha BigData - Banco de Dados Orientado a Grafos na Seguranca Publica
Trilha BigData - Banco de Dados Orientado a Grafos na Seguranca PublicaTrilha BigData - Banco de Dados Orientado a Grafos na Seguranca Publica
Trilha BigData - Banco de Dados Orientado a Grafos na Seguranca Publicatdc-globalcode
 
Trilha .Net - Programacao funcional usando f#
Trilha .Net - Programacao funcional usando f#Trilha .Net - Programacao funcional usando f#
Trilha .Net - Programacao funcional usando f#tdc-globalcode
 
TDC2018SP | Trilha Go - Case Easylocus
TDC2018SP | Trilha Go - Case EasylocusTDC2018SP | Trilha Go - Case Easylocus
TDC2018SP | Trilha Go - Case Easylocustdc-globalcode
 
TDC2018SP | Trilha Modern Web - Para onde caminha a Web?
TDC2018SP | Trilha Modern Web - Para onde caminha a Web?TDC2018SP | Trilha Modern Web - Para onde caminha a Web?
TDC2018SP | Trilha Modern Web - Para onde caminha a Web?tdc-globalcode
 
TDC2018SP | Trilha Go - Clean architecture em Golang
TDC2018SP | Trilha Go - Clean architecture em GolangTDC2018SP | Trilha Go - Clean architecture em Golang
TDC2018SP | Trilha Go - Clean architecture em Golangtdc-globalcode
 
TDC2018SP | Trilha Go - "Go" tambem e linguagem de QA
TDC2018SP | Trilha Go - "Go" tambem e linguagem de QATDC2018SP | Trilha Go - "Go" tambem e linguagem de QA
TDC2018SP | Trilha Go - "Go" tambem e linguagem de QAtdc-globalcode
 
TDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendencia
TDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendenciaTDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendencia
TDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendenciatdc-globalcode
 
TDC2018SP | Trilha .Net - Real Time apps com Azure SignalR Service
TDC2018SP | Trilha .Net - Real Time apps com Azure SignalR ServiceTDC2018SP | Trilha .Net - Real Time apps com Azure SignalR Service
TDC2018SP | Trilha .Net - Real Time apps com Azure SignalR Servicetdc-globalcode
 
TDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NET
TDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NETTDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NET
TDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NETtdc-globalcode
 
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8tdc-globalcode
 
TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...
TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...
TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...tdc-globalcode
 
TDC2018SP | Trilha .Net - .NET funcional com F#
TDC2018SP | Trilha .Net - .NET funcional com F#TDC2018SP | Trilha .Net - .NET funcional com F#
TDC2018SP | Trilha .Net - .NET funcional com F#tdc-globalcode
 
TDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor em .Net Core
TDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor  em .Net CoreTDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor  em .Net Core
TDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor em .Net Coretdc-globalcode
 

Más de tdc-globalcode (20)

TDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidade
TDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidadeTDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidade
TDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidade
 
TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...
TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...
TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...
 
TDC2019 Intel Software Day - ACATE - Cases de Sucesso
TDC2019 Intel Software Day - ACATE - Cases de SucessoTDC2019 Intel Software Day - ACATE - Cases de Sucesso
TDC2019 Intel Software Day - ACATE - Cases de Sucesso
 
TDC2019 Intel Software Day - Otimizacao grafica com o Intel GPA
TDC2019 Intel Software Day - Otimizacao grafica com o Intel GPATDC2019 Intel Software Day - Otimizacao grafica com o Intel GPA
TDC2019 Intel Software Day - Otimizacao grafica com o Intel GPA
 
TDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVino
TDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVinoTDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVino
TDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVino
 
TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...
TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...
TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...
 
TDC2019 Intel Software Day - Inferencia de IA em edge devices
TDC2019 Intel Software Day - Inferencia de IA em edge devicesTDC2019 Intel Software Day - Inferencia de IA em edge devices
TDC2019 Intel Software Day - Inferencia de IA em edge devices
 
Trilha BigData - Banco de Dados Orientado a Grafos na Seguranca Publica
Trilha BigData - Banco de Dados Orientado a Grafos na Seguranca PublicaTrilha BigData - Banco de Dados Orientado a Grafos na Seguranca Publica
Trilha BigData - Banco de Dados Orientado a Grafos na Seguranca Publica
 
Trilha .Net - Programacao funcional usando f#
Trilha .Net - Programacao funcional usando f#Trilha .Net - Programacao funcional usando f#
Trilha .Net - Programacao funcional usando f#
 
TDC2018SP | Trilha Go - Case Easylocus
TDC2018SP | Trilha Go - Case EasylocusTDC2018SP | Trilha Go - Case Easylocus
TDC2018SP | Trilha Go - Case Easylocus
 
TDC2018SP | Trilha Modern Web - Para onde caminha a Web?
TDC2018SP | Trilha Modern Web - Para onde caminha a Web?TDC2018SP | Trilha Modern Web - Para onde caminha a Web?
TDC2018SP | Trilha Modern Web - Para onde caminha a Web?
 
TDC2018SP | Trilha Go - Clean architecture em Golang
TDC2018SP | Trilha Go - Clean architecture em GolangTDC2018SP | Trilha Go - Clean architecture em Golang
TDC2018SP | Trilha Go - Clean architecture em Golang
 
TDC2018SP | Trilha Go - "Go" tambem e linguagem de QA
TDC2018SP | Trilha Go - "Go" tambem e linguagem de QATDC2018SP | Trilha Go - "Go" tambem e linguagem de QA
TDC2018SP | Trilha Go - "Go" tambem e linguagem de QA
 
TDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendencia
TDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendenciaTDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendencia
TDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendencia
 
TDC2018SP | Trilha .Net - Real Time apps com Azure SignalR Service
TDC2018SP | Trilha .Net - Real Time apps com Azure SignalR ServiceTDC2018SP | Trilha .Net - Real Time apps com Azure SignalR Service
TDC2018SP | Trilha .Net - Real Time apps com Azure SignalR Service
 
TDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NET
TDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NETTDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NET
TDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NET
 
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
 
TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...
TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...
TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...
 
TDC2018SP | Trilha .Net - .NET funcional com F#
TDC2018SP | Trilha .Net - .NET funcional com F#TDC2018SP | Trilha .Net - .NET funcional com F#
TDC2018SP | Trilha .Net - .NET funcional com F#
 
TDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor em .Net Core
TDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor  em .Net CoreTDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor  em .Net Core
TDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor em .Net Core
 

Último

EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxElton John Embodo
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxJanEmmanBrigoli
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEaurabinda banchhor
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 

Último (20)

EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptx
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSE
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 

Problemas que o Elm resolve só com o compilador sem nada mais

  • 1. Problemas que o Elm resolve só com o compilador sem nada mais @cuducos cuducos.me 1 / 73
  • 7. “O melhor caso de uso de Haskell” — Felipe de Morais 7 / 73
  • 9. Propriedades que podem não existir 1 9 / 73
  • 10. user = { name: 'Eduardo Cuducos', twitter: 'cuducos' } const getSocialMedia = (user) => user.facebook getSocialMedia(user) 10 / 73
  • 11. user = { name: 'Eduardo Cuducos', twitter: 'cuducos' } const getSocialMedia = (user) => user.facebook getSocialMedia(user) undefined 11 / 73
  • 12. class User: def __init__(self, name, twitter): self.name = name self.twitter = twitter user = User('Eduardo Cuducos', 'cuducos') def get_social_media(user): return user.facebook get_social_media(user) 12 / 73
  • 13. class User: def __init__(self, name, twitter): self.name = name self.twitter = twitter user = User('Eduardo Cuducos', 'cuducos') def get_social_media(user): return user.facebook get_social_media(user) AttributeError: 'User' object has no attribute 'facebook' 13 / 73
  • 14. type alias User = { name : String , twitter : String } getSocialMedia : User -> String getSocialMedia user = user.facebook 14 / 73
  • 15. type alias User = { name : String , twitter : String } getSocialMedia : User -> String getSocialMedia user = user.facebook -- TYPE MISMATCH ------------------------------------------------------ Main.elm `user` does not have a field named `facebook`. 15| user.facebook ^^^^^^^^^^^^^ The type of `user` is: User Which does not contain a field named `facebook`. Hint: The record fields do not match up. One has name and twitter. The other has facebook. 15 / 73
  • 16. type alias User = { name : String , twitter : String } getSocialMedia : User -> String getSocialMedia user = user.twitter 16 / 73
  • 17. type alias User = { name : String , twitter : String } getSocialMedia : User -> String getSocialMedia user = user.twitter Success! Compiled 1 module. 17 / 73
  • 18. Elm não te deixa com o undefined na mão! 18 / 73
  • 19. Objetos que podem não existir 2 19 / 73
  • 20. users = [ { name: 'Eduardo Cuducos', twitter: 'cuducos' }, { name: 'Hugo Bessa', twitter: 'hugobessaa' } ] const firstUserName = (users) => users[0].name firstUserName(users) 20 / 73
  • 21. users = [ { name: 'Eduardo Cuducos', twitter: 'cuducos' }, { name: 'Hugo Bessa', twitter: 'hugobessaa' } ] const firstUserName = (users) => users[0].name firstUserName(users) 'Eduardo Cuducos' 21 / 73
  • 23. users = [] firstUserName(users) TypeError: Cannot read property 'name' of undefined 23 / 73
  • 24. users = [ User('Eduardo Cuducos', 'cuducos'), User('Hugo Bessa', 'hugobessaa') ] def first_user_name(users): return users[0].name first_user_name(users) 24 / 73
  • 25. users = [ User('Eduardo Cuducos', 'cuducos'), User('Hugo Bessa', 'hugobessaa') ] def first_user_name(users): return users[0].name first_user_name(users) 'Eduardo Cuducos' 25 / 73
  • 27. users = [] first_user_name(users) IndexError: list index out of range 27 / 73
  • 28. users = [] first_user_name(users) IndexError: list index out of range def first_user_name(users): first_user, *_ = users return first_use.name 28 / 73
  • 29. users = [] first_user_name(users) IndexError: list index out of range def first_user_name(users): first_user, *_ = users return first_use.name ValueError: not enough values to unpack (expected at least 1, got 0) 29 / 73
  • 30. firstUserName : List User -> String firstUserName users = let firstUser = List.head users in firstUser.name 30 / 73
  • 31. firstUserName : List User -> String firstUserName users = let firstUser = List.head users in firstUser.name -- TYPE MISMATCH --------------------------------------------- Main.elm `firstUser` does not have a field named `name`. 29| firstUser.name ^^^^^^^^^^^^^^ The type of `firstUser` is: Maybe User Which does not contain a field named `name`. 31 / 73
  • 32. firstUserName : List User -> String firstUserName users = case List.head users of Just user -> user.name Nothing -> "User not found" 32 / 73
  • 33. firstUserName : List User -> String firstUserName users = case List.head users of Just user -> user.name Nothing -> "User not found" Success! Compiled 1 module. 33 / 73
  • 34. Elm te obri a a preparar a aplicação para casos raros, extremos! 34 / 73
  • 36. const tomorrow = (today) => parseInt(today) + 1 tomorrow('18') 36 / 73
  • 37. const tomorrow = (today) => parseInt(today) + 1 tomorrow('18') 19 37 / 73
  • 40. def tomorrow(today): return int(today) + 1 tomorrow('18') 40 / 73
  • 41. def tomorrow(today): return int(today) + 1 tomorrow('18') 19 41 / 73
  • 43. tomorrow(None) TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' 43 / 73
  • 44. tomorrow(None) TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' tomorrow('NaN') 44 / 73
  • 45. tomorrow(None) TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' tomorrow('NaN') ValueError: invalid literal for int() with base 10: 'NaN' 45 / 73
  • 46. tomorrow : String -> Int tomorrow today = (String.toInt today) + 1 46 / 73
  • 47. tomorrow : String -> Int tomorrow today = (String.toInt today) + 1 -- TYPE MISMATCH ------------------------------------------------------ Main.elm The left argument of (+) is causing a type mismatch. 45| (String.toInt today) + 1 ^^^^^^^^^^^^^^^^^^ (+) is expecting the left argument to be a: number But the left argument is: Result String Int 47 / 73
  • 48. tomorrow : String -> Int tomorrow today = case String.toInt today of Ok day -> day + 1 Err _ -> Debug.crash "TODO" 48 / 73
  • 49. tomorrow : String -> Int tomorrow today = case String.toInt today of Ok day -> day + 1 Err _ -> Debug.crash "TODO" Success! Compiled 1 module. 49 / 73
  • 50. Elm te obri a a se antecipar a erros em tempo de execução. 50 / 73
  • 51. Mas e o Debug.crash? 51 / 73
  • 52. view : String -> Html msg view today = case String.toInt today of Ok day -> viewMyApp Err error -> viewErroMsg error 52 / 73
  • 53. Ações de usuário não previstas 4 53 / 73
  • 54. ‑ 41 + 54 / 73
  • 55. const counter = (state, action) => { switch (action.type) { case 'INCREMENT': return state + 1 case 'DECREMENT': return state - 1 } } 55 / 73
  • 56. const counter = (state, action) => { switch (action.type) { case 'INCREMENT': return state + 1 case 'DECREMENT': return state - 1 } } const render = () => ReactDOM.render( <p> <button onClick={() => store.dispatch({ type: 'DECREMENT'})}>-</button> {store.getState()} <button onClick={() => store.dispatch({ type: 'INCREMENT'})}>+</button> </p> ) 56 / 73
  • 57. const counter = (state, action) => { switch (action.type) { case 'INCREMENT': return state + 1 case 'DECREMENT': return state - 1 } } const render = () => ReactDOM.render( <p> <button onClick={() => store.dispatch({ type: 'DECREMENT'})}>-</button> {store.getState()} <button onClick={() => store.dispatch({ type: 'INCREMENT'})}>+</button> </p> ) + 57 / 73
  • 58. const counter = (state, action) => { switch (action.type) { case 'INCREMENT': return state + 1 case 'DECREMENT': return state - 1 } } const render = () => ReactDOM.render( <p> <button onClick={() => store.dispatch({ type: 'DECREMENT'})}>-</button> {store.getState()} <button onClick={() => store.dispatch({ type: 'INCREMENT'})}>+</button> </p> ) + 42 58 / 73
  • 59. ‑ 21 + x2 59 / 73
  • 60. const render = () => ReactDOM.render( <p> <button onClick={() => store.dispatch({ type: 'DECREMENT'})}>-</button> {store.getSate()} <button onClick={() => store.dispatch({ type: 'INCREMENT'})}>+</button> <button onClick={() => store.dispatch({ type: 'DOUBLE'})}>x2</button> </p> ) 60 / 73
  • 61. const render = () => ReactDOM.render( <p> <button onClick={() => store.dispatch({ type: 'DECREMENT'})}>-</button> {store.getSate()} <button onClick={() => store.dispatch({ type: 'INCREMENT'})}>+</button> <button onClick={() => store.dispatch({ type: 'DOUBLE'})}>x2</button> </p> ) x2 61 / 73
  • 62. const render = () => ReactDOM.render( <p> <button onClick={() => store.dispatch({ type: 'DECREMENT'})}>-</button> {store.getSate()} <button onClick={() => store.dispatch({ type: 'INCREMENT'})}>+</button> <button onClick={() => store.dispatch({ type: 'DOUBLE'})}>x2</button> </p> ) x2 21 62 / 73
  • 63. type Msg = Increment | Decrement update : Msg -> Int -> Int update msg model = case msg of Increment -> model + 1 Decrement -> model - 1 view : Int -> Html Msg view model = p [] [ button [ onClick Increment ] [ text "+" ] , text (toString model) , button [ onClick Decrement ] [ text "-" ] ] 63 / 73
  • 64. type Msg = Increment | Decrement update : Msg -> Int -> Int update msg model = case msg of Increment -> model + 1 Decrement -> model - 1 view : Int -> Html Msg view model = p [] [ button [ onClick Increment ] [ text "+" ] , text (toString model) , button [ onClick Decrement ] [ text "-" ] ] ‑ 21 + 64 / 73
  • 65. view : Int -> Html Msg view model = p [] [ button [ onClick Increment ] [ text "+" ] , text (toString model) , button [ onClick Decrement ] [ text "-" ] , button [ onClick Double ] [ text "2x" ] ] 65 / 73
  • 66. view : Int -> Html Msg view model = p [] [ button [ onClick Increment ] [ text "+" ] , text (toString model) , button [ onClick Decrement ] [ text "-" ] , button [ onClick Double ] [ text "2x" ] ] -- NAMING ERROR ------------------------------------------------------- Main.elm Cannot find variable `Double` 82| , button [ onClick Double ] [ text "2x" ] 66 / 73
  • 67. type Msg = Increment | Decrement | Double 67 / 73
  • 68. type Msg = Increment | Decrement | Double -- MISSING PATTERNS --------------------------------------------------- Main.elm This `case` does not have branches for all possibilities. 68|> case msg of 69|> Increment -> 70|> model + 1 71|> 72|> Decrement -> 73|> model - 1 You need to account for the following values: Main.Double Add a branch to cover this pattern! 68 / 73
  • 69. update : Msg -> Int -> Int update msg model = case msg of Increment -> model + 1 Decrement -> model - 1 Double -> model * 2 69 / 73
  • 70. update : Msg -> Int -> Int update msg model = case msg of Increment -> model + 1 Decrement -> model - 1 Double -> model * 2 Success! Compiled 1 module. 70 / 73
  • 71. A arquitetura do Elm te dá arantia de que todas as ações dos usuários estão previstas! 71 / 73
  • 72. “Quem aprendeu al o novo hoje?” — Raymond Hettin er 72 / 73
  • 73. Muito obri ado : ) @cuducos cuducos.me/blo Vamos aprender Elm! 73 / 73