mirror of
https://github.com/github/semantic.git
synced 2024-11-27 12:57:49 +03:00
Factor out lists of child nodes.
This commit is contained in:
parent
82e00e4af0
commit
1ed8183066
@ -162,9 +162,10 @@ parseNode o = do
|
||||
"false" -> pure (const (bool False))
|
||||
"throw" -> fmap throw <$> resolve (head edges)
|
||||
"if" -> liftA3 iff <$> findEdgeNamed "condition" <*> findEdgeNamed "consequence" <*> findEdgeNamed "alternative" <|> pure (const noop)
|
||||
"block" -> fmap (foldr (\ (i, v) r -> let_ (nameI i) v (const r)) noop . zip [0..]) . sequenceA <$> traverse resolve edges
|
||||
"module" -> fmap (foldr (\ (i, v) r -> let_ (nameI i) v (const r)) noop . zip [0..]) . sequenceA <$> traverse resolve edges
|
||||
"block" -> children
|
||||
"module" -> children
|
||||
t -> A.parseFail ("unrecognized type: " <> t)
|
||||
children = fmap (foldr (\ (i, v) r -> let_ (nameI i) v (const r)) noop . zip [0..]) . sequenceA <$> traverse resolve edges
|
||||
resolve = resolveWith (const (pure ()))
|
||||
resolveWith :: (A.Object -> A.Parser ()) -> A.Value -> A.Parser (IntMap.IntMap rep -> rep)
|
||||
resolveWith f = A.withObject "edge" (\ edge -> do
|
||||
|
Loading…
Reference in New Issue
Block a user