[Haskell-cafe] Handling Postgresql array types
Tom Ellis
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Sat Dec 27 11:23:36 UTC 2014
On Fri, Dec 26, 2014 at 09:31:02PM -0800, info at rotnetix.com wrote:
> I would actually like my data IIM to be:
>
> data IIM = IIM {key :: String
> ,itype :: String
> ,idet :: Maybe String
> ,imat :: [[Double]]} deriving (Read, Show, Eq)
>
> But I can't figure out how to get a fromRow instance for that
instance FromRow IIM where
fromRow = IIM <$> field
<*> field
<*> field
<*> fmap (T.fromPGArray . fmap T.fromPGArray) field
> PS. I started looking into Opaleye as a possible DSL and would appreciate
> any help you can give me in figuring out how to represent arrays in that.
> I am assuming I need to do something with queryRunnerColumn but I was not
> able to understand the example.
This is indeed somewhat fiddly to do because it requires fiddling with the
implementation of postgresql-simple instances. Unfortunately that library
does not provide us with enough primitives to do this directly.
I will work on this.
Tom
More information about the Haskell-Cafe
mailing list