mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +03:00
Define a foldMapDefault1 function usable as a default definition of foldMap.
This commit is contained in:
parent
81aab02035
commit
d979ce7d19
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user