hnix-0.10.1: Haskell implementation of the Nix language
Safe HaskellNone
LanguageHaskell2010

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 

Fields

  • withoutParens :: Doc ann

    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 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.

Orphan instances

(HasCitations1 m v f, HasCitations m v t) => HasCitations m v (NValue t f m) Source # 
Instance details

Methods

citations :: NValue t f m -> [Provenance m v] Source #

addProvenance :: Provenance m v -> NValue t f m -> NValue t f m Source #

HasCitations1 m v f => HasCitations m v (NValue' t f m a) Source # 
Instance details

Methods

citations :: NValue' t f m a -> [Provenance m v] Source #

addProvenance :: Provenance m v -> NValue' t f m a -> NValue' t f m a Source #