Skip to content

Add To/FromField for (Double, Double), point type #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

avieth
Copy link

@avieth avieth commented Aug 25, 2015

Tested and working with PostgreSQL 9.4.1.

@lpsmith
Copy link
Owner

lpsmith commented Aug 25, 2015

Have you seen #154?

In particular, I won't accept a patch with (Double,Double) as the Haskell type. Other than that, it looks good to me.

Perhaps we could introduce a Database.PostgreSQL.Simple.Geometry module, and declare a data Point = Point {-# UNPACK #-} !Double {-# UNPACK #-} !Double type in there, with appropriate Haskell and postgresql-simple instances.

Eliminates To/FromRow instances of (Double, Double), favouring instead
the isomorphic Point type.
@avieth
Copy link
Author

avieth commented Aug 26, 2015

Your suggestion sounds good. Implemented in 4c37db1

@lpsmith
Copy link
Owner

lpsmith commented Aug 26, 2015

Ok, now I'd move the ToField/FromField instances into the Geometry module as well, as that's more in keeping with similar such modules. Also, I really don't see any reason why the Point type should be abstract, I'd just go ahead and export the constructor. And I would add a few Haskell instances for Point, at the very least I'd add Eq and Typeable.

@avieth
Copy link
Author

avieth commented Aug 26, 2015

You're the boss :) latest commit moves To/FromField into Geometry.hs and exports Point.

Also derive Eq, Ord for Point
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants