geojson-1.3.0: A thin GeoJSON Layer above the aeson library

Copyright(C) 2014 Dom De Re
LicenseBSD-style (see the file etc/
MaintainerDom De Re
Safe HaskellNone




Refer to the GeoJSON Spec

A LinearString is a List with at least 2 elements



data LineString a Source

a LineString has at least 2 elements


Functor LineString 
Foldable LineString

This instance of Foldable will run through the entire ring, closing the loop by also passing the initial element in again at the end.

(\xs -> (foldr (:) [] xs) == (fromLineString xs)) (xs :: LineString Int)
(\xs -> (lineStringHead xs) == (foldr'' (\a -> const a) 0 xs)) (xs :: LineString Int)
Traversable LineString 
Eq a => Eq (LineString a) 
Show a => Show (LineString a) 
ToJSON a => ToJSON (LineString a) 
(FromJSON a, Show a) => FromJSON (LineString a) 

data ListToLineStringError Source

When converting a List to a LineString, here is a list of things that can go wrong:

  • The list was empty
  • The list only had one element




fromLineString :: LineString a -> [a] Source

This function converts it into a list and appends the given element to the end.

(xs -> safeLast (fromLineString xs) == Just (lineStringHead xs)) (xs :: LineString Int)

(xs -> length (fromLineString xs) >= 4) (xs :: LineString Int)

fromList :: Validate v => [a] -> v ListToLineStringError (LineString a) Source

creates a LineString out of a list of elements, if there are enough elements (needs at least 2) elements

>>> fromList [] :: Validation ListToLineStringError (LineString Int)
Failure List Empty
>>> fromList [0] :: Validation ListToLineStringError (LineString Int)
Failure Singleton List
>>> fromList [0, 1] :: Validation ListToLineStringError (LineString Int)
Success [0,1]
>>> fromList [0, 1, 2] :: Validation ListToLineStringError (LineString Int)
Success [0,1,2]
>>> fromList [0, 1, 2, 4, 5, 0] :: Validation ListToLineStringError (LineString Int)
Success [0,1,2,4,5,0]

makeLineString Source


:: a

The first element

-> a

The second element

-> [a]

The rest of the optional elements

-> LineString a 

Creates a LineString makeLineString x y zs creates a LineString homomorphic to the list [x, y] ++ zs

lineStringHead :: LineString a -> a Source

returns the element at the head of the string

lineStringLast :: LineString a -> a Source

returns the last element in the string

lineStringLength :: LineString a -> Int Source

returns the number of elements in the list, including the replicated element at the end of the list.

(xs -> lineStringLength xs == (length (fromLineString xs))) (xs :: LineString Int)