Skip to content

Instantly share code, notes, and snippets.

@co-dan
Created January 12, 2013 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save co-dan/4517536 to your computer and use it in GitHub Desktop.
Save co-dan/4517536 to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings, DeriveDataTypeable, ScopedTypeVariables #-}
import Database.PostgreSQL.Simple
import Database.PostgreSQL.Simple.FromRow
import Database.PostgreSQL.Simple.FromField
import Data.Typeable
import Control.Applicative
data Location = Location { latitude :: Double
, longitude :: Double }
deriving (Eq, Typeable, Show)
instance FromField Location where
fromField f dat = fmap (uncurry Location) $ fromField f dat
copts :: ConnectInfo
copts = defaultConnectInfo { connectUser = "dan", connectDatabase = "test" }
main = do
c <- connect copts
x :: [Only Location] <- query_ c "select loc from markers"
print x
close c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment