Haskell interactive serverside web framework inspired by HTMX
Go to file
2024-05-21 11:56:51 -07:00
bin tests 2024-03-07 12:02:52 -07:00
client fixed load listener 2024-05-15 09:22:57 -07:00
example test, web-view 2024-05-21 11:56:51 -07:00
src/Web docs 2024-05-21 11:29:29 -07:00
test test, web-view 2024-05-21 11:56:51 -07:00
.gitignore initial commit post-separation 2023-11-27 12:17:08 -06:00
.hlint.yaml messing with forms 2023-11-29 14:29:04 -06:00
cabal.project test, web-view 2024-05-21 11:56:51 -07:00
CHANGELOG.md initial commit post-separation 2023-11-27 12:17:08 -06:00
fourmolu.yaml Forms are nice. Formatting 2023-12-04 09:57:53 -06:00
hyperbole.cabal test, web-view 2024-05-21 11:56:51 -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 test, web-view 2024-05-21 11:56:51 -07:00
README.md test, web-view 2024-05-21 11:56:51 -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 #-}

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, Param)

data MessageAction = Louder Text
  deriving (Generic, Param)

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 different features

Run the examples in this repo using cabal. Then visit http://localhost:3000/ in your browser

cabal run

In Production