Introduction

[A WORK IN PROGRESS - NOT THAT USEFUL YET!]

Kuljet is a happy little language for writing database-backed HTML applications. Its type checking and integration with relational databases should help you whip up prototypes in no time.

It aims to answer the question "What if a Haskeller designed PHP?" despite nobody having asked it.

Features:

Hello World

serve get / = "Hello World!"

Example

Here's a simple chat application

table messages { message : text, timestamp : timestamp }

serve get / =
  let template = fun content ->
    html [ head (link { href = "/style.css", rel = "stylesheet" })
         , body content
         ]
  in
  let messagesHtml =
    let query = (messages order timestamp desc limit 100) order timestamp asc in
    div { class = "messages" }
      (query select { message } -> div { class = "message" } message)
  in
  let formHtml =
    let formAttrs = { method = "POST", action = "/msg", class = "inputForm" } in
    let nameInput = input { name = "message", class = "inputMessage", autofocus = "true" } in
    let submitInput = input { type = "submit" } in
    form formAttrs [ nameInput, submitInput ]
  in
  template [ messagesHtml, formHtml ]

serve post /msg =
  fun formVars: { message: text } ->
    insert messages { message = formVars.message, timestamp = now } then
    redirect "/"

serve get /style.css =
  file "text/css" "style.css"

Running the Example

cd examples/chat && kuljet serve chat.kj