ormolu-0.0.4.0: A formatter for Haskell source code

Safe HaskellNone
LanguageHaskell2010

Ormolu.Printer.Operators

Description

This module helps handle operator chains composed of different operators that may have different precedence and fixities.

Synopsis

Documentation

data OpTree ty op Source #

Intermediate representation of operator trees. It has two type parameters: ty is the type of sub-expressions, while op is the type of operators.

Constructors

OpNode ty 
OpBranch (OpTree ty op) op (OpTree ty op) 

opTreeLoc :: OpTree (Located a) b -> SrcSpan Source #

Return combined SrcSpans of all elements in this OpTree.

reassociateOpTree Source #

Arguments

:: (op -> Maybe RdrName)

How to get name of an operator

-> OpTree (Located ty) (Located op)

Original OpTree

-> OpTree (Located ty) (Located op)

Re-associated OpTree

Re-associate an OpTree taking into account automagically inferred relative precedence of operators. Users are expected to first construct an initial OpTree, then re-associate it using this function before printing.