aboutsummaryrefslogtreecommitdiff
path: root/src/lustre.gleam
blob: 0f119b1d58e7b7d13e61978f467e57d03336ec07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
////


// IMPORTS ---------------------------------------------------------------------

import lustre/element
import lustre/attribute


// TYPES -----------------------------------------------------------------------

///
pub opaque type Program(state, action) {
    Program(
        init: state,
        update: Update(state, action),
        render: View(state, action)
    )
}


///
pub type Element(action) = element.Element(action)
///
pub type Attribute(action) = attribute.Attribute(action)


/// 
type Update(state, action) = fn (state, action) -> state
type Render(state, action) = fn (state) -> Element(action)


// CONSTRUCTORS ----------------------------------------------------------------

///
pub fn program (init: state, update: Update(state, action), render: Render(state, action)) -> Program(state, action) {
    Program(init, update, render)
}


// EFFECTS ---------------------------------------------------------------------

///
pub external fn start (program: Program(state, action), selector: String) -> Nil
    = "./lustre/ffi.mjs" "mount"