1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Define a foldMapDefault1 function usable as a default definition of foldMap.

This commit is contained in:
Rob Rix 2020-01-13 14:27:37 -05:00
parent 81aab02035
commit d979ce7d19
No known key found for this signature in database
GPG Key ID: 2BE643E01DC032AE

View File

@ -20,6 +20,7 @@ module Tags.Tagging.Precise
, Traversable1(..)
, for1
, foldMap1
, foldMapDefault1
, GTraversable1(..)
, Generics(..)
) where
@ -103,6 +104,11 @@ foldMap1 :: forall c t b a . (Traversable1 c t, Monoid b) => (a -> b) -> (forall
foldMap1 f g = getConst . traverse1 @c (Const . f) (Const . g)
-- | This function may be used as a value for 'foldMap' in a 'Foldable' instance.
foldMapDefault1 :: (Traversable1 Foldable t, Monoid b) => (a -> b) -> t a -> b
foldMapDefault1 f = foldMap1 @Foldable f (foldMap f)
-- FIXME: move GTraversable1 into semantic-ast.
class GTraversable1 c t where
-- | Generically map annotations and subterms of kind @* -> *@ into an 'Applicative' context.