) where
import Data.Function (on)
-import Data.List (sortBy, groupBy)
+import Data.List (sort, sortBy, groupBy)
import Data.Ord (comparing)
import Data.String hiding (lines)
import Data.Text hiding (groupBy, map, concat, foldl, head, splitAt, filter, zip, length, reverse)
myGroup :: (Eq a, Ord a) => [(a, b)] -> [(a, [b])]
myGroup = map (\l -> (fst . head $ l, map snd l)) . groupBy ((==) `on` fst) . sortBy (comparing fst)
+myGroupNoSort :: (Eq a, Ord a) => [(a, b)] -> [(a, [b])]
+myGroupNoSort = map (\l -> (fst . head $ l, map snd l)) . groupBy ((==) `on` fst)
+
stampsToEntryList :: [BlogEntry] -> EntryList
-stampsToEntryList stamps = reverse $ map (\(a,b) -> (a, reverse $ map (\(c,d) -> (c, map (\(x, y) -> ("0" `append` (fromString . show) x, y)) $ zip [1..] d)) b)) $
- map (\(a, b) -> (a, myGroup b)) $
- map (\(a, b) -> (a, concat b)) $ myGroup $
+stampsToEntryList stamps = map (\(a,b) -> (a, reverse $ map (\(c,d) -> (c, reverse $ map (\(x, y) -> ("0" `append` (fromString . show) x, y)) $ zip [1..] d)) b)) $
+ map (\(a, b) -> (a, myGroupNoSort b)) $
+ map (\(a, b) -> (a, concat b)) $ myGroupNoSort $
foldl (\c -> \v ->
c ++ [(format (postDate v) "%Y", [(format (postDate v) "%B", v)])]) [] stamps
writeFile "build/index.html" $ unpack $ toStrict $ render indexTemplate indexContext
someFunc = do
- files <- allFilesIn "entries"
+ files <- fmap (reverse . sort) $ allFilesIn "entries"
rawEntries <- mapM (\x -> (readFile ("entries/" ++ x)) >>= (\y -> (return . fromString) y)) files
entryList <- mapM (\raw -> return $ rawTextToEntry raw) rawEntries
entryPaths <- return $ entryListToPaths $ stampsToEntryList entryList