• Stars
    star
    123
  • Rank 282,321 (Top 6 %)
  • Language PureScript
  • License
    Apache License 2.0
  • Created about 2 years ago
  • Updated 18 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A PureScript web UI framework

purescript-deku

deku

A PureScript web framework for apps that need to be fast.

In anger

Documentation

Here is a guide to building apps with Deku. The guide is written in Deku and its source code can be found here. You should probably start your Deku journey with this guide. It contains everything you need to build a Deku app, from bootstrapping a project to Hello World to a Discord clone!

Indexed documentation for Deku is published on Pursuit. Deku's structure is currently highly decentralized, so it can be tough to know where to look. Here's a small Deku app that acts as a legend for the Pursuit docs.

main :: Effect Unit
main =
  -- `Deku.Toplevel` contains runInBody
  -- and other functions for hydration and SSR
  runInBody myNut
  where
  -- `Deku.Core` contains the `Nut` type, which is the type
  -- of all Deku applications.
  myNut :: Nut
  myNut = 
    -- `Deku.Do`` is the rebindable do context that allows you
    -- to use hooks in Deku
    Deku.do
      -- `Deku.Hooks` contains hooks like `useState`,
      -- `useDyn`, and `useMemoized`
      setCounter /\ counter <- useState 0
      -- `Deku.DOM`, often imported as `D`, contains all DOM elements,
      -- attributes, and event handlers
      D.div
          [
            -- `Deku.Listeners` contains helper functions for various common
            -- listeners like `click` and `keyUp`
            click $ counter <#> add 1 >>> setCounter
          -- `Deku.Attributes` contains helper functions for various common
          -- attributes like `style` and `klass` (an alias for `class`)
          , klass_ "color: crimson;"
          -- `Deku.CSS` contains `render`, which allows you to take `CSS` from
          -- `purescript-css` and use it in a Deku application
          , style_ $ render do
              color (rgb 42 142 242)
              fontWeight bold
          -- `Deku.Attribute` contains constructors for
          -- uncommon and ad hoc `x-` attributes
          , pure (xdata "my-attr" "my-val")
          ]
        [
          -- `Deku.Control` contains all non-element buiding blocks
          -- for applications, including `text` and `<#~>`, which
          -- allows you to switch between elements.
          text (show <$> counter)
        -- `Deku.Pursx` contains the `~~` operator, which allows you to
        -- construct typesafe Deku using plain old html.
        , (Proxy :: _ "<p>Now you're a Deku ~adj~</p>") ~~
            { adj: text
                (counter <#> mod 2 >>> eq 0 >>> if _ then "newb" else "master")
            }
        ]

So, in summary, ignore the voluminous number of modules in Deku (which makes browsing Pursuit difficult) and focus on the modules used in the example above, namely:

There are a few more modules to be aware of for advanced usage:

  • Deku.Lifecycle contains methods for arbitrary side effects to run when the Deku Nuts mount and dismount from the DOM.
  • Deku.Pursx.Anonymous contains an experimental pursx syntax that could theoretically be made better by Visible Type Applications. As that feature develops, if the syntax becomes ergonomic, it may supersede the current pursx syntax.
  • Deku.Interpret is for folks that wish to build a custom Deku backend. Deku currently supports Single-page applications (the default), static site rendering, and hydrated static site rendering.

Deku is a small codebase. All of the heavy lifting is done via primitives from purescript-hyrule, the documentation of which is also on Pursuit.

Why another web framework?

Deku aims to be:

  • fast: it's up to 2x faster than Halogen for a simple Todo MVC app.
  • small: the average Deku program tends to be fewer lines of code than its React or Halogen counterparts.
  • ssr-friendly: Deku has out-of-the-box server-side rendering capabilities.

What does Deku mean?

Deku is short for "DOMs Emitted as Kan-extended Universals." It is also the tree of Zelda lore and is a Japanese diminutive for a dullard or simpleton.

More Repositories

1

purescript-ocarina

Web audio graphs as a stream
PureScript
58
star
2

purescript-audio-behaviors

DSP in the browser using the behavior pattern.
PureScript
41
star
3

wagsi

A 100% browser-based interactive live audio coding environment.
PureScript
39
star
4

plzwrk

A Haskell front-end framework
Haskell
36
star
5

purescript-halogen-ihooks

A hooks library for purescript-halogen
PureScript
17
star
6

purescript-freer-free

Boilerplate-eliminator when working with free monads.
PureScript
15
star
7

klank.dev

Sound for all!
PureScript
14
star
8

joyride

A rhythm game to play with friends and frenemies
PureScript
14
star
9

purescript-deku-realworld

A realworld implementation using purescript-deku
PureScript
9
star
10

purescript-jit

PureScript
8
star
11

purescript-everythings-better-with-variants

Cuz everything's better with variants
PureScript
8
star
12

purescript-three

PureScript
8
star
13

purescript-rito

A three.js port backed by purescript-event
PureScript
7
star
14

deku-documentation

Documentation for the purescript-deku project
PureScript
7
star
15

purescript-bolson

An FRP application builder
PureScript
6
star
16

purescript-wags-lib

A standard library for working with web-audio control data
PureScript
6
star
17

purescript-react-basic-hooks-example

Small example using react-basic-hooks and webpack
Dhall
5
star
18

purescript-routing-link

Dhall
5
star
19

purescript-vec-dt

Dependently-typed vectors in purescript
PureScript
5
star
20

purescript-row-options

Optional values using rows
PureScript
5
star
21

in-a-sentimental-mood

In a Sentimental Mood by Duke Ellington
PureScript
4
star
22

purescript-sytc

Scala-like traits in PureScript
PureScript
4
star
23

wall

The Wall programming language
4
star
24

purescript-deku-starter

JavaScript
4
star
25

evseq

A simple event sequencer for Node.js
JavaScript
4
star
26

purescript-deku-ionic

PureScript
3
star
27

purescript-typelevel-rationals

Typelevel rationals in PureScript
PureScript
3
star
28

purescript-deku-toplevel

Helper functions for inserting a deku app into the DOM
Dhall
3
star
29

purescript-rx-hyrule

Dhall
3
star
30

sf

Learning about functional programming through sound and sound through functional programming
PureScript
3
star
31

survey-2023

PureScript 2023 Survey
PureScript
3
star
32

purescript-browser-file-system

Exposes the browser file system API in PureScript
PureScript
3
star
33

purescript-painting

Declarative canvas rendering in PureScript
PureScript
3
star
34

hash-modulo-alpha-ps

A purescript port of Microsoft Research's hash-modulo-alpha
PureScript
3
star
35

fouriax

A port of Christian Steinmetz's auraloss for jax.
Python
3
star
36

substructural-typing-systems

PureScript
2
star
37

e101

PureScript
2
star
38

repl-hacks

Wagging the PureScript repl
PureScript
2
star
39

svg

Implements an svg visual backend for Faust
JavaScript
2
star
40

sliders

How to use sliders in wags
PureScript
2
star
41

wags-course

A course on purescript-wags
2
star
42

purescript-monoid-extras

A straight-up port of Haskell's monoid-extras
PureScript
2
star
43

purescript-typelevel-graph

Typelevel assertions about graphs
PureScript
2
star
44

purescript-ez3

No-frills purescript bindings for three.js
Python
2
star
45

favorite-things

Java
2
star
46

nature-boy

Nature boy on klank.dev
PureScript
2
star
47

organdiae

A tool for mind mapping in the Python interpreter.
Python
2
star
48

create-deku-app

A template to create a deku app
JavaScript
2
star
49

type.klank.dev

Types for typesafe audio on klank.dev
PureScript
2
star
50

ep_wags

A wags plugin for etherpad
PureScript
2
star
51

docs.wags.fm

Documentation for purescript-wags
PureScript
2
star
52

wags-js

JS and TS bindings for some of PureScript Wags
TypeScript
2
star
53

a-felicidade

A felicidade no klank.dev
PureScript
2
star
54

purescript-deku-todo-mvc

A simple TODO MVC in Deku
PureScript
2
star
55

sad-unloved-project

1
star
56

purescript-halogen-cf

PureScript
1
star
57

jim_2015

Tabarnak ! Ostie ! Sacrament ! Câlice ! Torrieux ! Étole !
TeX
1
star
58

purescript-phantom-event

Dhall
1
star
59

my-reason-react-app

OCaml
1
star
60

learning-erlang

Erlang
1
star
61

purescript-deku-benchmarks

Dhall
1
star
62

fraggle

Lightweight DOM fragments
JavaScript
1
star
63

purescript-backoff

Dhall
1
star
64

purescript-frp-examples

Dhall
1
star
65

ab2gv

Audio behavior graphs to graphviz
JavaScript
1
star
66

saw

Score of Sit Ozfårs Wysr
LilyPond
1
star
67

braque

A compile-time model creation framework for Java
Java
1
star
68

ahc-cabal-bug-minimal-example

Minimal example for https://github.com/tweag/asterius/issues/623
Haskell
1
star
69

gliss

Documents for gliss
1
star
70

ballonrouge

JavaScript
1
star
71

rhythm-game-sketch

PureScript
1
star
72

apollo-client-hello-mutations

Simple apollo client for testing mutations
JavaScript
1
star
73

notation-in-the-21st-century

Python
1
star
74

purescript-meh

Mike's Event Hacks
Dhall
1
star
75

notify-me

A test of lots of notifications systems
Vue
1
star
76

capacitor-test

JavaScript
1
star
77

property-based-testing-sketch

1
star
78

cradle-multi-project-buildsrc

Java
1
star
79

afl-api-test-1

JavaScript
1
star
80

the-tragedy-of-intent-iv

Python
1
star
81

wags.fm

PureScript
1
star
82

walking-in-the-air

We're Walking in the Air
PureScript
1
star
83

obsessions

LilyPond
1
star
84

lots-of-notes

Lots of notes
PureScript
1
star
85

pureconf-2022

Dhall
1
star
86

feedback

Experiments with feedback loops using purescript-wags
PureScript
1
star
87

BlueprintOSS

Using OSS with blueprint
1
star
88

ray-tracing-in-one-weekend-webgpu

Attempting to get ray tracing in one weekend to run at 60fps in a browser!
PureScript
1
star
89

Statuts-LilyPond

Les statuts de l'association loi de 1901 lilypondienne
1
star
90

ug-ionic

PureScript
1
star