Header menu logo fantomas

Context Module

Types

Type Description

ColMultilineItem

Context

ShortExpressionInfo

Size

WriteModelMode

WriterEvent

WriterModel

Functions and values

Function or value Description

!-str

Full Usage: !-str

Parameters:
    str : string

Returns: Context -> Context
str : string
Returns: Context -> Context

(+>) ctx f x

Full Usage: (+>) ctx f x

Parameters:
Returns: Context

Function composition operator

ctx : Context -> Context
f : Context -> Context
x : Context
Returns: Context

addFixedSpaces targetColumn ctx

Full Usage: addFixedSpaces targetColumn ctx

Parameters:
Returns: Context
targetColumn : int
ctx : Context
Returns: Context

addParenIfAutoNln expr f

Full Usage: addParenIfAutoNln expr f

Parameters:
Returns: Context -> Context
expr : Expr
f : Expr -> Context -> Context
Returns: Context -> Context

addSpaceIfSpaceAfterComma ctx

Full Usage: addSpaceIfSpaceAfterComma ctx

Parameters:
Returns: Context
ctx : Context
Returns: Context

addSpaceIfSpaceAroundDelimiter ctx

Full Usage: addSpaceIfSpaceAroundDelimiter ctx

Parameters:
Returns: Context
ctx : Context
Returns: Context

atCurrentColumn f ctx

Full Usage: atCurrentColumn f ctx

Parameters:
Returns: Context

`atCurrentColumn` was called on `X`, then `indent` was called, but "some long string" have indent only 4, because it is bigger than `atColumn` (2).

f : Context -> Context
ctx : Context
Returns: Context

atCurrentColumnIndent f ctx

Full Usage: atCurrentColumnIndent f ctx

Parameters:
Returns: Context
 Write everything at current column indentation, set `indent` and `atColumn` on current column position
 /// Example (same as above):
 { X = // indent=2, atColumn=2
       "some long string" // indent=6, atColumn=2
   Y = 1 // indent=2, atColumn=2
 }
 `atCurrentColumn` was called on `X`, then `indent` was called, "some long string" have indent 6, because it is indented from `atCurrentColumn` pos (2).
f : Context -> Context
ctx : Context
Returns: Context

atIndentLevel alsoSetIndent level f ctx

Full Usage: atIndentLevel alsoSetIndent level f ctx

Parameters:
Returns: Context
alsoSetIndent : bool
level : int
f : Context -> Context
ctx : Context
Returns: Context

autoIndentAndNlnIfExpressionExceedsPageWidth expr ctx

Full Usage: autoIndentAndNlnIfExpressionExceedsPageWidth expr ctx

Parameters:
Returns: Context

try and write the expression on the remainder of the current line add an indent and newline if the expression is longer

expr : Context -> Context
ctx : Context
Returns: Context

autoIndentAndNlnIfExpressionExceedsPageWidthUnlessStroustrup f e ctx

Full Usage: autoIndentAndNlnIfExpressionExceedsPageWidthUnlessStroustrup f e ctx

Parameters:
Returns: Context
f : Expr -> Context -> Context
e : Expr
ctx : Context
Returns: Context

autoIndentAndNlnTypeUnlessStroustrup f t ctx

Full Usage: autoIndentAndNlnTypeUnlessStroustrup f t ctx

Parameters:
Returns: Context
f : Type -> Context -> Context
t : Type
ctx : Context
Returns: Context

autoIndentAndNlnWhenWriteBeforeNewlineNotEmpty f ctx

Full Usage: autoIndentAndNlnWhenWriteBeforeNewlineNotEmpty f ctx

Parameters:
Returns: Context
f : Context -> Context
ctx : Context
Returns: Context

autoParenthesisIfExpressionExceedsPageWidth expr ctx

Full Usage: autoParenthesisIfExpressionExceedsPageWidth expr ctx

Parameters:
Returns: Context
expr : Context -> Context
ctx : Context
Returns: Context

col f' c f ctx

Full Usage: col f' c f ctx

Parameters:
Returns: Context

Process collection - keeps context through the whole processing calls f for every element in sequence and f' between every two elements as a separator. This is a variant that works on typed collections.

f' : Context -> Context
c : 'T seq
f : 'T -> Context -> Context
ctx : Context
Returns: Context

colAutoNlnSkip0 f' c f

Full Usage: colAutoNlnSkip0 f' c f

Parameters:
Returns: Context -> Context

Similar to col, skip auto newline for index 0

f' : Context -> Context
c : 'a seq
f : 'a -> Context -> Context
Returns: Context -> Context

colEx f' c f ctx

Full Usage: colEx f' c f ctx

Parameters:
Returns: Context
f' : 'T -> Context -> Context
c : 'T seq
f : 'T -> Context -> Context
ctx : Context
Returns: Context

colPost f2 f1 c f ctx

Full Usage: colPost f2 f1 c f ctx

Parameters:
Returns: Context

Similar to col, apply one more function f2 at the end if the input sequence is not empty

f2 : Context -> Context
f1 : Context -> Context
c : 'T seq
f : 'T -> Context -> Context
ctx : Context
Returns: Context

colPre f2 f1 c f ctx

Full Usage: colPre f2 f1 c f ctx

Parameters:
Returns: Context

Similar to col, apply one more function f2 at the beginning if the input sequence is not empty

f2 : Context -> Context
f1 : Context -> Context
c : 'T seq
f : 'T -> Context -> Context
ctx : Context
Returns: Context

colWithNlnWhenItemIsMultiline items ctx

Full Usage: colWithNlnWhenItemIsMultiline items ctx

Parameters:
Returns: Context
 This helper function takes a list of expressions and ranges.
 If the expression is multiline it will add a newline before and after the expression.
 Unless it is the first expression in the list, that will never have a leading new line.
 F.ex.
 let a = AAAA
 let b =
     BBBB
     BBBB
 let c = CCCC

 will be formatted as:
 let a = AAAA

 let b =
     BBBB
     BBBBB

 let c = CCCC
items : ColMultilineItem list
ctx : Context
Returns: Context

colWithNlnWhenItemIsMultilineUsingConfig items ctx

Full Usage: colWithNlnWhenItemIsMultilineUsingConfig items ctx

Parameters:
Returns: Context
items : ColMultilineItem list
ctx : Context
Returns: Context

coli f' c f ctx

Full Usage: coli f' c f ctx

Parameters:
Returns: Context

Similar to col, and supply index as well

f' : Context -> Context
c : 'T seq
f : int -> 'T -> Context -> Context
ctx : Context
Returns: Context

dump isSelection ctx

Full Usage: dump isSelection ctx

Parameters:
Returns: FormatResult
isSelection : bool
ctx : Context
Returns: FormatResult

dumpAndContinue ctx

Full Usage: dumpAndContinue ctx

Parameters:
Returns: Context
ctx : Context
Returns: Context

exceedsWidth maxWidth f ctx

Full Usage: exceedsWidth maxWidth f ctx

Parameters:
Returns: bool

similar to futureNlnCheck but validates whether the expression is going over the max page width This functions is does not use any caching

maxWidth : int
f : Context -> Context
ctx : Context
Returns: bool

expressionFitsOnRestOfLine expression fallbackExpression ctx

Full Usage: expressionFitsOnRestOfLine expression fallbackExpression ctx

Parameters:
Returns: Context
expression : Context -> Context
fallbackExpression : Context -> Context
ctx : Context
Returns: Context

futureNlnCheck f ctx

Full Usage: futureNlnCheck f ctx

Parameters:
Returns: bool
f : Context -> Context
ctx : Context
Returns: bool

getListOrArrayExprSize ctx maxWidth xs

Full Usage: getListOrArrayExprSize ctx maxWidth xs

Parameters:
Returns: Size
ctx : Context
maxWidth : Num
xs : 'a list
Returns: Size

getRecordSize ctx fields

Full Usage: getRecordSize ctx fields

Parameters:
Returns: Size
ctx : Context
fields : 'a list
Returns: Size

hasWriteBeforeNewlineContent ctx

Full Usage: hasWriteBeforeNewlineContent ctx

Parameters:
Returns: bool
ctx : Context
Returns: bool

ifAlignOrStroustrupBrackets f g

Full Usage: ifAlignOrStroustrupBrackets f g

Parameters:
Returns: Context -> Context
f : Context -> Context
g : Context -> Context
Returns: Context -> Context

ifElse b f1 f2 ctx

Full Usage: ifElse b f1 f2 ctx

Parameters:
Returns: Context

b is true, apply f1 otherwise apply f2

b : bool
f1 : Context -> Context
f2 : Context -> Context
ctx : Context
Returns: Context

ifElseCtx cond f1 f2 ctx

Full Usage: ifElseCtx cond f1 f2 ctx

Parameters:
Returns: Context
cond : Context -> bool
f1 : Context -> Context
f2 : Context -> Context
ctx : Context
Returns: Context

indent ctx

Full Usage: indent ctx

Parameters:
Returns: Context

Indent one more level based on configuration

ctx : Context
Returns: Context

indentSepNlnUnindent f

Full Usage: indentSepNlnUnindent f

Parameters:
Returns: Context -> Context
f : Context -> Context
Returns: Context -> Context

indentSepNlnUnindentUnlessStroustrup f e ctx

Full Usage: indentSepNlnUnindentUnlessStroustrup f e ctx

Parameters:
Returns: Context
f : Expr -> Context -> Context
e : Expr
ctx : Context
Returns: Context

isShortExpression maxWidth shortExpression fallbackExpression ctx

Full Usage: isShortExpression maxWidth shortExpression fallbackExpression ctx

Parameters:
Returns: Context
maxWidth : int
shortExpression : Context -> Context
fallbackExpression : Context -> Context
ctx : Context
Returns: Context

isSmallExpression size smallExpression fallbackExpression ctx

Full Usage: isSmallExpression size smallExpression fallbackExpression ctx

Parameters:
Returns: Context
size : Size
smallExpression : Context -> Context
fallbackExpression : Context -> Context
ctx : Context
Returns: Context

isStroustrupStyleExpr config e

Full Usage: isStroustrupStyleExpr config e

Parameters:
Returns: bool
config : FormatConfig
e : Expr
Returns: bool

lastWriteEventIsNewline ctx

Full Usage: lastWriteEventIsNewline ctx

Parameters:
Returns: bool
ctx : Context
Returns: bool

leadingExpressionIsMultiline leadingExpression continuationExpression ctx

Full Usage: leadingExpressionIsMultiline leadingExpression continuationExpression ctx

Parameters:
Returns: 'a

A leading expression is not consider multiline if it has a comment before it. For example let a = 7 // foo let b = 8 let c = 9 The second binding b is not consider multiline.

leadingExpression : Context -> Context
continuationExpression : bool -> Context -> 'a
ctx : Context
Returns: 'a

leadingExpressionResult leadingExpression continuationExpression ctx

Full Usage: leadingExpressionResult leadingExpression continuationExpression ctx

Parameters:
Returns: 'a

provide the line and column before and after the leadingExpression to to the continuation expression

leadingExpression : Context -> Context
continuationExpression : (int * int) * (int * int) -> Context -> 'a
ctx : Context
Returns: 'a

onlyIf cond f ctx

Full Usage: onlyIf cond f ctx

Parameters:
    cond : bool
    f : 'a -> 'a
    ctx : 'a

Returns: 'a
cond : bool
f : 'a -> 'a
ctx : 'a
Returns: 'a

onlyIfCtx cond f ctx

Full Usage: onlyIfCtx cond f ctx

Parameters:
    cond : 'a -> bool
    f : 'a -> 'a
    ctx : 'a

Returns: 'a
cond : 'a -> bool
f : 'a -> 'a
ctx : 'a
Returns: 'a

onlyIfNot cond f ctx

Full Usage: onlyIfNot cond f ctx

Parameters:
    cond : bool
    f : 'a -> 'a
    ctx : 'a

Returns: 'a
cond : bool
f : 'a -> 'a
ctx : 'a
Returns: 'a

opt f' o f ctx

Full Usage: opt f' o f ctx

Parameters:
Returns: Context

If there is a value, apply f and f' accordingly, otherwise do nothing

f' : Context -> Context
o : 'a option
f : 'a -> Context -> Context
ctx : Context
Returns: Context

optPre f2 f1 o f ctx

Full Usage: optPre f2 f1 o f ctx

Parameters:
Returns: Context

Similar to opt, but apply f2 at the beginning if there is a value

f2 : Context -> Context
f1 : Context -> Context
o : 'a option
f : 'a -> Context -> Context
ctx : Context
Returns: Context

optSingle f o ctx

Full Usage: optSingle f o ctx

Parameters:
    f : 'a -> 'b -> 'b
    o : 'a option
    ctx : 'b

Returns: 'b

similar to opt, only takes a single function f to apply when there is a value

f : 'a -> 'b -> 'b
o : 'a option
ctx : 'b
Returns: 'b

rep n f ctx

Full Usage: rep n f ctx

Parameters:
Returns: Context

Repeat application of a function n times

n : int
f : Context -> Context
ctx : Context
Returns: Context

sepArrow

Full Usage: sepArrow

Returns: Context -> Context
Returns: Context -> Context

sepArrowRev

Full Usage: sepArrowRev

Returns: Context -> Context
Returns: Context -> Context

sepBar

Full Usage: sepBar

Returns: Context -> Context
Returns: Context -> Context

sepCloseLFixed

Full Usage: sepCloseLFixed

Returns: Context -> Context

closing token of list

Returns: Context -> Context

sepCloseT

Full Usage: sepCloseT

Returns: Context -> Context

closing token of tuple

Returns: Context -> Context

sepColon ctx

Full Usage: sepColon ctx

Parameters:
Returns: Context
ctx : Context
Returns: Context

sepColonFixed

Full Usage: sepColonFixed

Returns: Context -> Context
Returns: Context -> Context

sepColonWithSpacesFixed

Full Usage: sepColonWithSpacesFixed

Returns: Context -> Context
Returns: Context -> Context

sepComma ctx

Full Usage: sepComma ctx

Parameters:
Returns: Context
ctx : Context
Returns: Context

sepDot

Full Usage: sepDot

Returns: Context -> Context
Returns: Context -> Context

sepEq

Full Usage: sepEq

Returns: Context -> Context
Returns: Context -> Context

sepEqFixed

Full Usage: sepEqFixed

Returns: Context -> Context
Returns: Context -> Context

sepNln

Full Usage: sepNln

Returns: Context -> Context
Returns: Context -> Context

sepNlnForTrivia

Full Usage: sepNlnForTrivia

Returns: Context -> Context
Returns: Context -> Context

sepNlnUnlessLastEventIsNewline ctx

Full Usage: sepNlnUnlessLastEventIsNewline ctx

Parameters:
Returns: Context
ctx : Context
Returns: Context

sepNlnWhenWriteBeforeNewlineNotEmpty

Full Usage: sepNlnWhenWriteBeforeNewlineNotEmpty

Returns: Context -> Context
Returns: Context -> Context

sepNlnWhenWriteBeforeNewlineNotEmptyOr fallback ctx

Full Usage: sepNlnWhenWriteBeforeNewlineNotEmptyOr fallback ctx

Parameters:
Returns: Context
fallback : Context -> Context
ctx : Context
Returns: Context

sepNone

Full Usage: sepNone

Returns: 'a -> 'a
Returns: 'a -> 'a

sepOpenAnonRecdFixed

Full Usage: sepOpenAnonRecdFixed

Returns: Context -> Context

opening token of anon record

Returns: Context -> Context

sepOpenLFixed

Full Usage: sepOpenLFixed

Returns: Context -> Context

opening token of list

Returns: Context -> Context

sepOpenT

Full Usage: sepOpenT

Returns: Context -> Context

opening token of tuple

Returns: Context -> Context

sepSemi ctx

Full Usage: sepSemi ctx

Parameters:
Returns: Context
ctx : Context
Returns: Context

sepSpace ctx

Full Usage: sepSpace ctx

Parameters:
Returns: Context
ctx : Context
Returns: Context

sepSpaceBeforeClassConstructor ctx

Full Usage: sepSpaceBeforeClassConstructor ctx

Parameters:
Returns: Context
ctx : Context
Returns: Context

sepSpaceOrDoubleIndentAndNlnIfExpressionExceedsPageWidth expr ctx

Full Usage: sepSpaceOrDoubleIndentAndNlnIfExpressionExceedsPageWidth expr ctx

Parameters:
Returns: Context
expr : Context -> Context
ctx : Context
Returns: Context

sepSpaceOrIndentAndNlnIfExpressionExceedsPageWidth expr ctx

Full Usage: sepSpaceOrIndentAndNlnIfExpressionExceedsPageWidth expr ctx

Parameters:
Returns: Context
expr : Context -> Context
ctx : Context
Returns: Context

sepSpaceOrIndentAndNlnIfExpressionExceedsPageWidthUnlessStroustrup f expr ctx

Full Usage: sepSpaceOrIndentAndNlnIfExpressionExceedsPageWidthUnlessStroustrup f expr ctx

Parameters:
Returns: Context
f : Expr -> Context -> Context
expr : Expr
ctx : Context
Returns: Context

sepSpaceOrIndentAndNlnIfTypeExceedsPageWidthUnlessStroustrup f t ctx

Full Usage: sepSpaceOrIndentAndNlnIfTypeExceedsPageWidthUnlessStroustrup f t ctx

Parameters:
Returns: Context
f : Type -> Context -> Context
t : Type
ctx : Context
Returns: Context

sepSpaceUnlessWriteBeforeNewlineNotEmpty ctx

Full Usage: sepSpaceUnlessWriteBeforeNewlineNotEmpty ctx

Parameters:
Returns: Context
ctx : Context
Returns: Context

sepStar

Full Usage: sepStar

Returns: Context -> Context
Returns: Context -> Context

unindent ctx

Full Usage: unindent ctx

Parameters:
Returns: Context

Unindent one more level based on configuration

ctx : Context
Returns: Context

whenShortIndent f ctx

Full Usage: whenShortIndent f ctx

Parameters:
Returns: Context
f : Context -> Context
ctx : Context
Returns: Context

wordAnd

Full Usage: wordAnd

Returns: Context -> Context
Returns: Context -> Context

wordAndFixed

Full Usage: wordAndFixed

Returns: Context -> Context
Returns: Context -> Context

wordOf

Full Usage: wordOf

Returns: Context -> Context
Returns: Context -> Context

writerEvent e ctx

Full Usage: writerEvent e ctx

Parameters:
Returns: Context

This adds a WriterEvent to the Context. One event could potentially be split up into multiple events. The event is also being processed in the WriterModel of the Context.

e : WriterEvent
ctx : Context
Returns: Context

Type something to start searching.