module MdBlocks.Resolver ( resolveBlock ) where import Data.Text (Text) import MdBlocks.Address import MdBlocks.Types resolveBlock :: Address -> [Block] -> Maybe Block resolveBlock address = findByFileAndId (addressFile address) (addressId address) findByFileAndId :: FilePath -> Text -> [Block] -> Maybe Block findByFileAndId fp ident = go where go [] = Nothing go (b:bs) | blockFile b == fp , mdId (blockMeta b) == Just ident = Just b | otherwise = go bs