definition: |
multiGroup :: Tokens -> Width -> Position -> EndPosition -> OutGroupPrefix -> Q.Queue (StartPosition, OutGroupPrefix) -> StartPosition -> OutGroupPrefix -> Out multiGroup EOD _ _ _ _ _ _ _ = error "Pretty.multiGroup: EOD" -- should not occur: multiGroup (Empty ts) w p e outGrpPreOuter qs s outGrpPreInner = multiGroup ts w p e outGrpPreOuter qs s outGrpPreInner multiGroup (Text t ts) w p e outGrpPreOuter qs s outGrpPreInner = pruneMulti ts w (p+l) e outGrpPreOuter qs s (\h cont -> outGrpPreInner h (outText cont)) where l = lengthVis t outText cont r ms fs = t ++ cont (r-l) ms fs multiGroup (LineBreak Nothing ts) w p _ outGrpPreOuter qs _ outGrpPreInner = pruneAll outGrpPreOuter qs where pruneAll outGrpPreOuter' qs' = outGrpPreOuter' False (\r -> (case Q.matchLast qs' of Nothing -> outGrpPreInner False (outLine (noGroup ts w p)) Just ((_,outGrpPre),qss) -> pruneAll outGrpPre qss) r) outLine _ _ [] _ = error "Pretty.oneGroup.outLine: empty margins" outLine cont _ ms@(m:_) fs = '\n' : addSpaces m ts ++ cont (w - m) ms fs multiGroup (LineBreak (Just s) ts) w p e outGrpPreOuter qs si outGrpPreInner = pruneMulti ts w (p + l) e outGrpPreOuter qs si (\h cont -> outGrpPreInner h (outLine h cont)) where l = lengthVis s outLine _ _ _ [] _ = error "Pretty.multiGroup.outLine: empty margins" outLine h cont r ms@(m:_) fs = if h then s ++ cont (r-l) ms fs else '\n': addSpaces m ts ++ cont (w-m) ms fs multiGroup (OpenGroup ts) w p e outGrpPreOuter qs si outGrpPreInner = multiGroup ts w p e outGrpPreOuter (Q.cons (si,outGrpPreInner) qs) p (\_ cont -> cont) multiGroup (CloseGroup ts) w p e outGrpPreOuter qs si outGrpPreInner = case Q.matchHead qs of Nothing -> oneGroup ts w p e (\h cont -> outGrpPreOuter h (\ri -> outGrpPreInner (p<=si+ri) cont ri)) Just ((s,outGrpPre),qs') -> multiGroup ts w p e outGrpPreOuter qs' s (\h cont -> outGrpPre h (\ri -> outGrpPreInner (p<=si+ri) cont ri)) multiGroup (OpenNest n ts) w p e outGrpPreOuter qs si outGrpPreInner = multiGroup ts w p e outGrpPreOuter qs si (\h cont -> outGrpPreInner h (\r ms fs -> cont r (applyNesting n w r ms) fs)) multiGroup (CloseNest ts) w p e outGrpPreOuter qs si outGrpPreInner = multiGroup ts w p e outGrpPreOuter qs si (\h cont -> outGrpPreInner h (\r ms fs -> cont r (unApplyNesting ms) fs)) multiGroup (OpenFormat f ts) w p e outGrpPreOuter qs si outGrpPreInner = multiGroup ts w p e outGrpPreOuter qs si (\h cont -> outGrpPreInner h (outFormat cont)) where outFormat cont r ms fs = applyFormat f ++ cont r ms (f:fs) multiGroup (CloseFormat ts) w p e outGrpPreOuter qs si outGrpPreInner = multiGroup ts w p e outGrpPreOuter qs si (\h cont -> outGrpPreInner h (outUnformat cont)) where outUnformat cont r ms fs = applyFormat f ++ cont r ms ofs where (f, ofs) = resetFormat fs |
demand: |
argument 1 |
deterministic: |
deterministic operation |
documentation: |
-- multiGroup is used when there are at least two deferred groups -- Whenever the tokens `Text` or `LineBreak` are processed, i.e. the current position -- is increased, pruneMulti checks whether whether the outermost group still -- fits the line. -- Furthermore the `group output function` of the innermost group is extended -- with the current token. -- When we come across a `OpenGroup` token during traversal of the token sequence, -- the current innermost `group output function` is added to the queue. -- Reaching a `CloseGroup` token it is checked whether the queue still contains a -- deferred `group output function`: If the queue is empty, there is only one -- group left, otherwise there are at least two groups left. -- In both cases the function for the innermost group is merged with the -- function for the next inner group |
failfree: |
(_, _, _, _, _, _, _, _) |
indeterministic: |
referentially transparent operation |
infix: |
no fixity defined |
iotype: |
{({Empty},_,_,_,_,_,_,_) |-> _ || ({Text},_,_,_,_,_,_,_) |-> _ || ({LineBreak},_,_,_,_,_,_,_) |-> _ || ({OpenGroup},_,_,_,_,_,_,_) |-> _ || ({CloseGroup},_,_,_,_,_,_,_) |-> _ || ({OpenNest},_,_,_,_,_,_,_) |-> _ || ({CloseNest},_,_,_,_,_,_,_) |-> _ || ({OpenFormat},_,_,_,_,_,_,_) |-> _ || ({CloseFormat},_,_,_,_,_,_,_) |-> _} |
name: |
multiGroup |
precedence: |
no precedence defined |
result-values: |
_ |
signature: |
Tokens -> Prelude.Int -> Prelude.Int -> Prelude.Int -> (Prelude.Bool -> (Prelude.Int -> [Prelude.Int] -> [FormatStm] -> String) -> Prelude.Int -> [Prelude.Int] -> [FormatStm] -> String) -> Data.Queue.Queue (Prelude.Int, Prelude.Bool -> (Prelude.Int -> [Prelude.Int] -> [FormatStm] -> String) -> Prelude.Int -> [Prelude.Int] -> [FormatStm] -> String) -> Prelude.Int -> (Prelude.Bool -> (Prelude.Int -> [Prelude.Int] -> [FormatStm] -> String) -> Prelude.Int -> [Prelude.Int] -> [FormatStm] -> String) -> Prelude.Int -> [Prelude.Int] -> [FormatStm] -> String |
solution-complete: |
operation might suspend on free variables |
terminating: |
possibly non-terminating |
totally-defined: |
possibly non-reducible on same data term |