This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
QuickStart
Compl Yue edited this page Nov 20, 2019
·
3 revisions
Update: this is out-dated already, there're 3 flavors of scaffold as instructed in the home page, please update here as you see fit.
- create a stack project with
hadui
as one of its dependencies, in itspackage.yaml
like:
dependencies:
- base
- rio
- hadui
- in the project's
stack.yaml
, tell location of hadui withinextra-deps
, and customize the compiler definition:
extra-deps:
# to use the version of hadui checked out locally
#- ../hadui/hadui
# to use a version of hadui from github
- github: complyue/hadui
commit: stable
subdirs:
- hadui
compiler-check: match-exact
# CAVEATS
#
# binary distributions referenced following have NO support, checkout:
#
# https://gitlab.haskell.org/complyue/ghc-ife-bindist/blob/master/README.md
ghc-variant: ife
setup-info:
ghc:
macosx-custom-ife:
8.6.5:
url: "https://gitlab.haskell.org/complyue/ghc-ife-bindist/raw/master/ghc-8.6.5-x86_64-apple-darwin.tar.xz"
linux64-custom-ife:
8.6.5:
url: "https://gitlab.haskell.org/complyue/ghc-ife-bindist/raw/master/ghc-8.6.5-x86_64-unknown-linux.tar.xz"
- besides your
stack.yaml
, createhadui.yaml
, like:
# this cfg file 'hadui.yaml' is located by hadui besides
# the nearest 'stack.yaml' up from cwd you run hadui.
# it uses `stack path --project-root` to locate the dir.
# by default, only the local interface is bound to listen
# for hadui ws connections, this hardens the arbitrary
# code execution vulnerability a bit. but for you or your
# collegues to access hadui web front from other machines,
# bind to one of the external interfaces, or simply all
# interfaces by specifying '0.0.0.0'.
bind-interface: 0.0.0.0
http-port: 5050
ws-port: 5051
# backend log level
log-level: DEBUG
# additional options passed to GHCi
ghci-options:
# max history in trace, GHCi defaults to 50
- -fghci-hist-size=300
# run project code compiled, instead of interpreted, for performance
# but you won't get source locations for uncaught errors at runtime
#- -fobject-code
# additional options passed to both GHC and GHCi
ghc-options:
# language extensions to use, recommended by rio
# https://github.com/commercialhaskell/rio/#language-extensions
- -XAutoDeriveTypeable
# ...
- -XViewPatterns
- in your stack project, run:
stack build --exec hadui
- or run development mode:
stack build --exec hadui-dev
in development mode, you just refresh the browser page, the backend process will be restarted, and changed project source get recompiled automatically.
-
optionally, customize front UI for your project, by creating a
hadui
folder besides yourstack.yaml
.take for example: https://github.com/complyue/hadui-demo/tree/master/hadui
-
the Rating.hs module is paired with rating.html page to use state in frontend only.
-
the StatefulRating.hs module is paired with stateful-rating.html page to use state in backend.
-
the updateRank js method is shared by above 2 examples to update UI from Haskell code.
-