{-# LANGUAGE DataKinds #-}

module Data.KVITable.Internal.Helpers where

import Data.Name ( Name )


type Keys = [Name "Key"]


single :: e -> [e]
single :: forall e. e -> [e]
single = (e -> [e] -> [e]
forall a. a -> [a] -> [a]
:[])

snoc :: [a] -> a -> [a]
snoc :: forall a. [a] -> a -> [a]
snoc [a]
l a
e = [a]
l [a] -> [a] -> [a]
forall a. Semigroup a => a -> a -> a
<> [a
e]

maxOf :: (Foldable t, Ord e) => e -> t e -> e
maxOf :: forall (t :: * -> *) e. (Foldable t, Ord e) => e -> t e -> e
maxOf e
v t e
l = if t e -> Bool
forall a. t a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null t e
l then e
v else e -> e -> e
forall a. Ord a => a -> a -> a
max e
v (e -> e) -> e -> e
forall a b. (a -> b) -> a -> b
$ t e -> e
forall a. Ord a => t a -> a
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
maximum t e
l