<div dir="ltr">Groundhog has support for PostgreSQL arrays and almost all operations on them. Check out the docs at <a href="http://hackage.haskell.org/package/groundhog-postgresql/docs/Database-Groundhog-Postgresql-Array.html">http://hackage.haskell.org/package/groundhog-postgresql/docs/Database-Groundhog-Postgresql-Array.html</a><div><br></div><div>Here is a tutorial for the library <a href="https://www.fpcomplete.com/user/lykahb/groundhog">https://www.fpcomplete.com/user/lykahb/groundhog</a><br><div><br></div><div>The array code looks like</div><div><br></div><div>main = withPostgresqlConn connectionString . runDbConn $ do<br></div><div>  key <- insert $ MyData $ Array [1, 2, 3]<br></div><div>  results <- select $ arrayLength MyField 1 <. (5 :: Int)    -- length of array dimension 1 is less than 5</div></div><div>  liftIO $ print results</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 26, 2014 at 6:02 AM, Tom Ellis <span dir="ltr"><<a href="mailto:tom-lists-haskell-cafe-2013@jaguarpaw.co.uk" target="_blank">tom-lists-haskell-cafe-2013@jaguarpaw.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Fri, Dec 26, 2014 at 10:52:46AM +0000, Tom Ellis wrote:<br>
> On Fri, Dec 26, 2014 at 02:36:07PM +1100, Riaan wrote:<br>
> > So went back to HDBC.  But now my queries are starting to get fairly long<br>
> > and I have been looking at libraries like Persistent with Esqualeto,<br>
> > HaskellDB and Groundhog to make my queries a little more composable and<br>
> > type safe.<br>
><br>
> Don't forget to look at Opaleye too :)  It doesn't really have much support<br>
> for arrays at the moment, but if you let me know what you want to do I'm<br>
> happy to help you.<br>
><br>
> > So to my question.  Does anyone have experience with one of these libraries<br>
> > in dealing with postgresql arrays<br>
><br>
> postgresql-simple has<br>
><br>
>     instance (FromField a, Typeable a) => FromField (PGArray a)<br>
><br>
> Does that not do exactly what you want?<br>
<br>
</span>import Database.PostgreSQL.Simple (query_, ConnectInfo(..), connect, Only)<br>
import Database.PostgreSQL.Simple.Types (PGArray)<br>
<br>
import Data.String (fromString)<br>
<br>
connectInfo :: ConnectInfo<br>
connectInfo =  ConnectInfo { connectHost = "localhost"<br>
                           , connectPort = 25433<br>
                           , connectUser = "tom"<br>
                           , connectPassword = "tom"<br>
                           , connectDatabase = "opaleye_test" }<br>
<br>
arrayQuery :: String<br>
arrayQuery = "select '{{1,2}, {3,4}}' :: integer[][]"<br>
<br>
main :: IO ()<br>
main = do<br>
  conn <- connect connectInfo<br>
  results <- query_ conn (fromString arrayQuery) :: IO [Only (PGArray (PGArray Int))]<br>
  print results<br>
<br>
-- Output<br>
--<br>
-- ghci> main<br>
-- [Only {fromOnly = PGArray {fromPGArray = [PGArray {fromPGArray = [1,2]},PGArray {fromPGArray = [3,4]}]}}]<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Regards,<br>Boris</div>
</div>