| Copyright | (c) 2018 Cedric Liegeois |
|---|---|
| License | BSD3 |
| Maintainer | Cedric Liegeois <ofmooseandmen@yahoo.fr> |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Data.Geo.Jord.Eval
Contents
Description
Types and functions for evaluating expressions in textual form.
Documentation
A value accepted and returned by eval.
Constructors
| Ang Angle | |
| AngDec Double |
|
| Bool Bool | boolean |
| Double Double | double |
| Len Length | |
| Gc GreatCircle | |
| Ll LatLong | |
| Lls [LatLong] | list of |
| LlDec (Double, Double) | latitude and longitude in decimal degrees |
| LlsDec [(Double, Double)] | list of latitude and longitude in decimal degrees |
| Vec NVector | |
| Vecs [NVector] | list of |
emptyVault :: Vault Source #
An empty Vault.
eval :: String -> Vault -> Result Source #
Evaluates s, an expression of the form "(f x y ..)".
>>>eval "finalBearing (destination (antipode 54°N,154°E) 54° 1000m) 54°N,154°E"126°
f must be one of the supported functions and each parameter x, y, .. , is either another function call
or a String parameter. Parameters are either resolved by name using the Resolve
function r or if it returns Nothing, read to an Angle, a Length or a LatLong.
If the evaluation is successful, returns the resulting Value (Right) otherwise
a description of the error (Left).
vault = emptyVault
angle = eval "finalBearing 54N154E 54S154W" vault -- Right Ang
length = eval "distance (antipode 54N154E) 54S154W" vault -- Right Len
-- parameter resolution from vault
a1 = eval "finalBearing 54N154E 54S154W" vault
vault = insert "a1" vault
a2 = eval "(finalBearing a1 54S154W)" vault
All returned positions are LatLong by default, to get back a NVector the
expression must be wrapped by toNVector.
dest = eval "destination 54°N,154°E 54° 1000m" -- Right Ll
dest = eval "toNVector (destination 54°N,154°E 54° 1000m)" -- Right Vec
Every function call must be wrapped between parentheses, however they can be ommitted for the top level call.
angle = eval "finalBearing 54N154E 54S154W" -- Right Ang
angle = eval "(finalBearing 54N154E 54S154W)" -- Right Ang
length = eval "distance (antipode 54N154E) 54S154W" -- Right Len
length = eval "distance antipode 54N154E 54S154W" -- Left String
insert :: String -> Value -> Vault -> Vault Source #
insert k v vault inserts value v for key k. Overwrites any previous value.
lookup :: String -> Vault -> Maybe Value Source #
lookup k vault looks up the value of key k in the vault.