-- |
--
-- Builder function for 'JArray'
--
module Waargonaut.Encode.Builder.JArray (jArrayBuilder) where

import           Waargonaut.Types.JArray            (JArray (..))

import           Waargonaut.Encode.Builder.CommaSep (commaSeparatedBuilder)
import           Waargonaut.Encode.Builder.Types    (Builder)

-- | Using the given builders, build a 'JArray'.
jArrayBuilder
  :: Monoid b
  => Builder t b
  -> (Builder t b -> ws -> b)
  -> ((Builder t b -> ws -> b) -> Builder t b -> a -> b)
  -> JArray ws a
  -> b
jArrayBuilder :: Builder t b
-> (Builder t b -> ws -> b)
-> ((Builder t b -> ws -> b) -> Builder t b -> a -> b)
-> JArray ws a
-> b
jArrayBuilder Builder t b
bldr Builder t b -> ws -> b
ws (Builder t b -> ws -> b) -> Builder t b -> a -> b
a (JArray CommaSeparated ws a
cs) =
  Builder t b
-> Char
-> Char
-> (Builder t b -> ws -> b)
-> (Builder t b -> a -> b)
-> CommaSeparated ws a
-> b
forall ws a t b.
Monoid b =>
Builder t b
-> Char
-> Char
-> (Builder t b -> ws -> b)
-> (Builder t b -> a -> b)
-> CommaSeparated ws a
-> b
commaSeparatedBuilder Builder t b
bldr Char
'[' Char
']' Builder t b -> ws -> b
ws ((Builder t b -> ws -> b) -> Builder t b -> a -> b
a Builder t b -> ws -> b
ws) CommaSeparated ws a
cs