morphismtech / squeal

Squeal, a deep embedding of SQL in Haskell
362 stars 32 forks source link

Add tuple row decoders #330

Closed echatav closed 2 years ago

echatav commented 2 years ago

There should be row decoders for common cases of tuples. How far up should it go? Maybe only up to quadrupleRow?

pairRow
  :: (FromValue x0 ty0, FromValue x1 ty1)
  => DecodeRow '[col0 ::: ty0, col1 ::: ty1] (x0,x1)

tripleRow
  :: (FromValue x0 ty0, FromValue x1 ty1, FromValue x2 ty2)
  => DecodeRow '[col0 ::: ty0, col1 ::: ty1, col2 ::: ty2] (x0,x1,x2)

Should there be a singleRow?

echatav commented 2 years ago

Alternatively, a single function genericProductRow could be added. This would mirror current encoders.

genericRow / genericRowParams would match records (position and field) as decoder / encoder genericProductRow / genericParams would match products (position) including records & tuples as decoder / encoder