lue-bird/elm-syntax-format/1.1.11

NOTE: the latest version is 1.1.20

ElmSyntaxPrint

Pretty printing an elm-syntax tree in a way consistent with elm-format.

toString : Print -> String

All other helpers in this module produce a Print which you can in the end convert to a String with toString

type alias Print =
{ indent : Int } -> String

Pretty printable intermediate representation. See toString

module_ : File -> Print

That's all you'll need most of the time.

Sometimes it's useful to print only some part of the syntax, to, say, display only an expression in an article or reformat only the touched declarations on save.

{ atDocsLines : List (List String)
, comments : List (Node String)
}
-> Module
-> Print

Print an Elm.Syntax.Module.Module (confusingly, that's their name for only the module X exposing (Y) lines)

{ atDocsLines : List (List String)
, comments : List (Node String)
}
-> Node Exposing
-> Print

Print the stuff after exposing in a module header. For import exposing: importExposing

expose : TopLevelExpose -> Print
imports : List (Node String) -> List (Node Import) -> Print

Print a set of Elm.Syntax.Import.Imports

import_ : List (Node String) -> Node Import -> Print
importExposing : List (Node String) -> Node Exposing -> Print

Print the stuff after exposing in an import. For module header exposing: moduleExposing

moduleLevelComments : List String -> Print

Print -- or {- -} comments placed outside of declarations at the top level. For comments within a declaration: comments

comments : List String -> Print

Print -- or {- -} comments placed within a declaration. For top-level comments: moduleLevelComments

comment : String -> Print

Print a single -- or {- -} comment.

{ portDocumentationComments : List (Node String)
, comments : List (Node String)
, previousEnd : Location
}
-> List (Node Declaration)
-> Print

Print a list of Elm.Syntax.Declaration.Declarations and comments in between

{ portDocumentationComment : Maybe (Node String)
, comments : List (Node String)
}
-> Declaration
-> Print
declarationChoiceType : List (Node String) -> Type -> Print

Print an Elm.Syntax.Type.Type declaration

declarationSignature : List (Node String) -> Signature -> Print

Print an Elm.Syntax.Signature.Signature as name : Type

declarationExpression : List (Node String) -> Function -> Print

Print an Elm.Syntax.Expression.Function declaration

declarationInfix : Infix -> Print

Print an Elm.Syntax.Infix.Infix declaration

{ documentationComment : Maybe (Node String)
, comments : List (Node String)
}
-> Signature
-> Print
declarationTypeAlias : List (Node String) -> TypeAlias -> Print

Print an Elm.Syntax.TypeAlias.TypeAlias declaration

expressionNotParenthesized : List (Node String) -> Node Expression -> Print
case_ : List (Node String) -> Case -> Print
patternNotParenthesized : List (Node String) -> Node Pattern -> Print
typeNotParenthesized : List (Node String) -> Node TypeAnnotation -> Print
moduleName : ModuleName -> Print
{ qualification : List String
, unqualified : String
}
-> Print

Print a name with its qualification ([] for no qualification)

If you need other syntax printing like for collapsible comments to be exposed, open an issue