<div dir="ltr">Thank you very much, that works great.  My Haskell, poor as it is, is still a lot better than may SQL so I am doing most of my array operations in Haskell.  The only functionality I currently use is array_length, slices (as in SELECT colname [1:2][1:1]) and WHERE colname = '{}'.<div><br></div><div>The other issue I had is once the array select is working is how to select a column with a special name... For some reason out DB designer decided that one of the columns should be named "column".  Which is a pain anyway but in normal SQL you can deal with that by selecting it fully qualified as in arrayTable.column but if I try that in opaleye, like:</div><div><br></div><div>table = Table "arraytable" (required "arraytable.column") </div><div><br></div><div>the query complains:</div><div>*** Exception: SqlError {sqlState = "42601", sqlExecStatus = FatalError, sqlErrorMsg = "syntax error at or near \".\"", sqlErrorDetail = "", sqlErrorHint = ""}</div><div><br></div><div>Finally I am curious as to how easy it will be for me to create a different mapping for PGArray, so that instead of (PGArray (PGArray PGFloat8)) -> [[Double]] I can do (PGArray (PGArray Float8)) -> Matrix Double.  It is not a big deal to do the conversion later but if the library allows that kind of thing to be easily done it can make the code more readable.</div><div><br></div><div>Thanks again for the great support. </div><div><div><br>On Saturday, December 27, 2014 11:09:57 PM UTC+11, Tom Ellis wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Sat, Dec 27, 2014 at 11:23:36AM +0000, Tom Ellis wrote:
<br>> > PS. I started looking into Opaleye as a possible DSL and would appreciate 
<br>> > any help you can give me in figuring out how to represent arrays in that. 
<br>> >  I am assuming I need to do something with queryRunnerColumn but I was not 
<br>> > able to understand the example.
<br>> 
<br>> This is indeed somewhat fiddly to do because it requires fiddling with the
<br>> implementation of postgresql-simple instances.  Unfortunately that library
<br>> does not provide us with enough primitives to do this directly.
<br>
<br>OK, I just pushed a patch to GitHub
<br>
<br>    <a href="https://github.com/tomjaguarpaw/haskell-opaleye" target="_blank" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Ftomjaguarpaw%2Fhaskell-opaleye\46sa\75D\46sntz\0751\46usg\75AFQjCNGB5vqUbZr46IsfvYJPwAmvICdK3g';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Ftomjaguarpaw%2Fhaskell-opaleye\46sa\75D\46sntz\0751\46usg\75AFQjCNGB5vqUbZr46IsfvYJPwAmvICdK3g';return true;">https://github.com/<wbr>tomjaguarpaw/haskell-opaleye</a>
<br>
<br>Now you can do the below.  You can't actually do anything with your arrays
<br>yet except just read them from tables and return them from `runQuery` but
<br>let me know what functionality you want and I will endevour to support it.
<br>
<br>
<br>import           Database.PostgreSQL.Simple (execute_, ConnectInfo(..), connect)
<br>import           Data.String (fromString)
<br>import           Opaleye
<br>
<br>connectInfo :: ConnectInfo
<br>connectInfo =  ConnectInfo { connectHost = "localhost"
<br>                           , connectPort = 25433      
<br>                           , connectUser = "tom"
<br>                           , connectPassword = "tom"
<br>                           , connectDatabase = "opaleye_test" }
<br>
<br>table :: Table (Column (PGArray (PGArray PGInt4)))
<br>               (Column (PGArray (PGArray PGInt4)))
<br>table = Table "arraytable" (required "colname")
<br>
<br>query :: Query (Column (PGArray (PGArray PGInt4)))
<br>query = queryTable table
<br>
<br>main :: IO ()
<br>main = do
<br>  conn <- connect connectInfo
<br>
<br>  let q = execute_ conn . fromString
<br>
<br>  q "DROP TABLE IF EXISTS arraytable"
<br>  q "CREATE TABLE arraytable (colname integer[][])"
<br>  q "INSERT INTO arraytable VALUES ('{{1,2}, {3,4}}'), ('{{5,6}, {7,8}}')"
<br>
<br>  results' <- runQuery conn query :: IO [[[Int]]]
<br>  print results'
<br>
<br>-- ghci> main
<br>-- [[[1,2],[3,4]],[[5,6],[7,8]]]
<br>______________________________<wbr>_________________
<br>Haskell-Cafe mailing list
<br><a href="javascript:" target="_blank" gdf-obfuscated-mailto="1hsbp6kQI58J" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">Haskel...@haskell.org</a>
<br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.haskell.org%2Fmailman%2Flistinfo%2Fhaskell-cafe\46sa\75D\46sntz\0751\46usg\75AFQjCNHiVycCM53czUVzPma4Fkb_wPqP2A';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.haskell.org%2Fmailman%2Flistinfo%2Fhaskell-cafe\46sa\75D\46sntz\0751\46usg\75AFQjCNHiVycCM53czUVzPma4Fkb_wPqP2A';return true;">http://www.haskell.org/<wbr>mailman/listinfo/haskell-cafe</a>
<br></blockquote></div></div></div>