Shpadoinkle-console: Support for the native browser console

[ bsd3, library, web ] [ Propose Tags ]

This package adds support for native browser console features for logging and debugging.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.1.0, 0.0.1.1, 0.0.1.3, 0.0.1.4
Change log CHANGELOG.md
Dependencies aeson (>=1.4.4 && <1.6), base (>=4.12.0 && <4.16), jsaddle (>=0.9.7 && <0.20), lens (>=4.17.1 && <5.0), text (>=1.2.3 && <1.3), unliftio (>=0.2.12 && <0.3) [details]
License BSD-3-Clause
Author Isaac Shapira
Maintainer fresheyeball@protonmail.com
Category Web
Source repo head: git clone https://gitlab.com/fresheyeball/Shpadoinkle.git
Uploaded by fresheyeball at 2020-10-07T20:35:23Z
Distributions
Downloads 656 total (20 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for Shpadoinkle-console-0.0.1.1

[back to package description]

Shpadoinkle Console

Goldwater Haddock BSD-3 built with nix Hackage Hackage Deps Hackage CI

This package exposes some useful debugging functions for tracing the state of Shpadoinkle applications as they change over time. It exposes some type classes currently.

class LogJS (c :: Type -> Constraint) where
  logJS :: c a => a -> JSM ()

class LogJS c => Trapper c where
  trapper :: c a => JSContextRef -> a -> a

class Assert (c :: Type -> Constraint) where
  assert :: c a => Bool -> a -> JSM ()

These are intended to by used with TypeApplications, so you can choose the means of conversion before passing to console.log. For example:

main :: IO ()
main = runJSorWarp 8080 $ do
  ctx <- askJSM
  simple runParDiff initial (view . trapper @ToJSON ctx) getBody

This will log all state by first encoding to JSON with Aeson, then then logging with JSON.parse so the browser console has the nice native display. If we change it to trapper @Show ctx it will use the Show instance instead.

We also export a handful of console bindings such as console.time, console.table, console.info, console.warn, console.debug, and of course console.log.