hnix-0.13.1: Haskell implementation of the Nix language

Nix.Pretty

Synopsis

# Documentation

data NixDoc ann Source #

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

Constructors

 NixDoc FieldswithoutParens :: Doc annThe rendered expression, without any parentheses.rootOp :: OperatorInfoThe 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 ann -> NixDoc ann 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).

pathExpr :: Doc ann -> NixDoc ann Source #

leastPrecedence :: Doc ann -> NixDoc ann 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 parentheses 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).

prettyOriginExpr :: forall t f m ann. HasCitations1 m (NValue t f m) f => NExprLocF (Maybe (NValue t f m)) -> Doc ann Source #

valueToExpr :: forall t f m. MonadDataContext f m => NValue t f m -> NExpr Source #

prettyNValue :: forall t f m ann. MonadDataContext f m => NValue t f m -> Doc ann Source #

prettyNValueProv :: forall t f m ann. (HasCitations m (NValue t f m) t, HasCitations1 m (NValue t f m) f, MonadThunk t m (NValue t f m), MonadDataContext f m) => NValue t f m -> Doc ann Source #

prettyNThunk :: forall t f m ann. (HasCitations m (NValue t f m) t, HasCitations1 m (NValue t f m) f, MonadThunk t m (NValue t f m), MonadDataContext f m) => t -> m (Doc ann) Source #

printNix :: forall t f m. MonadDataContext f m => NValue t f m -> String Source #

This function is used only by the testing code.