module Graphics.Layout.Grid.Table where type Overflowed = [Int] emptyRow :: Overflowed emptyRow = [] commitRow :: Overflowed -> Overflowed commitRow = map $ max 0 . pred allocCol :: Int -> Overflowed -> Int allocCol ix cols = ix + length (span (> 0) $ drop ix cols) insertCell :: Int -> Int -> Int -> Overflowed -> Overflowed insertCell ix colspan rowspan cols = before ++ replicate colspan rowspan ++ drop colspan after where (before, after) = splitAt ix cols