1
1
mirror of https://github.com/github/semantic.git synced 2024-11-27 12:57:49 +03:00

Factor out a resolveWith function.

This commit is contained in:
Rob Rix 2022-02-03 11:31:17 -05:00
parent b1660bf2b1
commit 2e5d6160f6
No known key found for this signature in database
GPG Key ID: 2BE643E01DC032AE

View File

@ -167,6 +167,7 @@ parseNode o = do
sink <- edge A..: pack "sink"
attrs <- edge A..: pack "attrs"
f sink attrs)
resolve = edge (const . pure . flip (IntMap.!))
resolve = resolveWith (const (pure ()))
resolveWith f = edge (\ sink attrs -> f attrs >> pure (IntMap.! sink))
findEdgeNamed name = foldMap (edge (\ sink attrs -> attrs A..: pack "type" >>= guard . (== name) >> pure (IntMap.! sink))) edges
o A..: pack "attrs" >>= A.withObject "attrs" (fmap (index,) . parseType)