• Stars
    star
    138
  • Rank 258,786 (Top 6 %)
  • Language
    Haskell
  • License
    BSD 3-Clause "New...
  • Created about 5 years ago
  • Updated over 3 years ago

Reviews

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

Repository Details

Server-side VDOM UI framework for Concur

concur-replica

CircleCI

Build interactive web UIs using nothing but Haskell.

No user-written JS. No transpiler.

How?!

Replica: a remote virtual DOM library. Clients run a fixed JavaScript snippet which opens a connection to your Haskell server. The client uses it to notify the server of browser events, and the server uses it to send DOM updates to be applied by the client.

Concur: a UI framework that reifies time and as such generalizes the Elm architecture. It's based around Widgets, sections of the UI that may return a value.

Upsides and downsides

This strategy is well understood due to its use by Phoenix LiveView (among other projects).

There are two situations where you should rule concur-replica out completely:

  • Realtime client-side feedback is required (this is rarely the case)

  • It needs to work offline

The strategy also has two softer costs:

  • Events and updates cost bandwidth (e.g. listening to mouse position, or doing an animation in Haskell instead of CSS)

  • It puts a heavier load on your server than a traditional stateless webapp

Additionally, concur-replica is alpha software so it currently has additional deficiencies. Check the issue tracker for these, and they'll be fixed as it matures.

Despite these caveats however, concur-replica has incredible benefits. No JS! No REST API layer -- you can call whatever Haskell functions you want directly from your UI code. concur is an awesome way of making UIs. And you have the Haskell classics: STM is absolutely unfair for building collaborative apps, and UIs are so annoying to test that the type system really shines.

Obligatory counter example

{-# LANGUAGE OverloadedStrings #-}

module Main where

import Concur.Core
import Concur.Replica

import Prelude hiding (div)

counter :: Int -> Widget HTML a
counter x = do
  click <- div []
    [ Left  <$> div [ onClick ] [ text "-" ]
    , text $ T.pack $ show x
    , Right <$> div [ onClick ] [ text "+" ]
    ]

  case click of
    Left _  -> counter (x - 1)
    Right _ -> counter (x + 1)

main :: IO ()
main = runDefault 8080 "Counter" (counter 0)

Projects using concur-replica

Running the examples

stack build
stack exec concur-replica-(calc|hilo|menu|misc|multi-entry|select|routing|website|chat)

Point your browser to http://localhost:8080 and behold the remote VDOM goodness.

More Repositories

1

atea

A minimalistic menu bar time tracker for MacOS
Clojure
613
star
2

leerraum.js

A PDF typesetting library with exact positioning and hyphenated line breaking
TypeScript
231
star
3

replica

A remote virtual DOM library for Haskell
Haskell
132
star
4

typedraw

Visually describe Haskell/Purescript/Elm types
JavaScript
105
star
5

concur-static

Generate semi-dynamic UIs with Concur
Haskell
58
star
6

purescript-refract

Optical Purescript UI library based on React and the Elm architecture, but without the boilerplate.
PureScript
48
star
7

knit

Ties the knot on data structures that reference each other by unique keys
Haskell
46
star
8

sherlock

Structured json log viewer in the browser
JavaScript
20
star
9

synchron

Synchronous programming in Haskell
Haskell
15
star
10

formulae

Mirror of ftp://ftp.cs.uni-sb.de/formulae - "A Functional Description of TeX's Formula Layout"
Standard ML
12
star
11

atea-contrib

User contributed content for Atea
8
star
12

ytools

A set of structured composable unix tools
Haskell
8
star
13

purescript-interop

Generate Purescript types from Haskell
Haskell
7
star
14

memdb

Efficient in memory indexed database
Haskell
6
star
15

fbookmark

A file based bookmark plugin for Pentadactyl
JavaScript
6
star
16

usercfg

usercfg — remote account configuration protocol
Haskell
5
star
17

purescript-trace

Easily trace function arguments in Purescript.
JavaScript
4
star
18

bookkeeper-permissions

Permissions for bookkeeper records
Haskell
4
star
19

quadtree

Mutable and immutable fast quadtrees
Haskell
3
star
20

refract-replica

Refract backend for Replica
Haskell
3
star
21

purescript-thermite-login-component

Login component for purescript-thermite based on purescript-sync-websockets
PureScript
3
star
22

atea.vim

Atea vim plugin
Vim Script
3
star
23

hyde

A simple Haskell HTML templating engine
Haskell
2
star
24

quadtree-acid

Haskell quad tree experiments
Haskell
2
star
25

leibniz

Approximating nested GADTs/Leibniz equality
Haskell
2
star
26

tellme_api

API backend for telll.me
Erlang
2
star
27

concur-replica-components

Haskell
2
star
28

elm-gen

Autogenerate Elm plumbing
Elm
2
star
29

tellme

A minimalist 1on1 web chat
Clojure
2
star
30

TC

Haskell
2
star
31

dotfiles

Vim Script
2
star
32

distributed-stm

Haskell
2
star
33

concur-core

Testable Concur core model
Haskell
2
star
34

generative-purescript

Generative art experiments in Purescript
JavaScript
2
star
35

typesafe-query

Haskell
1
star
36

typesafe-query-mongodb

Haskell
1
star
37

purescript-relational

PureScript
1
star
38

jdic-macos-tray

A low-level JNI MacOS menu bar integration for Java
Objective-C
1
star
39

purescript-sync-websockets

Purescript client for sync-websockets
JavaScript
1
star
40

stm-store

Transactional database experiment based on Haskell's STM (and unsafeIOToSTM)
Haskell
1
star
41

users-remote

User auth microservice based on users-postgresql-simple and msgpack
Haskell
1
star
42

reentrant

Experiments related to http://www.reddit.com/r/haskell/comments/344x6d/manage_nonreentrant_blocking_code
Haskell
1
star
43

elm-refactor

Haskell
1
star
44

bptree

B+ tree in Typescript (ported from Haskell)
Haskell
1
star
45

raycaster

JavaScript
1
star
46

react-optics

Haskell
1
star
47

purescript-refract-todomvc

purescript-refract Todo MVC example.
CSS
1
star
48

safedata-aeson

Haskell
1
star
49

ocean

WebGL ocean demo
Java
1
star
50

channels-websockets

Haskell
1
star
51

allseeingeye

Experimental code similarity detection tool
Haskell
1
star
52

sync-websockets

Synchronous websocket communication
Haskell
1
star
53

haskell-ajax-cont

Asynchronous http requests using the continuation monad
Haskell
1
star
54

safedata-bson

Haskell
1
star