ekmett / free

free monads
http://hackage.haskell.org/package/free
Other
161 stars 65 forks source link

Add Foldable instance for the free applicative #221

Closed viercc closed 1 year ago

viercc commented 1 year ago

This adds Foldable Ap and Foldable1 Ap instance to the free applicative Control.Applicative.Free.Ap.

The intended behavior of Foldable (Ap f) instance is to satisfy:

toList @(Ap f) == runAp (toList @f) :: Ap f a -> [a]

Similarly, Foldable1 (Ap f) is meant to satisfy

toNonEmpty @(Ap f) == runAp (toNonEmpty @f) :: Ap f a -> NonEmpty a