You need to change <something>,
or multiple somethings
a button is pressed/
a variable changed/
an event happens/
Many names for the same underlying concept
Missed first event
Ref: FRP Manning book
(depends on listener ordering)
(initialisation order problem)
imperative perspective : explicit ordering
reactive perspective : explicit dependencies
imperative perspective : sequence
reactive perspective : dependency
instead of your custom control flow
Missed first event Callbacks pyramids
Threading issues (a bit)
• throw any exceptions handled outside of the function
• reading the value of any mutable external variable
• mutate any externally visible state
• keeping state around between invocations of the function
Basically no Side Effects allowed:
The property that the meaning of an expression is determined by the meanings of its parts and the rules used to combine them.
Being able to compose functions:
add : Int -> Int add n1 = n1 + 2 mult : Int -> Int mult n1 = n1 * 2 composedFunction = add >> multiply > composedFunction 4 12 : number
Let's try again...
(Referential Transparency & Immutability)
(not lazy like Haskell)
(similar to Haskell)
add : Int -> Int
Is the signature of a function that takes an Integer and returns an Integer.
add : Int -> Int -> Int
Is the signature of a function that takes two Integers and returns an Integer.
If you partially apply a function, by giving it less arguments than it takes, it will return a function that takes the remaining args:
add : Int -> Int -> Int
add n1 n2 = n1 + n2 > addTen = add 10 <function> : Int -> Int > addTen 1 11 : number
The main function is the entry point of program execution, so you need one, or your code won't run.
It is wired to one or more Signals that drive the whole application.
(Similar to Map, a Fold reduces, say, a List to one value, by applying a function to the entries)
( Update function )
( default value )
(next program state signal)
type Tile = Door Size | Column | BackGround BackGroundTile | Shadow ShadowTile
type Maybe a = Just a | Nothing
case maybeVar of Just a -> a Nothing -> "default value"
Action Model init : (Model, Effects Action) update : Action -> Model -> (Model, Effects Action) view : Signal.Address Action -> Model -> Html
(often a Record (similar to js object))
Update generates the next state of the program by
pattern matching on Actions
using a Model defined
using Union Types and Records
View renders that next state
no loops, rather mapping and folding
only mutate indirectly in fold (by returning value)
See you on twitter :)