Skip to content

corajr/servant-state-graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

servant-state-graph

Generate graphs from Servant API types. Inspired by choclety.

example graph

See a live demo.

Purpose

This library helps you render your Servant API as a state machine, with representations as states and requests as state transitions. This could be useful, for example, when looking for the shortest path(s) to reach a desired state (such as a revenue-generating action).

It also includes the beginnings of a HAL library for Servant, for serving a hypermedia API.

Prerequisites

  • haskell-stack: curl -sSL https://get.haskellstack.org/ | sh
    • run stack setup to obtain the Haskell compiler

Docs

See the Haddock documentation.

Usage

The library exposes a function stateGraph that can generate graph JSON suitable for use with the included viewer or serve the viewer on a desired port.

To serve up the graph viewer (uses Cytoscape.js) at 127.0.0.1:8090 for a sample API:

stack build && stack exec state-graph

To serve up the sample API itself on port 8080:

stack exec state-graph-server

Or, to serve up the HAL-supporting version of the API:

stack exec state-graph-server -- --hyper

To run the test suite:

stack test

About

Generate graphs from Servant API types

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published