úÎ+#)Ë     (c) Francesco Gazzetta 2017BSD3 (see the file LICENSE)francygazz@gmail.orgstableportableSafe;=>?óLift a _ into an Accumulator. This is a newtype because (<>) isn't always the ideal way of accumulating`An 'Accumulator c i' supports accumulation of elements of type i in it. This is different from  or , where - acts between two values with the same type.Accumulate a single value in a +Strictly accumulate multiple values from a , from left to rightAccumulate a value(c) Francesco Gazzetta 2017BSD3 (see the file LICENSE)francygazz@gmail.org experimentalportableSafe;=>?)‹ YApplication of function with an arbitrary number of arguments to the elements of a list.<Will raise an error if the list doesn't have enough elementsExamples8apply ((+) :: Int -> Int -> Int) ([1,2] :: [Int]) :: Int3 <Creation of functions with an arbitrary number of arguments./The arguments will be accumulated in the given <, which will then be passed as an argument to the function.ExamplesÄThree integers to a list. Note that you have to add type annotations for nearly everything to avoid ambiguities >>> polyvariadic mempty (id :: [Int] -> [Int]) (1::Int) (2::Int) (3::Int) :: [Int] The classic printfV function, which takes an arbitrary amount of arguments and inserts them in a string: {- LANGUAGE MultiParamTypeClasses -} {- LANGUAGE FlexibleInstances -} {- LANGUAGE FlexibleContexts ÿf-} import Data.Function.Polyvariadic import Data.Accumulator magicChar = '%' notMagicChar = (/= magicChar) data PrintfAccum = PrintfAccum { done :: String, todo :: String } instance Show x => Accumulator PrintfAccum x where accumulate x (PrintfAccum done (_:todo)) = PrintfAccum (done ++ show x ++ takeWhile notMagicChar todo) (dropWhile notMagicChar todo) accumulate _ acc = acc printf' str = polyvariadic (PrintfAccum (takeWhile notMagicChar str) (dropWhile notMagicChar str)) done )printf' "aaa%bbb%ccc%ddd" "TEST" 123 True"aaa\"TEST\"bbb123cccTrueddd"Takes an accumulator acc , a function fP, and an arbitrary number of additional arguments which will be accumulated in acc, which is finally passed to f.Like   but with an arbitrary  instead if a listMThere are no more arguments to accumulate so the function is applied to the Accumulates the next argument8The final type is reached and the application terminates?The final type is not reached yet and the application continues          +polyvariadic-0.3.0.3-KimTdnT7cgmE7d7lhRbMFpData.AccumulatorData.Function.PolyvariadicAccumulatorSemigroupgetAccumulatorSemigroup Accumulator accumulate singletonaccumulateMany$fAccumulatorSeta$fAccumulator[]a$fSemigroupAccumulatorSemigroup5$fAccumulatorAccumulatorSemigroupAccumulatorSemigroupApplyapply' Polyvariadic polyvariadicapply%$fPolyvariadicaccumulatorresultresult$fPolyvariadiccb(->) $fApplyabb $fApplyab(->)baseData.Semigroup SemigroupGHC.BaseMonoid<> Data.FoldableFoldable