my adventure with elm (polyconf 16)

Post on 18-Jan-2017

2.996 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

My adventure with

SCORE 42

by Yan Cui

ELM

@theburningmonk

start of my ELM journey

things have

moved

on…

The Elm Architecture

remember Day 1?

state

Msg

update

init

new state

- every Erlang programmer

side-effects!

state

Msg

update

init

new state

Msg

state

Msg

update

init

subscriptions

Msgnew state

Msg

state

Msg

update

init

subscriptions

Msgnew state

view

Msg

state

Msg

update

init

subscriptions

Msgnew state

view

Msg

Msg

state

Msg

update

init

subscriptions

Msgnew state

view

Msg

Msg

@theburningmonk

x = { age=42, name=“foo” }

@theburningmonk

-- clone and updatey = { x | name = "bar" }

@theburningmonk

type alias Character = { age : Int, name : String }

@theburningmonk

type Tree = | Leaf| Branch Tree

@theburningmonk

Demo

8 segments

direction

change

changeno changenot allowed

directionw

a s d

direction

direction

direction

direction

direction

cherry

direction

YUM YUM YUM!

direction

+1 segment

@theburningmonk

Demo

@theburningmonk

github.com/theburningmonk/elm-snake

@theburningmonk

elm-lang.org/try

@theburningmonk

guide.elm-lang.org

@theburningmonktheburningmonk.comgithub.com/theburningmonk

top related