11th of June 2015 - Functional Programming eXchange - London
(suffering together at late hours might be team-building but surely we don't need this :P)
As seen on LambdaCat:
import Graphics.Element exposing (..)
import Time
import Window
type alias UserInput = {}
userInput : Signal UserInput
userInput = Signal.constant {}
type alias Input =
{ timeDelta : Float
, userInput : UserInput
}
type alias UserInput = {}
userInput : Signal UserInput
userInput = Signal.constant {}
type alias Input =
{ timeDelta : Float
, userInput : UserInput
}
type alias UserInput = {}
userInput : Signal UserInput
userInput = Signal.constant {}
type alias Input =
{ timeDelta : Float
, userInput : UserInput
}
type alias GameState = {}
defaultGame : GameState
defaultGame = {}
display : (Int,Int) -> GameState -> Element
display (w,h) gameState = show gameState
display : (Int,Int) -> GameState -> Element
display (w,h) gameState = show gameState
stepGame : Input -> GameState -> GameState
stepGame {timeDelta,userInput} gameState =
gameState
delta : Signal Float
delta = Time.fps 30
input : Signal Input
input = Signal.sampleOn delta
(Signal.map2 Input delta userInput)
delta : Signal Float
delta = Time.fps 30
input : Signal Input
input = Signal.sampleOn delta
(Signal.map2 Input delta userInput)
gameState : Signal GameState
gameState = Signal.foldp stepGame
defaultGame input
gameState : Signal GameState
gameState = Signal.foldp stepGame
defaultGame input
main : Signal Element
main = Signal.map2 display
Window.dimensions gameState
main : Signal Element
main = Signal.map2 display
Window.dimensions gameState
merge : Signal a ->
apply a function on a signal
returns another, transformed, signal
apply a function on two signals
make a signal that depends on the past values of a signal
foldp : (a -> state -> state) -> state -> Signal a ->
Signal state
foldp takes (a -> state -> state)
a function
... -> state -> ...
a default state
... -> Signal a -> ...
an input signal
... -> Signal state
returns a signal (next state of the program, after applying update)