Haskell interactive serverside web framework inspired by HTMX
Go to file
Christian Georgii fddf8f0e7c CI with nix
2024-07-24 17:11:32 +02:00
.github/workflows CI with nix 2024-07-24 17:11:32 +02:00
bin better dev workflow by porting code into examples 2024-06-14 08:11:44 -07:00
client Add dev environment with nix 2024-07-19 15:19:01 +02:00
example -threaded example 2024-07-22 09:23:39 -07:00
src/Web Contacts Example: add contact 2024-07-18 10:24:44 -07:00
test Apply hlint to entire codebase and enable pre-commit check 2024-07-19 18:32:40 +02:00
.envrc Add dev environment with nix 2024-07-19 15:19:01 +02:00
.gitignore Add dev environment with nix 2024-07-19 15:19:01 +02:00
.hlint.yaml Apply hlint to entire codebase and enable pre-commit check 2024-07-19 18:32:40 +02:00
cabal.project Add dev environment with nix 2024-07-19 15:19:01 +02:00
CHANGELOG.md initial commit post-separation 2023-11-27 12:17:08 -06:00
flake.lock Add dev environment with nix 2024-07-19 15:19:01 +02:00
flake.nix CI with nix 2024-07-24 17:11:32 +02:00
fourmolu.yaml Apply formatting to entire codebase and enable pre-commit check 2024-07-19 18:19:06 +02:00
hyperbole.cabal bump web-view version 2024-07-02 12:53:08 -07:00
LICENSE initial commit post-separation 2023-11-27 12:17:08 -06:00
package-lock.json counter example 2024-05-15 09:23:02 -07:00
package.yaml bump web-view version 2024-07-02 12:53:08 -07:00
README.md Merge pull request #18 from cgeorgii/cgeorgii/dev 2024-07-19 08:24:04 -07:00

Hyperbole

Hackage

Create fully interactive HTML applications with type-safe serverside Haskell. Inspired by HTMX, Elm, and Phoenix LiveView

Learn more about Hyperbole on Hackage

{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}

import Data.Text (Text)
import Web.Hyperbole

main = do
  run 3000 $ do
    liveApp (basicDocument "Example") (page mainPage)


mainPage = do
  handle message
  load $ do
    pure $ do
      el bold "My Page"
      hyper (Message 1) $ messageView "Hello"
      hyper (Message 2) $ messageView "World!"


data Message = Message Int
  deriving (Generic, ViewId)

data MessageAction = Louder Text
  deriving (Generic, ViewAction)

instance HyperView Message where
  type Action Message = MessageAction


message :: Message -> MessageAction -> Eff es (View Message ())
message _ (Louder m) = do
  let new = m <> "!"
  pure $ messageView new


messageView m = do
  el_ $ text m
  button (Louder m) id "Louder"

Examples

The example directory contains an app with pages demonstrating various features

Learn More

View Documentation on Hackage

View on Github

In Production

National Solar Observatory

The NSO uses Hyperbole for the L2 Data creation UI for the DKIST telescope

Local Development

Dependencies

With nix

With nix installed, you can use nix develop to get a shell with all dependencies installed.

Tip: If you have direnv as well, you can run direnv allow once and every time you open a shell in this directory, it will automatically load the environment.


#### Manual dependency installation

Download and install [NPM](https://nodejs.org/en/download). On a mac, can be installed via homebrew:

brew install npm


Install client dependencies

cd client npm install



### Building

Build JavaScript client

cd client npx webpack


Run examples

cd example cabal run


### Tests

cabal test


### File watching

Run tests, then recompile everything on file change and restart examples

bin/dev



Contributors
------------

* [Sean Hess](seanhess)
* [Kamil Figiela](https://github.com/kfigiela)