Created
January 12, 2013 11:58
-
-
Save co-dan/4517536 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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