Last active
April 15, 2016 16:19
-
-
Save mrvdb/613f6f66a4f3757dfe4daef61b899902 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
-- Get the number of posts that satisfy a pattern | |
postCount :: Pattern -> Int | |
postCount pattern = do | |
-- something with getMatches sounds right | |
m' <- getMatches pattern -- getMatches :: MonadMetadata m => Pattern -> m [Identifier] | |
-- return $ length m' -- Inclined to do return here... | |
-- what do I put here? | |
-- Other relevant stuff: | |
-- https://jaspervdj.be/hakyll/reference/Hakyll-Core-Identifier-Pattern.html | |
postsPattern :: Pattern | |
postsPattern = "sites/main/_posts/2*.org" | |
-- From boomerang: | |
-- How do I use this then? | |
postCount' :: MonadMetadata m => Pattern -> m Int | |
postCount' pattern = length <$> getMatches pattern -- getMatches :: MonadMetadata m => Pattern -> m [Identifier] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looking at the definition of MonadMetadata it looks like
Compiler
andRules
are instances ofMonadMetadata
. So you can callpostCount'
in ado
statement in whatever function with type signature... -> Rules a
or... -> Compiler a
Boomerang :)