esqueleto-postgis: postgis bindings for esqueleto.

[ database, library, mit ] [ Propose Tags ]

postgis bindings for esqueleto. Makes postgres a spatial database but now typesafely

[Skip to Readme]


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS] 1.0.0, 1.0.1
Change log
Dependencies base (>= && <, containers (>=0.6.5 && <0.8), esqueleto (>=3.5.10 && <3.6), geojson (>=4.1.1 && <4.2), persistent (>=2.13.3 && <2.15), text (>=1.2.5 && <2.2), wkt-geom (>=0.0.12 && <0.1) [details]
License MIT
Copyright 2024 Jappie Klooster
Author Jappie Klooster
Category Database
Home page
Bug tracker
Source repo head: git clone
Uploaded by Jappie at 2024-02-25T13:57:21Z
Downloads 43 total (16 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2024-02-25 [all 1 reports]

Readme for esqueleto-postgis-1.0.1

[back to package description] Githbu actions build status Jappiejappie Hackage version

Show me the place where space is not.

Implement (partial) postgis functionality for esqueleto.

uses wkt-geom to get a persistent instance, then maps that to a custom datatype 'PostgisGeometry' which is valid for roundtripping.

Then the esqueleto combinators are defined around this datatype.


Make sure to enable to postgis extension on your database (it's activated per database):


you can specify some posgis geometry, use the point to nidicate dimensions, pointxy = 2 dimensions pointxyz = 3, pointxyzm = 4. The library forces you to work in the same dimensions.

You can specify a table with the custom datatype, which will have geometry as sql type:

  [mkPersist sqlSettings, mkMigrate "migrateAll"]
  Unit sql=unit
    geom       (PostgisGeometry PointXY)
    deriving Eq Show

then you can simply query on tat datatype:

test = testCase ("it finds the one unit with st_contains") $ do
            result <- runDB $ do
              _ <- insert $
                  { unitGeom = Polygon $ makePolygon (PointXY 0 0) (PointXY 0 2) (PointXY 2 2) $ Seq.fromList [(PointXY 2 0)]

              selectOne $ do
                unit <- from $ table @Unit
                where_ $ unit ^. UnitGeom `st_contains` (val $ Point (PointXY 1 1))
                pure countRows

            -- expectation, the result should be 1
            unValue <$> result @?= (Just (1 :: Int)),


contributions are welcome. There are still many bindings missing!



Enter the nix shell.

nix develop

You can checkout the makefile to see what's available:

cat makefile


make run

Fast filewatch which runs tests

make ghcid