lpsmith/postgresql-simple — pull request #50 by joeyadams (2013-01-08 04:42:06+00:00)
Title: Define PGArray newtype instead of using Vector to represent Postgres arrays

Using `Vector`, it's awkward (and perhaps less efficient) if you want to use a regular Haskell list in a record:

```haskell
import qualified Data.Vector as V

data Widget = Widget
{ foo :: String
, bar :: String
, baz :: String
, reports :: [String]
}

instance FromRow Widget where
fromRow = do
foo <- field
bar <- field
baz <- field
reports <- V.toList <$> field -- Postgres array
return Widget{..}
```

Moreover, it's not safe. Suppose in the future, postgresql-simple serializes Vector and Map using JSON so they stack properly (PostgreSQL arrays can't be nested; they're multi-dimensional, like matrices). Code that relies on Vector being a Postgres array will break at run-time.

We discussed this before in pull request #33, but it bothered me when I had to write code like the above.

@lpsmith, @solidsnack, and @sopvop, are you okay with this? My commit will break existing code using PG array support, but it will produce a compile-time error that is easy to fix (no `ToField` and `FromField` instances for `Vector`), rather than subtle breakage at runtime.