-------------------------------------------------------------------------------- |-- Module: Database.PostgreSQL.Simple.ToRow-- Copyright: (c) 2011 MailRank, Inc.-- (c) 2011-2012 Leon P Smith-- License: BSD3-- Maintainer: Leon P Smith <leon@melding-monads.com>-- Stability: experimental---- The 'ToRow' typeclass, for rendering a collection of-- parameters to a SQL query.---- Predefined instances are provided for tuples containing up to ten-- elements.--------------------------------------------------------------------------------moduleDatabase.PostgreSQL.Simple.ToRow(ToRow(..))whereimportDatabase.PostgreSQL.Simple.ToField(Action(..),ToField(..))importDatabase.PostgreSQL.Simple.Types(Only(..),(:.)(..))-- | A collection type that can be turned into a list of rendering-- 'Action's.---- Instances should use the 'render' method of the 'Param' class-- to perform conversion of each element of the collection.classToRowawheretoRow::a->[Action]-- ^ ToField a collection of values.instanceToRow()wheretoRow_=[]instance(ToFielda)=>ToRow(Onlya)wheretoRow(Onlyv)=[toFieldv]instance(ToFielda,ToFieldb)=>ToRow(a,b)wheretoRow(a,b)=[toFielda,toFieldb]instance(ToFielda,ToFieldb,ToFieldc)=>ToRow(a,b,c)wheretoRow(a,b,c)=[toFielda,toFieldb,toFieldc]instance(ToFielda,ToFieldb,ToFieldc,ToFieldd)=>ToRow(a,b,c,d)wheretoRow(a,b,c,d)=[toFielda,toFieldb,toFieldc,toFieldd]instance(ToFielda,ToFieldb,ToFieldc,ToFieldd,ToFielde)=>ToRow(a,b,c,d,e)wheretoRow(a,b,c,d,e)=[toFielda,toFieldb,toFieldc,toFieldd,toFielde]instance(ToFielda,ToFieldb,ToFieldc,ToFieldd,ToFielde,ToFieldf)=>ToRow(a,b,c,d,e,f)wheretoRow(a,b,c,d,e,f)=[toFielda,toFieldb,toFieldc,toFieldd,toFielde,toFieldf]instance(ToFielda,ToFieldb,ToFieldc,ToFieldd,ToFielde,ToFieldf,ToFieldg)=>ToRow(a,b,c,d,e,f,g)wheretoRow(a,b,c,d,e,f,g)=[toFielda,toFieldb,toFieldc,toFieldd,toFielde,toFieldf,toFieldg]instance(ToFielda,ToFieldb,ToFieldc,ToFieldd,ToFielde,ToFieldf,ToFieldg,ToFieldh)=>ToRow(a,b,c,d,e,f,g,h)wheretoRow(a,b,c,d,e,f,g,h)=[toFielda,toFieldb,toFieldc,toFieldd,toFielde,toFieldf,toFieldg,toFieldh]instance(ToFielda,ToFieldb,ToFieldc,ToFieldd,ToFielde,ToFieldf,ToFieldg,ToFieldh,ToFieldi)=>ToRow(a,b,c,d,e,f,g,h,i)wheretoRow(a,b,c,d,e,f,g,h,i)=[toFielda,toFieldb,toFieldc,toFieldd,toFielde,toFieldf,toFieldg,toFieldh,toFieldi]instance(ToFielda,ToFieldb,ToFieldc,ToFieldd,ToFielde,ToFieldf,ToFieldg,ToFieldh,ToFieldi,ToFieldj)=>ToRow(a,b,c,d,e,f,g,h,i,j)wheretoRow(a,b,c,d,e,f,g,h,i,j)=[toFielda,toFieldb,toFieldc,toFieldd,toFielde,toFieldf,toFieldg,toFieldh,toFieldi,toFieldj]instance(ToFielda)=>ToRow[a]wheretoRow=maptoFieldinstance(ToRowa,ToRowb)=>ToRow(a:.b)wheretoRow(a:.b)=toRowa++toRowb