Skip to content

Instantly share code, notes, and snippets.

@duairc
Created January 6, 2011 03:34
Show Gist options
  • Save duairc/767465 to your computer and use it in GitHub Desktop.
Save duairc/767465 to your computer and use it in GitHub Desktop.
loadTemplates path = readDirectoryWith reader path
>>= (free
-- DirTree (Maybe (FilePath, Either String ByteString))
>>> F.toList
-- [Maybe (String, Either String ByteString)]
>>> catMaybes
-- [(String, Either String ByteString)]
>>> unzip
-- ([String], [Either String ByteString])
>>> second partitionEithers
-- ([String], ([String], [ByteString]))
>>> second (first unlines)
-- ([String], (String, [ByteString]))
>>> subr
-- (String, ([String], [ByteString]))
>>> second (uncurry zip)
-- (String, [(String, ByteString)])
>>> second (map (first U.fromString))
-- (String, [(ByteString, ByteString)])
>>> second M.fromList
-- (String, Map ByteString ByteString)
>>> join (fmap toEither $ null . fst)
-- Either String (Map ByteString ByteString)
>>> return)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment