-- the controller is the most complex module for a reason: -- models are made as simple and small as possible -- views are pure functions. -- a note on encoding: -- uniform utf-8 enforced by custom io wrapper {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NamedFieldPuns #-} module Bamboo.Controller.Index where import Bamboo.Controller.Env index :: Controller index = do init_state (posts, pager) <- list.io >>= (mapM init_post_meta_data) >>= paged let nav_location = if pager.current == 1 then home_nav else no_navigation s <- get put s { uid = s.config.post_id , pager , nav_location , posts } index_feed :: Controller index_feed = do s <- get posts <- list .io ^ take (s.config.number_of_latest_posts) put s { posts }