lightning-haskell-0.1.0.2: Haskell client for lightning-viz REST API

Copyright(c) Connor Moreside, 2016
LicenseBSD-3
Maintainerconnor@moresi.de
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Web.Lightning.Utilities

Contents

Description

Contains commonly used utility functions used throughout the library.

Synopsis

Utility Functions

omitNulls Source

Arguments

:: [(Text, Value)]

The plot object to be serialized into JSON Value

-> Value

The plot object with Nothing (null) fields removed.

Used in conjunction with ToJSON. It will stop any field that is Nothing (null) in a record from being encoded in JSON.

createPayLoad Source

Arguments

:: Text

The name of the type of plot to create

-> Value

The plot creation request record in JSON Value format

-> Value

The properly encoded payload object

Converts the plot creation request record into the proper JSON object that the lightning-viz server expects.

createDataPayLoad Source

Arguments

:: Value

Data to update.

-> Value

The properly encoded payload object.

Creates a payload for streaming plots.

addSessionId Source

Arguments

:: Text

The current URL

-> Text

The session ID to add to current URL

-> Text

Returns the URL with the session ID

Appends the session route and session id to current URL.

getLinks Source

Arguments

:: [[Double]]

The adjacency matrix

-> [[Double]]

All the links for each of the nodes

Retrieves all the links for each of the nodes in the adjacency matrix.

getNodes Source

Arguments

:: [[Double]]

The adjacency matrix

-> [Int]

A list of all of the nodes in matrix

Retrieves all of the nodes from an adjacency matrix.

getPoints Source

Arguments

:: [Double]

X points

-> [Double]

Y points

-> [[Double]]

Returns [ [x, y] ] pairs

Zips up x and y points into array pairs.

getPoints3 Source

Arguments

:: [Double]

X points

-> [Double]

Y points

-> [Double]

Z points

-> [[Double]]

Returns [ [x, y, z] ] triplets

Zips up x, y, and z points into array triples.

Validation Functions

validateBin :: Maybe [Double] -> Either LightningError (Maybe [Double]) Source

Validates the bins of a histogram

validateColor :: Maybe [Int] -> Either LightningError (Maybe [Int]) Source

Verify that the color specs are either in the form of [r, g, b] or a list of [[r,g,b],[r,g,b],...]

validateColorMap :: Maybe Text -> Either LightningError (Maybe Text) Source

Verifiy that the color map specified is on of the colorbrewer maps.

Here are the available colorbrewer values: BrBG, PiYG, PRGn, PuOr, RdBu, RdGy, RdYlBu, RdYlGn, Spectral, Blues, BuGn, BuPu, GnBu, Greens, Greys, Oranges, OrRd, PuBu, PuBuGn, PuRd, Purples, RdPu, Reds, YlGn, YlGnBu, YlOrBr, YlOrRd, Accent, Dark2, Paired, Pastel1, Pastel2, Set1, Set2, Set3, or Lightning

validateSize :: Maybe [Int] -> Either LightningError (Maybe [Int]) Source

Verify that all size values are greater than zero.

validateAlpha :: Maybe [Double] -> Either LightningError (Maybe [Double]) Source

Verify all alpha values are greater than 0

validateThickness :: Maybe [Int] -> Either LightningError (Maybe [Int]) Source

Verify all thickness values are greater than 0.

validateIndex :: Maybe [Int] -> Either LightningError (Maybe [Int]) Source

Verify that there is at least one element in list.

validateCoordinates Source

Arguments

:: [Double]

x vector

-> [Double]

y vector

-> Either LightningError ([Double], [Double]) 

Verify that the length of vector x is equal to length of vector y.

validateCoordinates3 Source

Arguments

:: [Double]

x vector

-> [Double]

y vector

-> [Double]

z vector

-> Either LightningError ([Double], [Double], [Double]) 

Verify that the lenths of the x, y, and z vectors are the same length.

validateRegion :: [Text] -> Either LightningError [Text] Source

Verify that the lengths of the region names are either 2 letters or 3 letters.

2 letter region names must correspond to US states and 3 letter region names must correspond to countries of the world.

validateConn :: [[Double]] -> Either LightningError [[Double]] Source

Verify that the multi-dimensional list adheres to expected dimensions.

defaultBaseURL :: Text Source

Defines the default URL for the lightning-viz server.