Skip to content

Instantly share code, notes, and snippets.

@GallagherCommaJack
Created September 18, 2015 19:40
Show Gist options
  • Save GallagherCommaJack/86b729900c9ee8893467 to your computer and use it in GitHub Desktop.
Save GallagherCommaJack/86b729900c9ee8893467 to your computer and use it in GitHub Desktop.
dashSlashSlashDelete :: (Show a, Show b, Show c) => a -> b -> c -> Routes
dashSlashSlashDelete a b c = let sa = show a
sb = if length (show b) < 2 then '0':show b else show b
sc = if length (show c) < 2 then '0':show c else show c
in gsubRoute (fold $ intersperse "-" [sa, sb, sc, ""]) (const $ fold $ intersperse "/" [sa, sb, ""]) -- gsubRoute apparently succeeds even when it should fail
`composeRoutes` matchRoute (fromGlob "*/*/*") idRoute -- this oughta fix that
dashSlashList :: (Show a, Show b, Show c) => [a] -> [b] -> [c] -> [Routes]
dashSlashList as bs cs = [dashSlashSlashDelete a b c | a <- as, b <- bs, c <- cs]
dashSlashFoldList :: (Show a, Show b, Show c) => [a] -> [b] -> [c] -> Routes
dashSlashFoldList as bs cs = fold $ dashSlashList as bs cs
-- runRoutes (dashSlashSlashDelete a b c) (show a <> "-" <> show b <> "-" <> show c <> "-" <> str) = show a <> "/" <> show b <> "/" <> str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment