{-# LANGUAGE NamedFieldPuns #-}{-# LANGUAGE RecordWildCards #-}-- SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com-- SPDX-License-Identifier: MITmodule Lining (toSingleLine, LineFormat (..), withLineFormat) whereimport CSTwithLineFormat :: (ToSingleLine a) => LineFormat -> a -> awithLineFormat MULTILINE prog = progwithLineFormat SINGLELINE prog = toSingleLine progdata LineFormat = SINGLELINE | MULTILINE deriving (Show, Eq)class ToSingleLine a where toSingleLine :: a -> ainstance ToSingleLine PROGRAM where toSingleLine PR_SALTY{..} = PR_SALTY global arrow (toSingleLine expr) toSingleLine PR_SWEET{..} = PR_SWEET lcb (toSingleLine expr) rcbinstance ToSingleLine EXPRESSION where toSingleLine EX_FORMATION{lsb, binding = bd@BI_EMPTY{..}, rsb} = EX_FORMATION lsb NO_EOL NO_TAB bd NO_EOL NO_TAB rsb toSingleLine EX_FORMATION{..} = EX_FORMATION lsb NO_EOL TAB' (toSingleLine binding) NO_EOL TAB' rsb toSingleLine EX_DISPATCH{..} = EX_DISPATCH (toSingleLine expr) attr toSingleLine EX_APPLICATION{..} = EX_APPLICATION (toSingleLine expr) NO_EOL TAB' (toSingleLine tau) NO_EOL TAB' indent toSingleLine EX_APPLICATION_TAUS{..} = EX_APPLICATION_TAUS (toSingleLine expr) NO_EOL TAB' (toSingleLine taus) NO_EOL TAB' indent toSingleLine EX_APPLICATION_EXPRS{..} = EX_APPLICATION_EXPRS (toSingleLine expr) NO_EOL TAB' (toSingleLine args) NO_EOL TAB' indent toSingleLine EX_PHI_MEET{..} = EX_PHI_MEET prefix idx (toSingleLine expr) toSingleLine EX_PHI_AGAIN{..} = EX_PHI_AGAIN prefix idx (toSingleLine expr) toSingleLine expr = exprinstance ToSingleLine APP_BINDING where toSingleLine APP_BINDING{..} = APP_BINDING (toSingleLine pair)instance ToSingleLine BINDING where toSingleLine BI_PAIR{..} = BI_PAIR (toSingleLine pair) (toSingleLine bindings) TAB' toSingleLine BI_META{..} = BI_META meta (toSingleLine bindings) TAB' toSingleLine bd = bdinstance ToSingleLine BINDINGS where toSingleLine BDS_PAIR{..} = BDS_PAIR NO_EOL TAB' (toSingleLine pair) (toSingleLine bindings) toSingleLine BDS_META{..} = BDS_META NO_EOL TAB' meta (toSingleLine bindings) toSingleLine bds = bdsinstance ToSingleLine PAIR where toSingleLine PA_TAU{..} = PA_TAU attr arrow (toSingleLine expr) toSingleLine PA_FORMATION{..} = PA_FORMATION attr voids arrow (toSingleLine expr) toSingleLine pair = pairinstance ToSingleLine APP_ARG where toSingleLine APP_ARG{..} = APP_ARG (toSingleLine expr) (toSingleLine args)instance ToSingleLine APP_ARGS where toSingleLine AAS_EXPR{..} = AAS_EXPR NO_EOL TAB' (toSingleLine expr) (toSingleLine args) toSingleLine args = args