module Data.Help (
	Help(..),
	indent, indentHelp, detailed, indented
	) where

import Data.Text (Text)
import qualified Data.Text as T

class Help a where
	brief :: a -> Text
	help :: a -> [Text]

indent :: Text -> Text
indent :: Text -> Text
indent = Char -> Text -> Text
T.cons Char
'\t'

indentHelp :: [Text] -> [Text]
indentHelp :: [Text] -> [Text]
indentHelp [] = []
indentHelp (Text
h:[Text]
hs) = Text
h Text -> [Text] -> [Text]
forall a. a -> [a] -> [a]
: (Text -> Text) -> [Text] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map Text -> Text
indent [Text]
hs

detailed :: Help a => a -> [Text]
detailed :: a -> [Text]
detailed a
v = a -> Text
forall a. Help a => a -> Text
brief a
v Text -> [Text] -> [Text]
forall a. a -> [a] -> [a]
: a -> [Text]
forall a. Help a => a -> [Text]
help a
v

indented :: Help a => a -> [Text]
indented :: a -> [Text]
indented = [Text] -> [Text]
indentHelp ([Text] -> [Text]) -> (a -> [Text]) -> a -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> [Text]
forall a. Help a => a -> [Text]
detailed