{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
module RecordShellToMarkdown.Data
( ShellIO(..)
, RecordShellToMarkdownState
) where
import Control.Monad.Trans.State (StateT)
import Data.Sequence (Seq(..))
import qualified Data.Sequence as Seq
import qualified Data.Text as T
import RecordShellToMarkdown.Print (joinSequence)
type RecordShellToMarkdownState a = StateT (Seq ShellIO) IO a
data ShellIO = ShellIO
{ shell_inputs :: Seq T.Text
, shell_output :: !T.Text
, shell_wd :: T.Text
}
instance Show ShellIO where
show ShellIO {..} =
T.unpack $
joinSequence (fmap ("> " <>) shell_inputs) <> "\n" <> shell_output