postgresql-simple icon indicating copy to clipboard operation
postgresql-simple copied to clipboard

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

Open avieth opened this issue 10 years ago • 4 comments

Tested and working with PostgreSQL 9.4.1.

avieth avatar Aug 25 '15 21:08 avieth

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.

lpsmith avatar Aug 25 '15 23:08 lpsmith

Your suggestion sounds good. Implemented in 4c37db1

avieth avatar Aug 26 '15 02:08 avieth

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.

lpsmith avatar Aug 26 '15 03:08 lpsmith

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

avieth avatar Aug 26 '15 18:08 avieth