This is a Playground for various functionality imlemented in Haskell (and maybe other functional languages like Elm)
Authentication, REST servers, websockets, Web SPA/PWA clients, Postgres, Mongo (with oplog tailing)
If you don't have these already, install:
- Stack:
curl -sSL https://get.haskellstack.org/ | sh
- Elm:
- create-elm-app:
npm install create-elm-app -g
- PosgreSQL
mv config_sample.dhall config.dhall
- Edit
config.dhall
and make appropriate changes - opaleye-gen -d postgresql://localhost/tennis -o src/DB/Opaleye/Database.hs # Uses modifed opaleye-gen
stack build
cd elm-client
elm-app build
- client -> app server
- server redirects to Google and specifies a callback url
- Google handles authentication and redirects client to callback url
- Server gets the user details, creates a JWT and returns HTML+JS to the client sticking the token into localStorage. Also sets window.location to the Elm app's index.html
- Elm app has JS in index.html to initialize the Elm model from localStorage
in directory elm-client
, bootstrapped with create-elm-app. Therefore it is a PWA
elm-app build
creates a production build in the build
directory.
the elm code is in src/Main.elm
. The toplevel Javascript code is in src/index.js
The JS code initializes the model from localStorage. it gets authenticated email address and an access-token
- Authentication: OpenId Connect Google/Microsoft
- Communication : REST + Websockets
- FRP: streamly seems to be a new lib (Claims to be close to Rx in design)
- Client options:
- Purescript + Halogen + REST+Websocket + Nice default styling
- [x?] Elm
- GHCJS Reflex-DOM
- GHCJS Miso (Not FRP)
- ReScript
- Servant + Selda + Websocket server + Postgres
- MonadMetrics for metrics
- Actively maintained, Fastest streaming library, general purpose
-
- Examples of effect systems for same program
Polysemywas written by Sandy McGuire, author of "Thinking with Types" and "Algebra Driven Design". Polysemy poor in benchmark that Sandy accepted- Tutorial
-
Effects are things like IO, random numbers, exceptions, mutable global state
- mtl Basic, Super fast, O(n^2) instances, can't have more than one State, Reader etc.
- freer-simple Slow, no boilerplate, good type error messages
- fused effects Super fast, lot of boilerplate
- Eff By Alexis King, author of freer-simple and that video on Effect systems performance. This is very new, requires GHC changes to boost performance. The changes are not yet accepted
- Polysemy Very fast, little boilerplate, good error messages
Artyom's Haskell toolbox Lists the author's favorite libraries for various tasks
- Type level programming. Read Mcguire book
- McGuire also has a book Algebra Driven Design
- Effect systems
- FRP (use streamly?)