1
1
mirror of https://github.com/github/semantic.git synced 2024-11-25 11:04:00 +03:00

Replace GToTag with GFold1 ToTags.

This commit is contained in:
Rob Rix 2019-09-24 16:35:23 -04:00
parent f25af24099
commit 80ccf3c985
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -7,6 +7,7 @@ import Control.Effect.Reader
import Control.Effect.Writer
import Data.Foldable (traverse_)
import Data.Maybe (listToMaybe)
import Data.Monoid (Ap(..))
import Data.List.NonEmpty (NonEmpty(..))
import Data.Text as T
import GHC.Generics
@ -108,40 +109,5 @@ docComment _ _ = Nothing
firstLine :: Source -> Text
firstLine = T.take 180 . T.takeWhile (/= '\n') . toText
instance (Generic1 t, GToTag (Rep1 t)) => ToTagBy 'Generic t where
tags' = gtags . from1
class GToTag t where
gtags
:: ( Carrier sig m
, Member (Reader Source) sig
, Member (Writer Tags.Tags) sig
)
=> t Loc
-> m ()
instance GToTag f => GToTag (M1 i c f) where
gtags = gtags . unM1
instance (GToTag f, GToTag g) => GToTag (f :*: g) where
gtags (f :*: g) = gtags f >> gtags g
instance (GToTag f, GToTag g) => GToTag (f :+: g) where
gtags (L1 l) = gtags l
gtags (R1 r) = gtags r
instance GToTag (K1 R t) where
gtags _ = pure ()
instance GToTag Par1 where
gtags _ = pure ()
instance ToTags t => GToTag (Rec1 t) where
gtags = tags . unRec1
instance (Foldable f, GToTag g) => GToTag (f :.: g) where
gtags = mapM_ gtags . unComp1
instance GToTag U1 where
gtags _ = pure ()
instance (Generic1 t, Tags.GFold1 ToTags (Rep1 t)) => ToTagBy 'Generic t where
tags' = getAp . Tags.gfold1 @ToTags (Ap . tags) . from1