Skip to content

Commit

Permalink
better dev workflow by porting code into examples
Browse files Browse the repository at this point in the history
  • Loading branch information
seanhess committed Jun 14, 2024
1 parent 89ba95f commit 0a175eb
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 71 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ The NSO uses Hyperbole for the [L2 Data creation UI](https://github.com/DKISTDC/
Local Development
-----------------

### Dependencies

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

```
Expand All @@ -100,6 +102,9 @@ cd client
npm install
```


### Building

Build JavaScript client

```
Expand All @@ -110,16 +115,19 @@ npx webpack
Run examples

```
cabal run examples
cd example
cabal run
```

Run Tests
### Tests

```
cabal test
```

Watch for file changes and recompile everything
### File watching

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

```
bin/dev
Expand Down
6 changes: 4 additions & 2 deletions bin/dev
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ package() {
}

compile() {
ghcid --command "cabal repl examples" -T Main.main -W
cd example
ghcid -T main -W
}

client() {
cd client && npx webpack -w
cd client
npx webpack -w
}

# run tests once (so we don't forget!)
Expand Down
3 changes: 2 additions & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Hyperbole Examples
This directory contains an example application with multiple pages demonstrating different features. To try them out:

```
cabal run examples
cd example
cabal run
```

Then visit http://localhost:3000/
Expand Down
3 changes: 3 additions & 0 deletions example/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages:
.
../
1 change: 1 addition & 0 deletions example/client
89 changes: 89 additions & 0 deletions example/hyperbole-examples.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
cabal-version: 2.2

-- This file has been generated from package.yaml by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack

name: hyperbole-examples
version: 0.3.6
synopsis: Interactive HTML apps using type-safe serverside Haskell
description: Interactive HTML applications using type-safe serverside Haskell. Inspired by HTMX, Elm, and Phoenix LiveView
category: Web, Network
homepage: https://github.com/seanhess/hyperbole
bug-reports: https://github.com/seanhess/hyperbole/issues
author: Sean Hess
maintainer: seanhess@gmail.com
license: BSD-3-Clause
license-file: LICENSE
build-type: Simple

source-repository head
type: git
location: https://github.com/seanhess/hyperbole

executable woot
main-is: Main.hs
other-modules:
Web.Hyperbole
Web.Hyperbole.Application
Web.Hyperbole.Effect
Web.Hyperbole.Embed
Web.Hyperbole.Forms
Web.Hyperbole.HyperView
Web.Hyperbole.Param
Web.Hyperbole.Route
Web.Hyperbole.Session
Web.Hyperbole.View
BulkUpdate
Example.Colors
Example.Concurrent
Example.Contacts
Example.Counter
Example.Effects.Debug
Example.Effects.Users
Example.Errors
Example.Forms
Example.LazyLoading
Example.Redirects
Example.Sessions
Example.Simple
Example.Style
Example.Transitions
HelloWorld
Paths_hyperbole_examples
autogen-modules:
Paths_hyperbole_examples
hs-source-dirs:
../src
./
default-extensions:
OverloadedStrings
OverloadedRecordDot
DuplicateRecordFields
NoFieldSelectors
TypeFamilies
DataKinds
DerivingStrategies
DeriveAnyClass
ghc-options: -Wall -fdefer-typed-holes
build-depends:
base
, bytestring
, casing
, containers
, cookie
, effectful
, file-embed
, http-api-data
, http-types
, network
, string-conversions
, string-interpolate
, text
, wai
, wai-middleware-static
, wai-websockets
, warp
, web-view
, websockets
default-language: GHC2021
56 changes: 56 additions & 0 deletions example/package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: hyperbole-examples
version: 0.3.6
synopsis: Interactive HTML apps using type-safe serverside Haskell
homepage: https://github.com/seanhess/hyperbole
github: seanhess/hyperbole
license: BSD-3-Clause
license-file: LICENSE
author: Sean Hess
maintainer: seanhess@gmail.com
category: Web, Network
description: Interactive HTML applications using type-safe serverside Haskell. Inspired by HTMX, Elm, and Phoenix LiveView

language: GHC2021

ghc-options:
- -Wall
- -fdefer-typed-holes

default-extensions:
- OverloadedStrings
- OverloadedRecordDot
- DuplicateRecordFields
- NoFieldSelectors
- TypeFamilies
- DataKinds
- DerivingStrategies
- DeriveAnyClass

dependencies:
- base
- bytestring
- containers
- casing
- effectful
- text
- string-interpolate
- file-embed
- http-api-data
- http-types
- wai
- warp
- web-view
- string-conversions
- wai-websockets
- network
- websockets
- cookie

executables:
woot:
main: Main.hs
source-dirs:
- ../src
- ./
dependencies:
- wai-middleware-static
57 changes: 0 additions & 57 deletions hyperbole.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -75,63 +75,6 @@ library
, websockets >=0.12 && <0.14
default-language: GHC2021

executable examples
main-is: Main.hs
other-modules:
BulkUpdate
Example.Colors
Example.Concurrent
Example.Contacts
Example.Counter
Example.Effects.Debug
Example.Effects.Users
Example.Errors
Example.Forms
Example.LazyLoading
Example.Redirects
Example.Sessions
Example.Simple
Example.Style
Example.Transitions
HelloWorld
Paths_hyperbole
autogen-modules:
Paths_hyperbole
hs-source-dirs:
example
default-extensions:
OverloadedStrings
OverloadedRecordDot
DuplicateRecordFields
NoFieldSelectors
TypeFamilies
DataKinds
DerivingStrategies
DeriveAnyClass
ghc-options: -Wall -fdefer-typed-holes
build-depends:
base >=4.16 && <5
, bytestring >=0.11 && <0.13
, casing >0.1 && <0.2
, containers >=0.6 && <1
, cookie ==0.4.*
, effectful >=2.3 && <3
, file-embed >=0.0.10 && <0.1
, http-api-data ==0.6.*
, http-types ==0.12.*
, hyperbole
, network >=3.1 && <4
, string-conversions ==0.4.*
, string-interpolate ==0.3.*
, text >=1.2 && <3
, wai >=3.2 && <4
, wai-middleware-static >=0.9 && <=0.10
, wai-websockets >=3.0 && <4
, warp >=3.3 && <4
, web-view >=0.4 && <=0.5
, websockets >=0.12 && <0.14
default-language: GHC2021

test-suite tests
type: exitcode-stdio-1.0
main-is: Spec.hs
Expand Down
8 changes: 0 additions & 8 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ dependencies:
library:
source-dirs: src

executables:
examples:
main: Main.hs
source-dirs: example
dependencies:
- hyperbole
- wai-middleware-static >= 0.9 && <= 0.10

tests:
tests:
main: Spec.hs
Expand Down

0 comments on commit 0a175eb

Please sign in to comment.