-
-
Save dminuoso/3b1e7a2f5eab7055e7438f8dd5da7f1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lookupDel :: (Eq a) => a -> [(a,b)] -> (b -> [(a, b)] -> t) -> t -> t | |
lookupDel key as just nothing = go as [] | |
where | |
go ((x,y):xys) ss | |
| key == x = just y (ss <> xys) | |
| otherwise = go xys ((x,y) : ss) | |
go [] ss = nothing | |
workMembers :: [IT.TextTree ASpec] -> [(T.Text, Attr)] -> [(Attr, IT.TextTree ASpec)] -> ExM [EncodableAttr] | |
workMembers (m:ms) req es = let aspec = IT.rootValue m | |
member = asNam aspec | |
in lookupDel member req (\n req' -> workMembers ms req' ((n, m):es)) | |
(workMembers ms req es) | |
workMembers [] req@(_:_) es = abort (EE_MissingMembers (attrNam [nam]) (fst <$> req)) | |
workMembers ms@(_:_) [] es = abort (EE_ExtraMembers (attrNam [nam]) (asNam . IT.rootValue <$> ms)) | |
workMembers [] [] es = traverse (\(attr, subtree') -> | |
go (p `dlistSnoc` nam) subtree' attr | |
) es | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment