module Text.Layout.Table.Spec.LenSpec
    ( LenSpec (..)
    , expand
    , fixed
    , expandUntil
    , fixedUntil
    , expandBetween
    ) where

import Data.Default.Class

-- | Determines how long a column will be.
data LenSpec
    = Expand
    | Fixed Int
    | ExpandUntil Int
    | FixedUntil Int
    | ExpandBetween Int Int

-- | The default 'LenSpec' allows columns to use as much space as needed.
instance Default LenSpec where
    def :: LenSpec
def = LenSpec
expand

-- | Allows columns to use as much space as needed.
expand :: LenSpec
expand :: LenSpec
expand = LenSpec
Expand

-- | Fixes column length to a specific width.
fixed :: Int -> LenSpec
fixed :: Int -> LenSpec
fixed = Int -> LenSpec
Fixed

-- | The column will expand as long as it is smaller as the given width.
expandUntil :: Int -> LenSpec
expandUntil :: Int -> LenSpec
expandUntil = Int -> LenSpec
ExpandUntil

-- | The column will be at least as wide as the given width.
fixedUntil :: Int -> LenSpec
fixedUntil :: Int -> LenSpec
fixedUntil = Int -> LenSpec
FixedUntil

-- | The column will be at least as wide as the first width, and will expand as
-- long as it is smaller than the second.
expandBetween :: Int -> Int -> LenSpec
expandBetween :: Int -> Int -> LenSpec
expandBetween = Int -> Int -> LenSpec
ExpandBetween