add more functions for tweaking headedness

This commit is contained in:
Andrew Martin 2017-02-25 14:08:49 -05:00
parent e0a0f66a43
commit c646c467c9

View File

@ -1,4 +1,5 @@
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# OPTIONS_GHC -Wall -fno-warn-unused-imports -fno-warn-unticked-promoted-constructors -Werror #-} {-# OPTIONS_GHC -Wall -fno-warn-unused-imports -fno-warn-unticked-promoted-constructors -Werror #-}
@ -16,12 +17,16 @@ module Colonnade
, headless , headless
, singleton , singleton
-- * Transform -- * Transform
, mapHeaderContent -- ** Body
, fromMaybe , fromMaybe
, columns , columns
, bool , bool
, replaceWhen , replaceWhen
, modifyWhen , modifyWhen
-- ** Header
, mapHeaderContent
, mapHeadedness
, toHeadless
-- * Cornice -- * Cornice
-- ** Types -- ** Types
, Cornice , Cornice
@ -118,6 +123,16 @@ mapHeaderContent :: Functor h => (c -> c) -> Colonnade h a c -> Colonnade h a c
mapHeaderContent f (E.Colonnade v) = mapHeaderContent f (E.Colonnade v) =
E.Colonnade (Vector.map (\(E.OneColonnade h e) -> E.OneColonnade (fmap f h) e) v) E.Colonnade (Vector.map (\(E.OneColonnade h e) -> E.OneColonnade (fmap f h) e) v)
-- | Map over the header type of a 'Colonnade'.
mapHeadedness :: (forall x. h x -> h' x) -> Colonnade h a c -> Colonnade h' a c
mapHeadedness f (E.Colonnade v) =
E.Colonnade (Vector.map (\(E.OneColonnade h e) -> E.OneColonnade (f h) e) v)
-- | Remove the heading from a 'Colonnade'.
toHeadless :: Colonnade h a c -> Colonnade Headless a c
toHeadless = mapHeadedness (const Headless)
-- | Lift a column over a 'Maybe'. For example, if some people -- | Lift a column over a 'Maybe'. For example, if some people
-- have houses and some do not, the data that pairs them together -- have houses and some do not, the data that pairs them together
-- could be represented as: -- could be represented as: