[Haskell-cafe] Handling Postgresql array types

info at rotnetix.com info at rotnetix.com
Sun Dec 28 00:24:25 UTC 2014


Thank you, that works.

I started down this road but I only got to:

instance FromRow IIM where 
  fromRow = IIM <$> field 
                <*> field 
                <*> field 
                <*> T.fromPGArray  (fmap T.fromPGArray field)

Which I expected to work based on the fact that this is what I need to 
convert (PGArray (PGArray Double)) to [[Double]].

Why is there an additional fmap needed?


On Saturday, December 27, 2014 10:23:47 PM UTC+11, Tom Ellis wrote:
>
> On Fri, Dec 26, 2014 at 09:31:02PM -0800, in... at rotnetix.com <javascript:> 
> 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 
>
> _______________________________________________ 
> Haskell-Cafe mailing list 
> Haskel... at haskell.org <javascript:> 
> http://www.haskell.org/mailman/listinfo/haskell-cafe 
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141227/5657851d/attachment-0001.html>


More information about the Haskell-Cafe mailing list