diff --git a/Setup.lhs b/Setup.lhs
new file mode 100644
--- /dev/null
+++ b/Setup.lhs
@@ -0,0 +1,44 @@
+#!/usr/bin/env runhaskell
+\begin{code}
+{-# OPTIONS_GHC -Wall #-}
+module Main (main) where
+
+import Data.List ( nub )
+import Data.Version ( showVersion )
+import Distribution.Package ( PackageName(PackageName), PackageId, InstalledPackageId, packageVersion, packageName )
+import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) )
+import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )
+import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )
+import Distribution.Simple.BuildPaths ( autogenModulesDir )
+import Distribution.Simple.Setup ( BuildFlags(buildVerbosity), fromFlag )
+import Distribution.Simple.LocalBuildInfo ( withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps) )
+import Distribution.Verbosity ( Verbosity )
+import System.FilePath ( (</>) )
+
+main :: IO ()
+main = defaultMainWithHooks simpleUserHooks
+  { buildHook = \pkg lbi hooks flags -> do
+     generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi
+     buildHook simpleUserHooks pkg lbi hooks flags
+  }
+
+generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
+generateBuildModule verbosity pkg lbi = do
+  let dir = autogenModulesDir lbi
+  createDirectoryIfMissingVerbose verbosity True dir
+  withLibLBI pkg lbi $ \_ libcfg -> do
+    withTestLBI pkg lbi $ \suite suitecfg -> do
+      rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines
+        [ "module Build_" ++ testName suite ++ " where"
+        , "deps :: [String]"
+        , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))
+        ]
+  where
+    formatdeps = map (formatone . snd)
+    formatone p = case packageName p of
+      PackageName n -> n ++ "-" ++ showVersion (packageVersion p)
+
+testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]
+testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys
+
+\end{code}
diff --git a/coordinate.cabal b/coordinate.cabal
new file mode 100644
--- /dev/null
+++ b/coordinate.cabal
@@ -0,0 +1,72 @@
+name:               coordinate
+version:            0.0.1
+license:            BSD3
+license-File:       etc/LICENCE
+author:             Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ>
+maintainer:         Tony Morris
+copyright:          Copyright (C) 2010-2013 Tony Morris
+synopsis:           A representation of latitude and longitude
+category:           Development
+description:        A representation of latitude and longitude
+homepage:           https://github.com/tonymorris/coordinate
+bug-reports:        https://github.com/tonymorris/coordinate/issues
+cabal-version:      >= 1.10
+build-type:         Custom
+
+source-repository   head
+  type:             git
+  location:         git@github.com:tonymorris/coordinate.git
+
+flag                small_base
+  description:      Choose the new, split-up base package.
+
+library
+  default-language:
+                    Haskell2010
+
+  build-depends:
+                    base < 5 && >= 3
+                    , lens >= 3.10
+
+  ghc-options:
+                    -Wall
+
+  default-extensions:
+                      NoImplicitPrelude
+
+  hs-source-dirs:
+                    src
+
+  exposed-modules:
+                    Data.GPS.Coordinate
+                    Data.GPS.Coordinate.Coordinate
+                    Data.GPS.Coordinate.DegreesLatitude
+                    Data.GPS.Coordinate.DegreesLongitude
+                    Data.GPS.Coordinate.Latitude
+                    Data.GPS.Coordinate.Longitude
+                    Data.GPS.Coordinate.Minutes
+                    Data.GPS.Coordinate.Seconds
+
+test-suite doctests
+  type:
+                    exitcode-stdio-1.0
+
+  main-is:
+                    doctests.hs
+
+  default-language:
+                    Haskell2010
+
+  build-depends:
+                    base < 5 && >= 3,
+                    doctest >= 0.9.7,
+                    filepath >= 1.3,
+                    directory >= 1.1,
+                    QuickCheck >= 2.0
+
+  ghc-options:
+                    -Wall
+                    -threaded
+
+  hs-source-dirs:
+                    test
diff --git a/etc/LICENCE b/etc/LICENCE
new file mode 100644
--- /dev/null
+++ b/etc/LICENCE
@@ -0,0 +1,27 @@
+Copyright 2013 Tony Morris
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name of the author nor the names of his contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
diff --git a/src/Data/GPS/Coordinate.hs b/src/Data/GPS/Coordinate.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/GPS/Coordinate.hs
@@ -0,0 +1,9 @@
+module Data.GPS.Coordinate(module C) where
+
+import Data.GPS.Coordinate.Coordinate as C
+import Data.GPS.Coordinate.DegreesLatitude as C
+import Data.GPS.Coordinate.DegreesLongitude as C
+import Data.GPS.Coordinate.Latitude as C
+import Data.GPS.Coordinate.Longitude as C
+import Data.GPS.Coordinate.Minutes as C
+import Data.GPS.Coordinate.Seconds as C
diff --git a/src/Data/GPS/Coordinate/Coordinate.hs b/src/Data/GPS/Coordinate/Coordinate.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/GPS/Coordinate/Coordinate.hs
@@ -0,0 +1,49 @@
+module Data.GPS.Coordinate.Coordinate(
+  Coordinate
+, coordinate
+, coordinate'
+, coordinateLat
+, coordinateLon
+, coordinateLatlon
+) where
+
+import Prelude(Eq, Show, (.))
+import Control.Lens(Iso', iso, mapping, swapped, withIso)
+import Data.GPS.Coordinate.Latitude
+import Data.GPS.Coordinate.Longitude
+import Data.GPS.Coordinate.DegreesLatitude
+import Data.GPS.Coordinate.DegreesLongitude
+import Data.GPS.Coordinate.Minutes
+import Data.GPS.Coordinate.Seconds
+
+data Coordinate =
+  Coordinate
+    Latitude
+    Longitude
+  deriving (Eq, Show)
+
+coordinate ::
+  Iso' (Latitude, Longitude) Coordinate
+coordinate =
+  iso (\(lat, lon) -> Coordinate lat lon) (\(Coordinate lat lon) -> (lat, lon))
+
+coordinate' ::
+  Iso' (Longitude, Latitude) Coordinate
+coordinate' =
+  swapped . coordinate
+
+coordinateLat ::
+  Iso' ((DegreesLatitude, Minutes, Seconds), Longitude) Coordinate
+coordinateLat =
+  swapped . mapping latitude . coordinate'
+
+coordinateLon ::
+  Iso' (Latitude, (DegreesLongitude, Minutes, Seconds)) Coordinate
+coordinateLon =
+  mapping longitude . coordinate
+
+coordinateLatlon ::
+  Iso' ((DegreesLatitude, Minutes, Seconds), (DegreesLongitude, Minutes, Seconds)) Coordinate
+coordinateLatlon =
+  iso (\((td, tm, ts), (nd, nm, ns)) -> Coordinate (withIso latitude (\k _ -> k (td, tm, ts))) (withIso longitude (\k _ -> k (nd, nm, ns))))
+      (\(Coordinate lat lon) -> (withIso latitude (\_ k -> k lat), withIso longitude (\_ k -> k lon)))
diff --git a/src/Data/GPS/Coordinate/DegreesLatitude.hs b/src/Data/GPS/Coordinate/DegreesLatitude.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/GPS/Coordinate/DegreesLatitude.hs
@@ -0,0 +1,21 @@
+module Data.GPS.Coordinate.DegreesLatitude(
+  DegreesLatitude
+, degreesLatitude
+) where
+
+import Prelude(Int, Bool(..), Eq, Show, Ord(..), (&&))
+import Data.Maybe(Maybe(..))
+import Control.Lens(Prism', prism')
+
+newtype DegreesLatitude =
+  DegreesLatitude Int
+  deriving (Eq, Show)
+
+degreesLatitude ::
+  Prism' Int DegreesLatitude
+degreesLatitude =
+  prism'
+    (\(DegreesLatitude i) -> i)
+    (\i -> case i >= -90 && i <= 90 of
+             True -> Just (DegreesLatitude i)
+             False -> Nothing)
diff --git a/src/Data/GPS/Coordinate/DegreesLongitude.hs b/src/Data/GPS/Coordinate/DegreesLongitude.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/GPS/Coordinate/DegreesLongitude.hs
@@ -0,0 +1,21 @@
+module Data.GPS.Coordinate.DegreesLongitude(
+  DegreesLongitude
+, degreesLongitude
+) where
+
+import Prelude(Int, Bool(..), Eq, Show, Ord(..), (&&))
+import Data.Maybe(Maybe(..))
+import Control.Lens(Prism', prism')
+
+newtype DegreesLongitude =
+  DegreesLongitude Int
+  deriving (Eq, Show)
+
+degreesLongitude ::
+  Prism' Int DegreesLongitude
+degreesLongitude =
+  prism'
+    (\(DegreesLongitude i) -> i)
+    (\i -> case i >= -180 && i <= 180 of
+             True -> Just (DegreesLongitude i)
+             False -> Nothing)
diff --git a/src/Data/GPS/Coordinate/Latitude.hs b/src/Data/GPS/Coordinate/Latitude.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/GPS/Coordinate/Latitude.hs
@@ -0,0 +1,35 @@
+module Data.GPS.Coordinate.Latitude(
+  Latitude
+, latitude
+, latitudeF
+) where
+
+import Prelude(Double, Eq, Show, Ord(..), Num(..), Bool(..), Monad(..), (&&), properFraction, fromIntegral)
+import Control.Lens(Iso', Prism', iso, prism', (#), (^?))
+import Data.GPS.Coordinate.DegreesLatitude
+import Data.GPS.Coordinate.Minutes
+import Data.GPS.Coordinate.Seconds
+
+data Latitude =
+  Latitude
+    DegreesLatitude
+    Minutes
+    Seconds
+  deriving (Eq, Show)
+
+latitude ::
+  Iso' (DegreesLatitude, Minutes, Seconds) Latitude
+latitude =
+  iso (\(d, m, s) -> Latitude d m s) (\(Latitude d m s) -> (d, m, s))
+
+latitudeF ::
+  Prism' Double Latitude
+latitudeF =
+  prism' (\(Latitude d m s) ->
+    fromIntegral (degreesLatitude # d) + seconds # s + fromIntegral (minutes # m * 60))
+    (\x -> let (d, z) = properFraction x
+               (m, s) = properFraction ((z :: Double) * 60)
+           in do d' <- d ^? degreesLatitude
+                 m' <- m ^? minutes
+                 s' <- s ^? seconds
+                 return (Latitude d' m' s'))
diff --git a/src/Data/GPS/Coordinate/Longitude.hs b/src/Data/GPS/Coordinate/Longitude.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/GPS/Coordinate/Longitude.hs
@@ -0,0 +1,35 @@
+module Data.GPS.Coordinate.Longitude(
+  Longitude
+, longitude
+, longitudeF
+) where
+
+import Prelude(Double, Eq, Show, Ord(..), Num(..), Bool(..), Monad(..), (&&), properFraction, fromIntegral)
+import Control.Lens(Iso', Prism', iso, prism', (#), (^?))
+import Data.GPS.Coordinate.DegreesLongitude
+import Data.GPS.Coordinate.Minutes
+import Data.GPS.Coordinate.Seconds
+
+data Longitude =
+  Longitude
+    DegreesLongitude
+    Minutes
+    Seconds
+  deriving (Eq, Show)
+
+longitude ::
+  Iso' (DegreesLongitude, Minutes, Seconds) Longitude
+longitude =
+  iso (\(d, m, s) -> Longitude d m s) (\(Longitude d m s) -> (d, m, s))
+
+longitudeF ::
+  Prism' Double Longitude
+longitudeF =
+  prism' (\(Longitude d m s) ->
+    fromIntegral (degreesLongitude # d) + seconds # s + fromIntegral (minutes # m * 60))
+    (\x -> let (d, z) = properFraction x
+               (m, s) = properFraction ((z :: Double) * 60)
+           in do d' <- d ^? degreesLongitude
+                 m' <- m ^? minutes
+                 s' <- s ^? seconds
+                 return (Longitude d' m' s'))
diff --git a/src/Data/GPS/Coordinate/Minutes.hs b/src/Data/GPS/Coordinate/Minutes.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/GPS/Coordinate/Minutes.hs
@@ -0,0 +1,21 @@
+module Data.GPS.Coordinate.Minutes(
+  Minutes
+, minutes
+) where
+
+import Prelude(Int, Bool(..), Eq, Show, Ord(..), (&&))
+import Data.Maybe(Maybe(..))
+import Control.Lens(Prism', prism')
+
+newtype Minutes =
+  Minutes Int
+  deriving (Eq, Show)
+
+minutes ::
+  Prism' Int Minutes
+minutes =
+  prism'
+    (\(Minutes i) -> i)
+    (\i -> case i >= 0 && i < 60 of
+             True -> Just (Minutes i)
+             False -> Nothing)
diff --git a/src/Data/GPS/Coordinate/Seconds.hs b/src/Data/GPS/Coordinate/Seconds.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/GPS/Coordinate/Seconds.hs
@@ -0,0 +1,21 @@
+module Data.GPS.Coordinate.Seconds(
+  Seconds
+, seconds
+) where
+
+import Prelude(Double, Bool(..), Eq, Show, Ord(..), (&&))
+import Data.Maybe(Maybe(..))
+import Control.Lens(Prism', prism')
+
+newtype Seconds =
+  Seconds Double
+  deriving (Eq, Show)
+
+seconds ::
+  Prism' Double Seconds
+seconds =
+  prism'
+    (\(Seconds d) -> d)
+    (\d -> case d >= 0 && d < 60 of
+             True -> Just (Seconds d)
+             False -> Nothing)
diff --git a/test/doctests.hs b/test/doctests.hs
new file mode 100644
--- /dev/null
+++ b/test/doctests.hs
@@ -0,0 +1,32 @@
+module Main where
+
+import Build_doctests (deps)
+import Control.Applicative
+import Control.Monad
+import Data.List
+import System.Directory
+import System.FilePath
+import Test.DocTest
+
+main ::
+  IO ()
+main =
+  getSources >>= \sources -> doctest $
+      "-isrc"
+    : "-idist/build/autogen"
+    : "-optP-include"
+    : "-optPdist/build/autogen/cabal_macros.h"
+    : "-hide-all-packages"
+    : map ("-package="++) deps ++ sources
+
+getSources :: IO [FilePath]
+getSources = filter (isSuffixOf ".hs") <$> go "src"
+  where
+    go dir = do
+      (dirs, files) <- getFilesAndDirectories dir
+      (files ++) . concat <$> mapM go dirs
+
+getFilesAndDirectories :: FilePath -> IO ([FilePath], [FilePath])
+getFilesAndDirectories dir = do
+  c <- map (dir </>) . filter (`notElem` ["..", "."]) <$> getDirectoryContents dir
+  (,) <$> filterM doesDirectoryExist c <*> filterM doesFileExist c
