/virtual-dom

Haskell (GHCJS) bindings to the virtual-dom project

Primary LanguageHaskellBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

virtual-dom

This library provides Haskell (GHCJS) bindings to the virtual-dom project. virtual-dom is a set of Javascript libraries to allow one to build a functional representation of the browser DOM in a declarative manner, and efficiently render these changes into the DOM.

These bindings provide:

  • A lens interface to building elements and setting their attributes.
  • A lucid-like DSL for building HTML documents - with functions for all HTML 5 elements and attributes.
  • The ability to register hooks.
  • The ability to attach event handlers by using dom-delegator.

For a small example of how this library can be used, see below

{-# LANGUAGE OverloadedStrings #-}
import VirtualDom

main :: IO ()
main =
  do body <- bodyContainer
     initDomDelegator
     renderTo body
              (with body_
                    (on "click" (const (putStrLn "Ouch")))
                    [into h1_ ["Heading"]])