sanctuary icon indicating copy to clipboard operation
sanctuary copied to clipboard

Add `asum`

Open masaeedu opened this issue 7 years ago • 1 comments

// :: (Foldable f, Plus g) => TypeRep g -> f (g a) -> g a
const asum = A => S.reduce(S.alt)(S.zero(A))

masaeedu avatar Nov 27 '18 22:11 masaeedu

I should note here that Flutures might be one common Alt that we wish to use this function with, however after some discussion in the Fluture chatroom it was concluded that it doesn't make much sense for the non-concurrent Fluture to implement the full Plus; instead it's only going to implement Alt.

To work with such instances, it might be better for asum to explicitly accept a zero case and weaken the constraint to:

// :: (Foldable f, Alt g) => f (g a) -> g a -> g a

masaeedu avatar Nov 28 '18 20:11 masaeedu