53. module Main exposing (..)
import Html
import List
numbers =
[ 1, 2, 3 ]
main =
List.map (a -> a * 2) numbers
|> toString
|> Html.text
54. podemos utilizar o operador
de composição >> para fazer
composição de funções
55. module Main exposing (..)
import Html
import List
double x =
x * 2
plus1 x =
x + 1
doublePlus1 =
double >> plus1
main =
List.map doublePlus1 [ 1, 2, 3 ]
|> toString
|> Html.text
59. module Main exposing (..)
import Html
import String
joinUpper x y =
let
text =
x ++ y
in
String.toUpper text
main =
joinUpper "hello " "world"
|> Html.text
69. module Main exposing (..)
import Html
import String
person =
{ name = "James", age = 42 }
newPerson =
{ person | age = 32 }
main =
"My age is "
++ (toString newPerson.age)
|> Html.text
71. as union types assemelham-
se a enumerações de tipos
diferentes
72. type Msg
= Edit Player
| Score Player Int
| Input String
| Save
| Cancel
| DeletePlay Play
73. os type aliases permite criar
novos tipos a partir de tipos
existentes
74. type alias Player =
{ id : Int
, name : String
, points : Int
}
type alias Play =
{ id : Int
, playerId : Int
, name : String
, points : Int
}
type alias Model =
{ players : List Player
, name : String
, playerId : Maybe Int
, plays : List Play
}
75. o tipo Maybe é uma union
type que pode ter ou não um
valor