hnix-0.5.2: Haskell implementation of the Nix language

Safe HaskellNone
LanguageHaskell2010

Nix.Pretty

Synopsis

Documentation

data NixDoc Source #

This type represents a pretty printed nix expression together with some information about the expression.

Constructors

NixDoc 

Fields

  • withoutParens :: Doc

    The rendered expression, without any parentheses.

  • rootOp :: OperatorInfo

    The root operator is the operator at the root of the expression tree. For example, in '(a * b) + c', + would be the root operator. It is needed to determine if we need to wrap the expression in parentheses.

  • wasPath :: Bool
     

simpleExpr :: Doc -> NixDoc Source #

A simple expression is never wrapped in parentheses. The expression behaves as if its root operator had a precedence higher than all other operators (including function application).

leastPrecedence :: Doc -> NixDoc Source #

An expression that behaves as if its root operator had a precedence lower than all other operators. That ensures that the expression is wrapped in parantheses in almost always, but it's still rendered without parentheses in cases where parentheses are never required (such as in the LHS of a binding).

dethunk :: MonadVar m => NThunk m -> m (NValueNF m) Source #