-- |
-- Module      : Data.Text.Format.Params
-- Copyright   : (c) 2011 MailRank, Inc.
--
-- License     : BSD-style
-- Maintainer  : bos@serpentine.com
-- Stability   : experimental
-- Portability : GHC
--
-- Types that can be used as a collection of arguments for formatting.

module Data.Text.Format.Params
    (
      Params(..)
    ) where

import Data.Text.Buildable
import Data.Text.Format.Types
import Data.Text.Lazy.Builder

-- | The class of types that can be used as a collection of arguments
-- for formatting.
class Params ps where
    buildParams :: ps -> [Builder]

instance Params () where
    buildParams :: () -> [Builder]
buildParams ()
_ = []

instance (Buildable a) => Params (Only a) where
    buildParams :: Only a -> [Builder]
buildParams (Only a
a) = [forall p. Buildable p => p -> Builder
build a
a]

instance (Buildable a) => Params [a] where
    buildParams :: [a] -> [Builder]
buildParams = forall a b. (a -> b) -> [a] -> [b]
map forall p. Buildable p => p -> Builder
build

instance (Buildable a, Buildable b) => Params (a,b) where
    buildParams :: (a, b) -> [Builder]
buildParams (a
a,b
b) = [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b]

instance (Buildable a, Buildable b, Buildable c) => Params (a,b,c) where
    buildParams :: (a, b, c) -> [Builder]
buildParams (a
a,b
b,c
c) = [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c]

instance (Buildable a, Buildable b, Buildable c, Buildable d)
    => Params (a,b,c,d) where
    buildParams :: (a, b, c, d) -> [Builder]
buildParams (a
a,b
b,c
c,d
d) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e)
    => Params (a,b,c,d,e) where
    buildParams :: (a, b, c, d, e) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f)
    => Params (a,b,c,d,e,f) where
    buildParams :: (a, b, c, d, e, f) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g)
    => Params (a,b,c,d,e,f,g) where
    buildParams :: (a, b, c, d, e, f, g) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g, Buildable h)
    => Params (a,b,c,d,e,f,g,h) where
    buildParams :: (a, b, c, d, e, f, g, h) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g, forall p. Buildable p => p -> Builder
build h
h]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g, Buildable h, Buildable i)
    => Params (a,b,c,d,e,f,g,h,i) where
    buildParams :: (a, b, c, d, e, f, g, h, i) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g, forall p. Buildable p => p -> Builder
build h
h, forall p. Buildable p => p -> Builder
build i
i]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j)
    => Params (a,b,c,d,e,f,g,h,i,j) where
    buildParams :: (a, b, c, d, e, f, g, h, i, j) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g, forall p. Buildable p => p -> Builder
build h
h, forall p. Buildable p => p -> Builder
build i
i, forall p. Buildable p => p -> Builder
build j
j]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
          Buildable k)
    => Params (a,b,c,d,e,f,g,h,i,j,k) where
    buildParams :: (a, b, c, d, e, f, g, h, i, j, k) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g, forall p. Buildable p => p -> Builder
build h
h, forall p. Buildable p => p -> Builder
build i
i, forall p. Buildable p => p -> Builder
build j
j,
         forall p. Buildable p => p -> Builder
build k
k]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
          Buildable k, Buildable l)
    => Params (a,b,c,d,e,f,g,h,i,j,k,l) where
    buildParams :: (a, b, c, d, e, f, g, h, i, j, k, l) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k,l
l) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g, forall p. Buildable p => p -> Builder
build h
h, forall p. Buildable p => p -> Builder
build i
i, forall p. Buildable p => p -> Builder
build j
j,
         forall p. Buildable p => p -> Builder
build k
k, forall p. Buildable p => p -> Builder
build l
l]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
          Buildable k, Buildable l, Buildable m)
    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m) where
    buildParams :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k,l
l,m
m) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g, forall p. Buildable p => p -> Builder
build h
h, forall p. Buildable p => p -> Builder
build i
i, forall p. Buildable p => p -> Builder
build j
j,
         forall p. Buildable p => p -> Builder
build k
k, forall p. Buildable p => p -> Builder
build l
l, forall p. Buildable p => p -> Builder
build m
m]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
          Buildable k, Buildable l, Buildable m, Buildable n)
    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n) where
    buildParams :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k,l
l,m
m,n
n) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g, forall p. Buildable p => p -> Builder
build h
h, forall p. Buildable p => p -> Builder
build i
i, forall p. Buildable p => p -> Builder
build j
j,
         forall p. Buildable p => p -> Builder
build k
k, forall p. Buildable p => p -> Builder
build l
l, forall p. Buildable p => p -> Builder
build m
m, forall p. Buildable p => p -> Builder
build n
n]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
          Buildable k, Buildable l, Buildable m, Buildable n, Buildable o)
    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) where
    buildParams :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k,l
l,m
m,n
n,o
o) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g, forall p. Buildable p => p -> Builder
build h
h, forall p. Buildable p => p -> Builder
build i
i, forall p. Buildable p => p -> Builder
build j
j,
         forall p. Buildable p => p -> Builder
build k
k, forall p. Buildable p => p -> Builder
build l
l, forall p. Buildable p => p -> Builder
build m
m, forall p. Buildable p => p -> Builder
build n
n, forall p. Buildable p => p -> Builder
build o
o]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
          Buildable k, Buildable l, Buildable m, Buildable n, Buildable o,
          Buildable p)
    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) where
    buildParams :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k,l
l,m
m,n
n,o
o,p
p) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g, forall p. Buildable p => p -> Builder
build h
h, forall p. Buildable p => p -> Builder
build i
i, forall p. Buildable p => p -> Builder
build j
j,
         forall p. Buildable p => p -> Builder
build k
k, forall p. Buildable p => p -> Builder
build l
l, forall p. Buildable p => p -> Builder
build m
m, forall p. Buildable p => p -> Builder
build n
n, forall p. Buildable p => p -> Builder
build o
o,
         forall p. Buildable p => p -> Builder
build p
p]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
          Buildable k, Buildable l, Buildable m, Buildable n, Buildable o,
          Buildable p, Buildable r)
    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r) where
    buildParams :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, r) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k,l
l,m
m,n
n,o
o,p
p,r
r) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g, forall p. Buildable p => p -> Builder
build h
h, forall p. Buildable p => p -> Builder
build i
i, forall p. Buildable p => p -> Builder
build j
j,
         forall p. Buildable p => p -> Builder
build k
k, forall p. Buildable p => p -> Builder
build l
l, forall p. Buildable p => p -> Builder
build m
m, forall p. Buildable p => p -> Builder
build n
n, forall p. Buildable p => p -> Builder
build o
o,
         forall p. Buildable p => p -> Builder
build p
p, forall p. Buildable p => p -> Builder
build r
r]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
          Buildable k, Buildable l, Buildable m, Buildable n, Buildable o,
          Buildable p, Buildable r, Buildable s)
    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s) where
    buildParams :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, r, s) -> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k,l
l,m
m,n
n,o
o,p
p,r
r,s
s) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g, forall p. Buildable p => p -> Builder
build h
h, forall p. Buildable p => p -> Builder
build i
i, forall p. Buildable p => p -> Builder
build j
j,
         forall p. Buildable p => p -> Builder
build k
k, forall p. Buildable p => p -> Builder
build l
l, forall p. Buildable p => p -> Builder
build m
m, forall p. Buildable p => p -> Builder
build n
n, forall p. Buildable p => p -> Builder
build o
o,
         forall p. Buildable p => p -> Builder
build p
p, forall p. Buildable p => p -> Builder
build r
r, forall p. Buildable p => p -> Builder
build s
s]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
          Buildable k, Buildable l, Buildable m, Buildable n, Buildable o,
          Buildable p, Buildable r, Buildable s, Buildable t)
    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s,t) where
    buildParams :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, r, s, t)
-> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k,l
l,m
m,n
n,o
o,p
p,r
r,s
s,t
t) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g, forall p. Buildable p => p -> Builder
build h
h, forall p. Buildable p => p -> Builder
build i
i, forall p. Buildable p => p -> Builder
build j
j,
         forall p. Buildable p => p -> Builder
build k
k, forall p. Buildable p => p -> Builder
build l
l, forall p. Buildable p => p -> Builder
build m
m, forall p. Buildable p => p -> Builder
build n
n, forall p. Buildable p => p -> Builder
build o
o,
         forall p. Buildable p => p -> Builder
build p
p, forall p. Buildable p => p -> Builder
build r
r, forall p. Buildable p => p -> Builder
build s
s, forall p. Buildable p => p -> Builder
build t
t]

instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
          Buildable k, Buildable l, Buildable m, Buildable n, Buildable o,
          Buildable p, Buildable r, Buildable s, Buildable t, Buildable u)
    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s,t,u) where
    buildParams :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, r, s, t, u)
-> [Builder]
buildParams (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k,l
l,m
m,n
n,o
o,p
p,r
r,s
s,t
t,u
u) =
        [forall p. Buildable p => p -> Builder
build a
a, forall p. Buildable p => p -> Builder
build b
b, forall p. Buildable p => p -> Builder
build c
c, forall p. Buildable p => p -> Builder
build d
d, forall p. Buildable p => p -> Builder
build e
e,
         forall p. Buildable p => p -> Builder
build f
f, forall p. Buildable p => p -> Builder
build g
g, forall p. Buildable p => p -> Builder
build h
h, forall p. Buildable p => p -> Builder
build i
i, forall p. Buildable p => p -> Builder
build j
j,
         forall p. Buildable p => p -> Builder
build k
k, forall p. Buildable p => p -> Builder
build l
l, forall p. Buildable p => p -> Builder
build m
m, forall p. Buildable p => p -> Builder
build n
n, forall p. Buildable p => p -> Builder
build o
o,
         forall p. Buildable p => p -> Builder
build p
p, forall p. Buildable p => p -> Builder
build r
r, forall p. Buildable p => p -> Builder
build s
s, forall p. Buildable p => p -> Builder
build t
t, forall p. Buildable p => p -> Builder
build u
u]