1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 00:42:33 +03:00

Define a foldMap1 convenience using traverse1.

This commit is contained in:
Rob Rix 2020-01-13 13:35:18 -05:00
parent 0c6e09849b
commit a8f666ad5b
No known key found for this signature in database
GPG Key ID: 2BE643E01DC032AE

View File

@ -16,11 +16,13 @@ module Tags.Tagging.Precise
, firstLine
, GFoldable1(..)
, Traversable1(..)
, foldMap1
, GTraversable1(..)
) where
import Control.Carrier.Reader
import Control.Carrier.Writer.Strict
import Data.Functor.Const
import Data.Functor.Identity
import Data.Monoid (Endo (..))
import Data.Text as Text (Text, takeWhile)
@ -105,6 +107,10 @@ class Traversable1 c t where
-> f (t b)
traverse1 f g = fmap to1 . gtraverse1 @c f g . from1
foldMap1 :: forall c t b a . (Traversable1 c t, Monoid b) => (a -> b) -> (forall t' . c t' => t' a -> b) -> t a -> b
foldMap1 f g = getConst . traverse1 @c (Const . f) (Const . g)
class GTraversable1 c t where
-- | Generically map annotations and subterms of kind @* -> *@ into an 'Applicative' context.
gtraverse1