How to structure an Elm project?
type Task =
Task
{ name : String
, completed : Bool
}
createTask : String -> Task
completeTask : Task -> Task
type Form a =
Valid a
| Invalid a
| Partial a
validate : (Form a -> Form ()) -> Form a -> Form a
type alias TaskForm =
{ name : String
, validated : Bool
}
validateTaskForm : Form TaskForm -> Form ()
type User =
User
{ name : String
, lastOnline : Posix
}
createUser : String -> Posix -> User
type alias UserForm =
{ name : String
, password : String
, validated : Bool
}
validateUserForm : Form UserForm -> Form ()
type alias TodoPageModel =
{ form :
Form TaskForm
, todo : Array Task
, User : User
}
type alias LoginPageModel =
Form UserForm
type Model =
LoginPage LoginPageModel
| TodoPage TodoPageModel
type LoginPageMsg =
NameEntered String
| PasswordEntered String
| Submited
| GotTime Posix
type TodoPageMsg =
LoggedOut
| TaskAdded String
| TaskCompleted Int
| TaskDeleted
type Msg =
LoginSpecific LoginPageMsg
| TodoSpecific TodoPageMsg
init : () -> Model
updateTodoPage : TodoPageModel -> (TodoPageModel, Cmd TodoPageMsg)
updateLoginPage : LoginPageModel -> (LoginPageModel, Cmd LoginPageMsg)
update : Msg -> (Model, Cmd Msg) -> (Model, Cmd Msg)
viewUserForm : Form UserForm -> Html Msg
viewLoginPage : LoginPageModel -> Html Msg
viewTask : Task -> Html Msg
viewTaskForm : Form TaskForm -> Html Msg
viewTodoPage : TodoPageModel -> Html Msg
view : Model -> Html Msg
subscription : Model -> Sub MsgexposQuestion
Answer
Further reading
Last updated