├── .envrc ├── cabal.config ├── package ├── nix │ └── .gitignore ├── elm-tooling │ ├── .gitignore │ ├── generate.sh │ └── build.sh ├── npm │ ├── .gitignore │ ├── README.md │ ├── default.nix │ ├── .eslintrc.json │ ├── index.js │ ├── bin │ │ └── elm-format │ ├── shell.nix │ ├── platform-info.nix │ ├── package.json │ └── elm-format-0.8.5-test.nix ├── win │ ├── .gitignore │ ├── links.txt │ ├── shell │ │ ├── main.cmd │ │ ├── InstallChocolatey.ps1 │ │ └── InstallPackages.bat │ ├── build-package.sh │ ├── Vagrantfile │ ├── wine.sh │ └── setup.md ├── linux │ ├── archlinux │ │ ├── Vagrantfile │ │ └── .gitignore │ ├── build-package.sh │ └── build-in-docker.sh └── mac │ └── build-package.sh ├── tests ├── test-files │ ├── validate2.json │ ├── transform │ │ ├── Elm-0.18 │ │ │ ├── Empty.elm │ │ │ ├── TrickyModule1.elm │ │ │ ├── TrickyModule3.elm │ │ │ ├── TrickyModule4.elm │ │ │ ├── TrickyModule2.elm │ │ │ ├── Empty.formatted.elm │ │ │ ├── TrickyModule1.formatted.elm │ │ │ ├── TrickyModule2.formatted.elm │ │ │ ├── TrickyModule4.formatted.elm │ │ │ ├── TrickyModule3.formatted.elm │ │ │ ├── LenientEqualsColon.elm │ │ │ ├── QuickCheck-94f37da84c1310f03dcfa1059ce870b73c94a825--6449652945938213463.elm │ │ │ ├── LenientEqualsColon.formatted.elm │ │ │ ├── QuickCheck-4562ebccb71ea9f622fb99cdf32b2923f6f9d34f-2529668492575674138.elm │ │ │ ├── AllSyntax │ │ │ │ ├── Types.formatted.elm │ │ │ │ ├── Types.elm │ │ │ │ ├── Patterns.formatted.elm │ │ │ │ └── Patterns.elm │ │ │ ├── Examples.elm │ │ │ ├── QuickCheck-94f37da84c1310f03dcfa1059ce870b73c94a825--6449652945938213463.formatted.elm │ │ │ ├── QuickCheck-4562ebccb71ea9f622fb99cdf32b2923f6f9d34f-2529668492575674138.formatted.elm │ │ │ ├── DocCommentCheapskateReferenceBug.elm │ │ │ ├── DocCommentCheapskateReferenceBug.formatted.elm │ │ │ ├── WindowsEol.elm │ │ │ ├── WindowsEol.formatted.elm │ │ │ ├── MissingImportParens.formatted.elm │ │ │ ├── DocCommentAtDocs.elm │ │ │ ├── MissingImportParens.elm │ │ │ ├── DocCommentCodeExample.elm │ │ │ ├── DocCommentAtDocs.formatted.elm │ │ │ ├── DocCommentCodeExample.formatted.elm │ │ │ ├── Examples.formatted.elm │ │ │ ├── DocCommentMarkdownSafety.elm │ │ │ ├── DocCommentMarkdownSafety.formatted.elm │ │ │ ├── Sorting.formatted.elm │ │ │ ├── Sorting.elm │ │ │ └── UnnecessaryParens.formatted.elm │ │ ├── Elm-0.19 │ │ │ ├── AddMissingExposingForImport.elm │ │ │ ├── TransformFatArrow.elm │ │ │ ├── ClarifyNegativeExponentiationPrecedence.elm │ │ │ ├── ParseTabsInLiterals.elm │ │ │ ├── AddMissingExposingForModule.elm │ │ │ ├── DistinguishCharStartFromRef.elm │ │ │ ├── AddMissingExposingForImport.formatted.elm │ │ │ ├── AddMissingExposingForModule.formatted.elm │ │ │ ├── ListAllExportsNoModuleLine.elm │ │ │ ├── ReplaceThenByOfInCase.elm │ │ │ ├── TransformFatArrow.formatted.elm │ │ │ ├── ListAllExportsNoExposing.elm │ │ │ ├── DistinguishCharStartFromRef.formatted.elm │ │ │ ├── ClarifyNegativeExponentiationPrecedence.formatted.elm │ │ │ ├── ExplicitlyListExposedValues.elm │ │ │ ├── ParseTabsInLiterals.formatted.elm │ │ │ ├── ExplicitlyListExposedValues.formatted.elm │ │ │ ├── ListDocumentedExportsNoExposing.elm │ │ │ ├── ReplaceThenByOfInCase.formatted.elm │ │ │ ├── ListAllExportsNoModuleLine.formatted.elm │ │ │ ├── ListAllExportsNoExposing.formatted.elm │ │ │ └── ListDocumentedExportsNoExposing.formatted.elm │ │ └── Elm-0.16 │ │ │ ├── github-avh4-elm-format-184.elm │ │ │ └── github-avh4-elm-format-184.formatted.elm │ ├── CommonMark │ │ ├── .gitignore │ │ ├── tools │ │ │ ├── template.commonmark │ │ │ └── spec2js.js │ │ ├── .editorconfig │ │ ├── package.json │ │ ├── RELEASE_CHECKLIST.md │ │ ├── Makefile │ │ └── index.js │ ├── directory │ │ ├── valid.elm │ │ └── invalid.elm │ ├── recursive-directory │ │ ├── nested │ │ │ └── invalid.elm │ │ └── valid.elm │ ├── from-json │ │ └── Elm-0.19 │ │ │ ├── Simple.elm │ │ │ ├── ModuleComments.elm │ │ │ ├── Simple.json │ │ │ ├── ModuleImports.elm │ │ │ ├── ModuleComments.json │ │ │ ├── Patterns.elm │ │ │ ├── Declarations.elm │ │ │ ├── Types.elm │ │ │ └── ModuleImports.json │ ├── bad │ │ └── Elm-0.19 │ │ │ ├── UnexpectedEndOfInput.elm │ │ │ ├── UnexpectedComma.elm │ │ │ ├── UnexpectedComma.output.txt │ │ │ └── UnexpectedEndOfInput.output.txt │ ├── good │ │ ├── Elm-0.18 │ │ │ ├── Simple.elm │ │ │ ├── Export.elm │ │ │ ├── ApiSketch.elm │ │ │ ├── AllSyntax │ │ │ │ ├── DocCommentsStartingWtihAtDocs.elm │ │ │ │ ├── ModuleMultiline.elm │ │ │ │ ├── Expressions │ │ │ │ │ ├── Unary.elm │ │ │ │ │ └── BinaryOperators.elm │ │ │ │ ├── OldKeywords.elm │ │ │ │ ├── GLShader.elm │ │ │ │ ├── Comments.elm │ │ │ │ ├── BlockComments │ │ │ │ │ ├── Types.elm │ │ │ │ │ ├── Module.elm │ │ │ │ │ └── Patterns.elm │ │ │ │ ├── DeclaraionSpacing.elm │ │ │ │ ├── Module.elm │ │ │ │ ├── LineComments │ │ │ │ │ └── Types.elm │ │ │ │ └── ModuleWithDocs.elm │ │ │ ├── TopLevelSpacing.elm │ │ │ ├── WorkaroundNegativeCasePatterns.elm │ │ │ └── TrueFalseInIdentifiers.elm │ │ ├── Elm-0.17 │ │ │ ├── AllSyntax │ │ │ │ ├── Module.elm │ │ │ │ ├── Range.elm │ │ │ │ ├── BlockComments │ │ │ │ │ ├── Module.elm │ │ │ │ │ └── ModuleEffect.elm │ │ │ │ ├── ModuleEffect.elm │ │ │ │ ├── InfixOperators.elm │ │ │ │ ├── LineComments │ │ │ │ │ ├── Module.elm │ │ │ │ │ └── ModuleEffect.elm │ │ │ │ └── OldKeywords.elm │ │ │ ├── Export.elm │ │ │ ├── TopLevelSpacing.elm │ │ │ └── WorkaroundNegativeCasePatterns.elm │ │ ├── Elm-0.19 │ │ │ ├── TopLevelSpacing.elm │ │ │ ├── GLShader.elm │ │ │ ├── WorkaroundNegativeCasePatterns.elm │ │ │ ├── InfixAsVariableName.elm │ │ │ ├── GLShader.json-roundtrip │ │ │ └── AllSyntax │ │ │ │ ├── InfixDeclaration.elm │ │ │ │ ├── Module.json-roundtrip │ │ │ │ └── Module.elm │ │ ├── json │ │ │ ├── ExternalReferences.elm │ │ │ └── ExternalReferences.json-roundtrip │ │ └── Elm-0.16 │ │ │ └── AllSyntax │ │ │ └── PatternsRequireParens.elm │ └── validate1.json ├── Integration │ └── data │ │ └── minimal.elm ├── stdin-error.stderr │ └── golden ├── json-format-schema.json ├── Test.hs └── usage.stdout │ └── golden ├── parser ├── tests │ └── test-files │ │ ├── bad │ │ ├── BBTArgs │ │ ├── InfiniteType.elm │ │ ├── NonElementMain.elm │ │ ├── Strings │ │ │ └── ExtraClose.elm │ │ └── IncompletePatternMatch.elm │ │ └── good │ │ ├── Lists │ │ ├── EmptyList.elm │ │ ├── ListRange.elm │ │ └── NonEmptyList.elm │ │ ├── Soundness │ │ ├── TrickyId.elm │ │ ├── Id.elm │ │ ├── Apply.elm │ │ ├── TrickyIdAnnotated.elm │ │ ├── IdAnnotated.elm │ │ └── ApplyAnnotated.elm │ │ ├── Strings │ │ ├── Multiline.elm │ │ └── MultilineNormal.elm │ │ ├── NoExpressions.elm │ │ ├── Otherwise.elm │ │ ├── Unify │ │ └── NonHomogeneousRecords.elm │ │ ├── TailRecursive.elm │ │ ├── PortsWithTypeAliases.elm │ │ ├── QuotesAndComments.elm │ │ ├── AliasSubstitution.elm │ │ ├── CaseExpression3.elm │ │ └── Ports.elm └── bench │ ├── elm-package.json │ └── src │ ├── SmallTupleBench.elm │ ├── LargeDictionary.elm │ ├── TupleBench.elm │ └── SmallRecordBench.elm ├── .hlint.yaml ├── Style Guide ├── .gitignore ├── styles │ └── website.css ├── book.json ├── Upgrading.md ├── SUMMARY.md ├── Declarations.md ├── Sections.md └── Lists.md ├── elm-format-markdown ├── tests │ ├── Emphasis │ │ ├── Escapes.markdown │ │ ├── Escapes.html │ │ ├── Punctuation.markdown │ │ ├── Punctuation.html │ │ ├── Pathological.markdown │ │ └── Pathological.html │ ├── Blockquotes │ │ ├── Indents.markdown~ │ │ ├── Indents.markdown │ │ ├── Indents.html │ │ ├── Nesting.markdown │ │ ├── Separation.markdown │ │ ├── Nesting.html │ │ └── Separation.html │ ├── Lists │ │ ├── TightLooseMore.markdown │ │ ├── ListsAndHRs.markdown │ │ ├── ListsAndSetextHeaders.markdown │ │ ├── EmptyListItem.markdown │ │ ├── ListsAndHRs.html │ │ ├── ListsAndSetextHeaders.html │ │ ├── TightLooseMore.html │ │ ├── Indents.markdown │ │ ├── ConsecutiveLists.markdown │ │ ├── InBlockquote.markdown │ │ ├── EmptyListItem.html │ │ ├── Start.markdown │ │ ├── TwoBlankLinesEndList.markdown │ │ ├── CodeBlocksInLists.markdown │ │ ├── Indents.html │ │ ├── Start.html │ │ ├── CodeBlocksInLists.html │ │ ├── ConsecutiveLists.html │ │ ├── Sublists.markdown │ │ ├── TwoBlankLinesEndList.html │ │ ├── TightLooseBlockquote.markdown │ │ ├── InBlockquote.html │ │ ├── MultipleBlankLines.markdown │ │ ├── TightAndLoose.markdown │ │ ├── TightLooseBlockquote.html │ │ ├── Sublists.html │ │ ├── TightAndLoose.html │ │ └── MultipleBlankLines.html │ ├── Links │ │ ├── BackticksInLinks.markdown │ │ ├── CaseInsensitiveReferences.html │ │ ├── CaseInsensitiveReferences.markdown │ │ ├── BackticksInLinks.html │ │ ├── Entities.markdown │ │ ├── Entities.html │ │ ├── AngleBrackets.markdown │ │ ├── AngleBrackets.html │ │ ├── AutoLinks.markdown │ │ ├── ReferenceLinks.markdown │ │ ├── ReferenceLinks.html │ │ ├── InlineLinks.markdown │ │ ├── InlineLinks.html │ │ ├── ParensInURLs.markdown │ │ ├── AutoLinks.html │ │ └── ParensInURLs.html │ ├── Original │ │ ├── Nested_blockquotes.markdown │ │ ├── Tidyness.markdown │ │ ├── Nested_blockquotes.html │ │ ├── Strong_and_em_together.markdown │ │ ├── Literal_quotes_in_titles.markdown │ │ ├── Tidyness.html │ │ ├── Code_Spans.markdown │ │ ├── Literal_quotes_in_titles.html │ │ ├── Blockquotes_with_code_blocks.markdown │ │ ├── Inline_HTML_comments.html │ │ ├── Strong_and_em_together.html │ │ ├── Code_Spans.html │ │ ├── Inline_HTML_comments.markdown │ │ ├── Code_Blocks.markdown │ │ ├── Blockquotes_with_code_blocks.html │ │ ├── Links_shortcut_references.html │ │ ├── Auto_links.markdown │ │ ├── Links_shortcut_references.markdown │ │ ├── Code_Blocks.html │ │ ├── Tabs.markdown │ │ ├── Inline_HTML_Advanced.html │ │ ├── Inline_HTML_Advanced.markdown │ │ ├── Amps_and_angle_encoding.markdown │ │ ├── Tabs.html │ │ ├── Images.markdown │ │ ├── Amps_and_angle_encoding.html │ │ ├── Horizontal_rules.html │ │ ├── Auto_links.html │ │ ├── Horizontal_rules.markdown │ │ ├── README │ │ ├── Links_inline_style.markdown │ │ ├── Images.html │ │ ├── Links_inline_style.html │ │ ├── Inline_HTML_Simple.markdown │ │ ├── Inline_HTML_Simple.html │ │ ├── Links_reference_style.markdown │ │ └── Links_reference_style.html │ ├── Tabs │ │ ├── TabConversionUnicode.markdown │ │ └── TabConversionUnicode.html │ ├── Code │ │ ├── WhiteLines.html │ │ ├── FenceMatching.markdown │ │ ├── WhiteLines.markdown │ │ ├── FenceMatching.html │ │ ├── BlankLinesAtEnd.markdown │ │ ├── Inline.markdown │ │ ├── BlankLinesAtEnd.html │ │ ├── IndentedInLists.markdown │ │ ├── IndentedFences.markdown │ │ ├── BlankLines.markdown │ │ ├── ListBreakAfter.markdown │ │ ├── IndentedFences.html │ │ ├── Inline.html │ │ ├── BlankLines.html │ │ ├── IndentedCodeBlocks.markdown │ │ ├── IndentedInLists.html │ │ ├── ListBreakAfter.html │ │ ├── IndentedCodeBlocks.html │ │ ├── FencedCodeBlocks.markdown │ │ └── FencedCodeBlocks.html │ ├── HTML │ │ ├── UppercaseTags.markdown │ │ ├── UppercaseTags.html │ │ ├── Inline.markdown │ │ ├── Inline.html │ │ ├── Blocks.html │ │ └── Blocks.markdown │ ├── Headers │ │ ├── Setext.html │ │ ├── Setext.markdown │ │ ├── ATX.markdown │ │ └── ATX.html │ └── Misc │ │ ├── Laziness.markdown │ │ ├── Transitions.markdown │ │ ├── BackslashEscapes.markdown │ │ ├── Laziness.html │ │ ├── LineBreaks.html │ │ ├── BackslashEscapes.html │ │ ├── Transitions.html │ │ └── LineBreaks.markdown └── package.yaml ├── avh4-lib ├── test │ ├── Tests.hs │ └── Data │ │ ├── Text │ │ └── ExtraTest.hs │ │ └── List │ │ └── ExtraTest.hs └── src │ └── Data │ ├── Coapplicative.hs │ ├── Either │ └── Extra.hs │ ├── ReversedList.hs │ ├── List │ └── Extra.hs │ └── Text │ └── Extra.hs ├── elm-format-lib ├── test │ ├── Tests.hs │ └── Parse │ │ └── TestHelpersTest.hs └── src │ ├── Parse │ ├── IParser.hs │ ├── Markdown.hs │ ├── Comments.hs │ └── State.hs │ ├── ElmFormat │ ├── AST │ │ ├── PublicAST │ │ │ ├── Config.hs │ │ │ └── MaybeF.hs │ │ └── PublicAST.hs │ ├── Render │ │ └── Text.hs │ └── KnownContents.hs │ ├── Reporting │ └── Error │ │ └── Docs.hs │ └── AST │ └── Helpers.hs ├── elm-format-test-lib ├── test │ └── Tests.hs └── src │ └── Expect.hs ├── keys └── github-actions.pub ├── cabal.project ├── .dockerignore ├── Release Notes ├── 0.5.1-alpha.md ├── 0.5.2-alpha.md ├── 0.3.1-alpha.md ├── 0.5.0-alpha.md ├── 0.8.3.md ├── 0.3.0-alpha-elm017rc1-rc1.md ├── 0.8.5.md ├── 0.6.1-alpha.md ├── 0.8.4.md ├── 0.8.1.md └── 0.8.7.md ├── src ├── Main.hs └── ElmFormat │ └── Version.hs ├── .github ├── actions │ ├── git-tags │ │ └── action.yml │ ├── cache-haskell-deps │ │ └── action.yml │ └── cache-build │ │ └── action.yml └── workflows │ ├── Touch cache.yml │ ├── Build release.yml │ ├── CI.yml │ ├── Check published packages (nixpkgs).yml │ └── Check published packages (npm).yml ├── dev ├── Documentation │ ├── README.md │ ├── Build Commands.md │ └── Signatures.md └── build.sh ├── .gitattributes ├── Shakefile ├── src │ └── Shakefiles │ │ ├── Prelude.hs │ │ ├── Extra.hs │ │ ├── Signature.hs │ │ ├── ListFiles.hs │ │ └── NestedCheckout.hs ├── package.yaml └── build-elm-format.cabal ├── .gitignore ├── nix ├── tools.nix └── sources.json ├── .gitpod.yml ├── shell.nix └── hie.yaml /.envrc: -------------------------------------------------------------------------------- 1 | use nix 2 | -------------------------------------------------------------------------------- /cabal.config: -------------------------------------------------------------------------------- 1 | split-objs: True 2 | -------------------------------------------------------------------------------- /package/nix/.gitignore: -------------------------------------------------------------------------------- 1 | /nixpkgs 2 | -------------------------------------------------------------------------------- /tests/test-files/validate2.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /parser/tests/test-files/bad/BBTArgs: -------------------------------------------------------------------------------- 1 | Fail -------------------------------------------------------------------------------- /.hlint.yaml: -------------------------------------------------------------------------------- 1 | - ignore: {name: "Eta reduce"} 2 | -------------------------------------------------------------------------------- /package/elm-tooling/.gitignore: -------------------------------------------------------------------------------- 1 | /elm-tooling/ 2 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/Empty.elm: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Style Guide/.gitignore: -------------------------------------------------------------------------------- 1 | /_book/ 2 | /node_modules/ 3 | -------------------------------------------------------------------------------- /package/npm/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /result 3 | -------------------------------------------------------------------------------- /parser/tests/test-files/bad/InfiniteType.elm: -------------------------------------------------------------------------------- 1 | 2 | f = f 42 -------------------------------------------------------------------------------- /elm-format-markdown/tests/Emphasis/Escapes.markdown: -------------------------------------------------------------------------------- 1 | *hi\* there* -------------------------------------------------------------------------------- /parser/tests/test-files/bad/NonElementMain.elm: -------------------------------------------------------------------------------- 1 | 2 | main = 42 -------------------------------------------------------------------------------- /parser/tests/test-files/good/Lists/EmptyList.elm: -------------------------------------------------------------------------------- 1 | 2 | emptyList = [] -------------------------------------------------------------------------------- /tests/test-files/CommonMark/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.bak 3 | spec.html -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/TrickyModule1.elm: -------------------------------------------------------------------------------- 1 | modu = () 2 | -------------------------------------------------------------------------------- /avh4-lib/test/Tests.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -F -pgmF tasty-discover #-} 2 | -------------------------------------------------------------------------------- /package/win/.gitignore: -------------------------------------------------------------------------------- 1 | /.vagrant 2 | /elm-format.exe 3 | /elm-format/ 4 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/Lists/ListRange.elm: -------------------------------------------------------------------------------- 1 | 2 | listRange = [2..10] -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/TrickyModule3.elm: -------------------------------------------------------------------------------- 1 | portModule = () 2 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/TrickyModule4.elm: -------------------------------------------------------------------------------- 1 | effect mod = () 2 | -------------------------------------------------------------------------------- /elm-format-lib/test/Tests.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -F -pgmF tasty-discover #-} 2 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Blockquotes/Indents.markdown~: -------------------------------------------------------------------------------- 1 | > one 2 | > blockquote -------------------------------------------------------------------------------- /elm-format-markdown/tests/Emphasis/Escapes.html: -------------------------------------------------------------------------------- 1 |

hi* there

2 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/Lists/NonEmptyList.elm: -------------------------------------------------------------------------------- 1 | 2 | nonEmptyList = [1,4,5] -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/TrickyModule2.elm: -------------------------------------------------------------------------------- 1 | 2 | modulex = () 3 | -------------------------------------------------------------------------------- /elm-format-test-lib/test/Tests.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -F -pgmF tasty-discover #-} 2 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/Soundness/TrickyId.elm: -------------------------------------------------------------------------------- 1 | 2 | myId x = let y = x in y -------------------------------------------------------------------------------- /Style Guide/styles/website.css: -------------------------------------------------------------------------------- 1 | .markdown-section pre { 2 | line-height: 1em; 3 | } 4 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/TightLooseMore.markdown: -------------------------------------------------------------------------------- 1 | * foo 2 | * bar 3 | 4 | blah -------------------------------------------------------------------------------- /package/win/links.txt: -------------------------------------------------------------------------------- 1 | http://digitaldrummerj.me//vagrant-installing-your-software/ 2 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/Soundness/Id.elm: -------------------------------------------------------------------------------- 1 | 2 | myId = 3 | let id x = x in id 4 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/Empty.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (..) 2 | -------------------------------------------------------------------------------- /tests/test-files/directory/valid.elm: -------------------------------------------------------------------------------- 1 | module X exposing (a) 2 | 3 | 4 | a = 5 | 123 6 | -------------------------------------------------------------------------------- /parser/tests/test-files/bad/Strings/ExtraClose.elm: -------------------------------------------------------------------------------- 1 | 2 | s = " " " 3 | 4 | main = plainText s 5 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/Strings/Multiline.elm: -------------------------------------------------------------------------------- 1 | s = """ 2 | here's a quote: " 3 | 4 | """ 5 | -------------------------------------------------------------------------------- /tests/test-files/recursive-directory/nested/invalid.elm: -------------------------------------------------------------------------------- 1 | module X where 2 | 3 | ab,c = 123 + x 4 | -------------------------------------------------------------------------------- /Style Guide/book.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ "page-toc" ], 3 | "pluginsConfig": { 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/BackticksInLinks.markdown: -------------------------------------------------------------------------------- 1 | [the right bracket character (`]`)](/url) 2 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/Soundness/Apply.elm: -------------------------------------------------------------------------------- 1 | 2 | apply f = let g x = f x 3 | in g 4 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/ListsAndHRs.markdown: -------------------------------------------------------------------------------- 1 | * item 1 2 | * item 2 3 | * * * * * 4 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Nested_blockquotes.markdown: -------------------------------------------------------------------------------- 1 | > foo 2 | > 3 | > > bar 4 | > 5 | > foo 6 | -------------------------------------------------------------------------------- /package/npm/README.md: -------------------------------------------------------------------------------- 1 | 2 | See [https://github.com/avh4/elm-format](https://github.com/avh4/elm-format) 3 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/NoExpressions.elm: -------------------------------------------------------------------------------- 1 | 2 | type alias Width = Float 3 | type alias Height = Float -------------------------------------------------------------------------------- /parser/tests/test-files/good/Strings/MultilineNormal.elm: -------------------------------------------------------------------------------- 1 | 2 | s = " 3 | here's a quote: \" 4 | 5 | " 6 | -------------------------------------------------------------------------------- /tests/Integration/data/minimal.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (..) 2 | 3 | 4 | f : Float 5 | f = 6 | 1 7 | -------------------------------------------------------------------------------- /tests/test-files/from-json/Elm-0.19/Simple.elm: -------------------------------------------------------------------------------- 1 | module Simple exposing (f) 2 | 3 | 4 | f = 5 | () 6 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/AddMissingExposingForImport.elm: -------------------------------------------------------------------------------- 1 | import {- A -} Bar {- B -} (Foo) 2 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Tabs/TabConversionUnicode.markdown: -------------------------------------------------------------------------------- 1 | `То лпой` is a Russian word with a tab inside. 2 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/Soundness/TrickyIdAnnotated.elm: -------------------------------------------------------------------------------- 1 | 2 | myId : a -> a 3 | myId x = let y = x in y 4 | -------------------------------------------------------------------------------- /tests/test-files/recursive-directory/valid.elm: -------------------------------------------------------------------------------- 1 | module X exposing (abc) 2 | 3 | 4 | abc x = 5 | 123 + x 6 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/CaseInsensitiveReferences.html: -------------------------------------------------------------------------------- 1 |

Толпой is a Russian word.

2 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/ListsAndSetextHeaders.markdown: -------------------------------------------------------------------------------- 1 | 1. item 2 | 2. item 3 | Not header 4 | ---------- 5 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/CaseInsensitiveReferences.markdown: -------------------------------------------------------------------------------- 1 | [Толпой] is a Russian word. 2 | 3 | [ТОЛПОЙ]: /url 4 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/EmptyListItem.markdown: -------------------------------------------------------------------------------- 1 | - one 2 | - 3 | - three 4 | 5 | 1. one 6 | 2. 7 | 3. three 8 | -------------------------------------------------------------------------------- /package/npm/default.nix: -------------------------------------------------------------------------------- 1 | {pkgs ? import {}}: 2 | import ./workspace.nix pkgs (import ./elm-format-0.8.7.nix) 3 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/TransformFatArrow.elm: -------------------------------------------------------------------------------- 1 | foo : Int => Int => Int => Int 2 | foo = \a b c => a + b + c 3 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/WhiteLines.html: -------------------------------------------------------------------------------- 1 |
ABC
2 |   
3 |  
4 | 
5 | DEF
6 | 
7 |

GHI

8 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/BackticksInLinks.html: -------------------------------------------------------------------------------- 1 |

the right bracket character (])

2 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Tabs/TabConversionUnicode.html: -------------------------------------------------------------------------------- 1 |

То лпой is a Russian word with a tab inside.

2 | -------------------------------------------------------------------------------- /package/linux/archlinux/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure(2) do |config| 2 | config.vm.box = "terrywang/archlinux" 3 | end 4 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/Soundness/IdAnnotated.elm: -------------------------------------------------------------------------------- 1 | 2 | myId = let id : a -> a 3 | id x = x 4 | in id 5 | -------------------------------------------------------------------------------- /tests/stdin-error.stderr/golden: -------------------------------------------------------------------------------- 1 | Unable to parse file :1:13 To see a detailed explanation, run elm make on the file. 2 | -------------------------------------------------------------------------------- /tests/test-files/bad/Elm-0.19/UnexpectedEndOfInput.elm: -------------------------------------------------------------------------------- 1 | module UnexpectedEndOfInput (..) where 2 | 3 | abcdef = 4 | """ 5 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/TrickyModule1.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (modu) 2 | 3 | 4 | modu = 5 | () 6 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ClarifyNegativeExponentiationPrecedence.elm: -------------------------------------------------------------------------------- 1 | x = -2^2 2 | y = 4^2^ -1 3 | z = 2^ -1^2 4 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ParseTabsInLiterals.elm: -------------------------------------------------------------------------------- 1 | string = " . " 2 | char = ' ' 3 | multilineString = """ . """ 4 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/HTML/UppercaseTags.markdown: -------------------------------------------------------------------------------- 1 |
2 | this is a block 3 |
4 | 5 | Here is some inline html. -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/Entities.markdown: -------------------------------------------------------------------------------- 1 | 2 | 3 | [hi](/url "göögle & yahoo") 4 | -------------------------------------------------------------------------------- /tests/test-files/bad/Elm-0.19/UnexpectedComma.elm: -------------------------------------------------------------------------------- 1 | module UnexpectedComma (..) where 2 | 3 | 4 | abc,def = 5 | "Hello World!" 6 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/Simple.elm: -------------------------------------------------------------------------------- 1 | module Simple exposing (token) 2 | 3 | 4 | token : String 5 | token = 6 | "XYZZY" 7 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/TrickyModule2.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (modulex) 2 | 3 | 4 | modulex = 5 | () 6 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/AddMissingExposingForModule.elm: -------------------------------------------------------------------------------- 1 | module Foo {- A -} (Bar) 2 | 3 | type alias Bar = String 4 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/DistinguishCharStartFromRef.elm: -------------------------------------------------------------------------------- 1 | a = String.fromChar'!' 2 | b = identity (String.fromChar'!') 3 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/HTML/UppercaseTags.html: -------------------------------------------------------------------------------- 1 |
2 | this is a block 3 |
4 |

Here is some inline html.

5 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/ListsAndHRs.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • item 1 3 |
      4 |
    • item 2
    • 5 |
  • 6 |
7 |
8 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/Otherwise.elm: -------------------------------------------------------------------------------- 1 | module Otherwise where 2 | 3 | otherwise = 3 4 | 5 | boo = if False then "Yay" else "Boo" 6 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.17/AllSyntax/Module.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.Module exposing ((===), D, a, b, c) 2 | 3 | 4 | a = 5 | 1 6 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.17/AllSyntax/Range.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.Expressions exposing (range) 2 | 3 | 4 | range = 5 | [1..2] 6 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.17/Export.elm: -------------------------------------------------------------------------------- 1 | module Export exposing (export) 2 | 3 | 4 | export : String 5 | export = 6 | "export" 7 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/Export.elm: -------------------------------------------------------------------------------- 1 | module Export exposing (export) 2 | 3 | 4 | export : String 5 | export = 6 | "export" 7 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/TrickyModule4.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (effect) 2 | 3 | 4 | effect mod = 5 | () 6 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Blockquotes/Indents.markdown: -------------------------------------------------------------------------------- 1 | > one 2 | > blockquote 3 | 4 | >>> triply nested 5 | > > > triply nested 6 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/ListsAndSetextHeaders.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. item
  2. 3 |
  3. item 4 | Not header
  4. 5 |
6 |
7 | -------------------------------------------------------------------------------- /package/linux/archlinux/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | elm-format-0.16-bin 3 | elm-format-0.17-bin 4 | elm-format-0.18-bin 5 | elm-format-0.19-bin 6 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/Soundness/ApplyAnnotated.elm: -------------------------------------------------------------------------------- 1 | 2 | apply : (a -> b) -> a -> b 3 | apply f = let g x = f x 4 | in g 5 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/TrickyModule3.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (portModule) 2 | 3 | 4 | portModule = 5 | () 6 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/TightLooseMore.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • foo

    3 |
      4 |
    • bar
    • 5 |
    6 |

    blah

  • 7 |
8 | -------------------------------------------------------------------------------- /keys/github-actions.pub: -------------------------------------------------------------------------------- 1 | untrusted comment: minisign public key AD7B120324D7931C 2 | RWQck9ckAxJ7rR33f9wfM1h4lDzf9etWvDW7jBZUNUhIJ/PPoSN2K1Q9 3 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/FenceMatching.markdown: -------------------------------------------------------------------------------- 1 | ````abc 2 | ~~~ 3 | ``` 4 | ````blah 5 | 6 | ~~~~~ 7 | 8 | ~~~~ 9 | 10 | ~~~~~~~~~~~ -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/WhiteLines.markdown: -------------------------------------------------------------------------------- 1 | ABC 2 | 3 | 4 | 5 | DEF 6 | 7 | 8 | 9 | GHI 10 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Tidyness.markdown: -------------------------------------------------------------------------------- 1 | > A list within a blockquote: 2 | > 3 | > * asterisk 1 4 | > * asterisk 2 5 | > * asterisk 3 6 | -------------------------------------------------------------------------------- /tests/test-files/bad/Elm-0.19/UnexpectedComma.output.txt: -------------------------------------------------------------------------------- 1 | Unable to parse file :4:4 To see a detailed explanation, run elm make on the file. 2 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/FenceMatching.html: -------------------------------------------------------------------------------- 1 |
~~~
2 | ```
3 | 
4 |

5 | ~~~~
6 | 
7 | 
8 | -------------------------------------------------------------------------------- /tests/test-files/bad/Elm-0.19/UnexpectedEndOfInput.output.txt: -------------------------------------------------------------------------------- 1 | Unable to parse file :4:5 To see a detailed explanation, run elm make on the file. 2 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/AddMissingExposingForImport.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (..) 2 | 3 | import {- A -} Bar exposing {- B -} (Foo) 4 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/AddMissingExposingForModule.formatted.elm: -------------------------------------------------------------------------------- 1 | module Foo exposing {- A -} (Bar) 2 | 3 | 4 | type alias Bar = 5 | String 6 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ListAllExportsNoModuleLine.elm: -------------------------------------------------------------------------------- 1 | type alias X = () 2 | type Y = Y1 | Y2 3 | q = 4 4 | a = 1 5 | b = 2 6 | c = 3 7 | p = 5 8 | -------------------------------------------------------------------------------- /tests/test-files/directory/invalid.elm: -------------------------------------------------------------------------------- 1 | module Main (..) where 2 | 3 | x ad,dress = 4 | button [ onClick address (AddStatus { id = 50 }) ] [ text "add status" ] 5 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/Indents.markdown: -------------------------------------------------------------------------------- 1 | > * foo 2 | > 3 | > bar 4 | 5 | 6 | - one 7 | - two 8 | 9 | 10 | - one 11 | - two 12 | - three 13 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Nested_blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

foo

3 |
4 |

bar

5 |
6 |

foo

7 |
8 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/ConsecutiveLists.markdown: -------------------------------------------------------------------------------- 1 | * one 2 | * one 3 | + two 4 | + two 5 | - three 6 | - three 7 | 1. four 8 | 1. four 9 | 1) five 10 | 1) five 11 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/ApiSketch.elm: -------------------------------------------------------------------------------- 1 | module ApiSketch exposing (..) 2 | 3 | 4 | encode : Stats -> Json.Encode.Value 5 | 6 | 7 | decoder : Json.Decode.Decoder Stats 8 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ReplaceThenByOfInCase.elm: -------------------------------------------------------------------------------- 1 | type Foo = A | B | C 2 | 3 | a = A 4 | 5 | b = case a then 6 | A -> 1 7 | B -> 2 8 | C -> 3 9 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/TransformFatArrow.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (foo) 2 | 3 | 4 | foo : Int -> Int -> Int -> Int 5 | foo = 6 | \a b c -> a + b + c 7 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/DocCommentsStartingWtihAtDocs.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (x) 2 | 3 | {-| 4 | 5 | @docs x 6 | 7 | -} 8 | 9 | 10 | x = 11 | () 12 | -------------------------------------------------------------------------------- /package/win/shell/main.cmd: -------------------------------------------------------------------------------- 1 | @powershell -NoProfile -ExecutionPolicy Bypass -File "%systemdrive%\vagrant\shell\InstallChocolatey.ps1" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" 2 | -------------------------------------------------------------------------------- /cabal.project: -------------------------------------------------------------------------------- 1 | packages: 2 | ./avh4-lib, 3 | ./elm-format-markdown, 4 | ./elm-format-lib, 5 | ./elm-format-test-lib, 6 | ./ 7 | ./Shakefile 8 | with-compiler: ghc-9.6.7 9 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/BlankLinesAtEnd.markdown: -------------------------------------------------------------------------------- 1 | * List 2 | 3 | code 4 | 5 | 6 | * one 7 | * two 8 | 9 | 10 | 11 | * one 12 | not code 13 | 14 | * two 15 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/Entities.html: -------------------------------------------------------------------------------- 1 |

http://göögle.com

2 |

hi

3 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/InBlockquote.markdown: -------------------------------------------------------------------------------- 1 | > - tight 2 | > - tight 3 | 4 | 5 | > - loose 6 | > 7 | > - loose 8 | 9 | 10 | > - one-item list 11 | 12 | > - one-item list 13 | -------------------------------------------------------------------------------- /tests/test-files/from-json/Elm-0.19/ModuleComments.elm: -------------------------------------------------------------------------------- 1 | module ModuleComments exposing (f) 2 | 3 | 4 | 5 | -- Default comment 6 | {- Block comment -} 7 | 8 | 9 | f = 10 | () 11 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/LenientEqualsColon.elm: -------------------------------------------------------------------------------- 1 | 2 | 3 | type alias Foo = 4 | { x = Int 5 | , y = () 6 | } 7 | 8 | 9 | foo = 10 | { x : Int, y : Int } 11 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/EmptyListItem.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • one
  • 3 |
  • 4 |
  • three
  • 5 |
6 |
    7 |
  1. one
  2. 8 |
  3. 9 |
  4. three
  5. 10 |
11 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Strong_and_em_together.markdown: -------------------------------------------------------------------------------- 1 | ***This is strong and em.*** 2 | 3 | So is ***this*** word. 4 | 5 | ___This is strong and em.___ 6 | 7 | So is ___this___ word. 8 | -------------------------------------------------------------------------------- /package/mac/build-package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euxo pipefail 3 | 4 | ## Run tests 5 | ./dev/build.sh -- clean 6 | ./dev/build.sh 7 | 8 | ## Build binaries 9 | ./dev/build.sh -- dist 10 | -------------------------------------------------------------------------------- /package/win/build-package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euxo pipefail 3 | 4 | ## Run tests 5 | ./dev/build.sh -- clean 6 | ./dev/build.sh 7 | 8 | ## Build binaries 9 | ./dev/build.sh -- dist 10 | -------------------------------------------------------------------------------- /tests/test-files/CommonMark/tools/template.commonmark: -------------------------------------------------------------------------------- 1 | --- 2 | title: $title$ 3 | author: $author$ 4 | version: $version$ 5 | date: '$date$' 6 | license: '$license$' 7 | ... 8 | 9 | $body$ 10 | -------------------------------------------------------------------------------- /elm-format-lib/src/Parse/IParser.hs: -------------------------------------------------------------------------------- 1 | module Parse.IParser where 2 | 3 | import Parse.Primitives (Parser) 4 | import Reporting.Error.Syntax (ParsecError) 5 | 6 | 7 | type IParser a = Parser ParsecError a 8 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Literal_quotes_in_titles.markdown: -------------------------------------------------------------------------------- 1 | Foo [bar][]. 2 | 3 | Foo [bar](/url/ "Title with "quotes" inside"). 4 | 5 | 6 | [bar]: /url/ "Title with "quotes" inside" 7 | 8 | -------------------------------------------------------------------------------- /package/linux/build-package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euxo pipefail 3 | 4 | 5 | ## Run tests 6 | ./dev/build.sh -- clean 7 | ./dev/build.sh 8 | 9 | ## Build binaries 10 | ./dev/build.sh -- dist 11 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ListAllExportsNoExposing.elm: -------------------------------------------------------------------------------- 1 | module ListAllExportsNoExposing 2 | 3 | type alias X = () 4 | type Y = Y1 | Y2 5 | q = 4 6 | a = 1 7 | b = 2 8 | c = 3 9 | p = 5 10 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/AngleBrackets.markdown: -------------------------------------------------------------------------------- 1 | [silly URL with angle brackets](). 2 | 3 | [link]( "title"). 4 | 5 | [link][]. 6 | 7 | [link]: "title" 8 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Tidyness.html: -------------------------------------------------------------------------------- 1 |
2 |

A list within a blockquote:

3 |
    4 |
  • asterisk 1
  • 5 |
  • asterisk 2
  • 6 |
  • asterisk 3
  • 7 |
8 |
9 | -------------------------------------------------------------------------------- /elm-format-test-lib/src/Expect.hs: -------------------------------------------------------------------------------- 1 | module Expect where 2 | 3 | import Test.Tasty.HUnit ((@=?)) 4 | 5 | 6 | equals :: (Eq a, Show a) => a -> a -> IO () 7 | equals expected actual = 8 | expected @=? actual 9 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/QuickCheck-94f37da84c1310f03dcfa1059ce870b73c94a825--6449652945938213463.elm: -------------------------------------------------------------------------------- 1 | module{-A-}Main{-A-}(..) 2 | where 3 | 4 | foo{-A-}{-B-}=--A 5 | (a,--A 6 | b,c{-A-})--A 7 | -------------------------------------------------------------------------------- /elm-format-lib/src/ElmFormat/AST/PublicAST/Config.hs: -------------------------------------------------------------------------------- 1 | module ElmFormat.AST.PublicAST.Config (Config(..)) where 2 | 3 | 4 | newtype Config = 5 | Config 6 | { showSourceLocation :: Bool 7 | } 8 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/DistinguishCharStartFromRef.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (a, b) 2 | 3 | 4 | a = 5 | String.fromChar '!' 6 | 7 | 8 | b = 9 | identity (String.fromChar '!') 10 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !cabal.config 3 | !cabal.project 4 | !cabal.project.freeze 5 | !elm-format.cabal 6 | !elm-format-markdown 7 | !elm-format-lib 8 | !src 9 | !generated 10 | !elm-format-test-lib 11 | !avh4-lib 12 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/Start.markdown: -------------------------------------------------------------------------------- 1 | 4. this list starts with 4. 2 | 5. and continues 3 | 1. the continuation number is irrelevant. 4 | 5 | 2001) a space odyssey 6 | 7 | 1. standard lists get no start attribute 8 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/HTML/Inline.markdown: -------------------------------------------------------------------------------- 1 | hi 2 | `hi` 3 | 5 | Hello there. 7 | A line
break. 8 | 9 | -------------------------------------------------------------------------------- /package/npm/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "node": true, 4 | "es6": true 5 | }, 6 | "extends": "eslint:recommended", 7 | "rules": { 8 | "no-console": "off" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Code_Spans.markdown: -------------------------------------------------------------------------------- 1 | `` 2 | 3 | Fix for backticks within HTML tag: like this 4 | 5 | Here's how you put `` `backticks` `` in a code span. -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Literal_quotes_in_titles.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 |

Foo bar.

3 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/Unify/NonHomogeneousRecords.elm: -------------------------------------------------------------------------------- 1 | 2 | type alias Thing = 3 | { x:Float 4 | , y:Float 5 | } 6 | 7 | 8 | f : Thing -> Thing 9 | f t = 10 | let x = t.x 11 | y = t.y 12 | in t 13 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Headers/Setext.html: -------------------------------------------------------------------------------- 1 |

Level one

2 |

Two

3 |

In a paragraph

4 |

Level two

5 |

more text

6 |

====== 7 | no empty headers

8 |

not a header

9 |
10 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/AngleBrackets.html: -------------------------------------------------------------------------------- 1 |

silly URL with angle brackets.

2 |

link.

3 |

link.

4 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/LenientEqualsColon.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (Foo, foo) 2 | 3 | 4 | type alias Foo = 5 | { x : Int 6 | , y : () 7 | } 8 | 9 | 10 | foo = 11 | { x = Int, y = Int } 12 | -------------------------------------------------------------------------------- /Release Notes/0.5.1-alpha.md: -------------------------------------------------------------------------------- 1 | Bug fixes: 2 | - Whne upgrading ranges to `List.range`, parentheses are correctly added if the range is used as a function call argument 3 | - Correctly space top-level declarations that use pattern destructuring 4 | -------------------------------------------------------------------------------- /Style Guide/Upgrading.md: -------------------------------------------------------------------------------- 1 | ## Upgrading old Elm files 2 | 3 | `elm-format` 0.5.0-alpha and higher can upgrade Elm 0.17 files to Elm 0.18. 4 | See [elm-upgrade](https://github.com/avh4/elm-upgrade) for instructions on 5 | upgrading your project. 6 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.17/AllSyntax/BlockComments/Module.elm: -------------------------------------------------------------------------------- 1 | module {- A -} AllSyntax.BlockComments.Module {- B -} exposing {- C -} ({- J -} D {- K -}, {- D -} a {- E -}, {- F -} b {- G -}, {- H -} c {- I -}) 2 | 3 | 4 | a = 5 | 1 6 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ClarifyNegativeExponentiationPrecedence.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (x, y, z) 2 | 3 | 4 | x = 5 | -2 ^ 2 6 | 7 | 8 | y = 9 | 4 ^ 2 ^ -1 10 | 11 | 12 | z = 13 | 2 ^ -1 ^ 2 14 | -------------------------------------------------------------------------------- /elm-format-lib/src/Reporting/Error/Docs.hs: -------------------------------------------------------------------------------- 1 | module Reporting.Error.Docs where 2 | 3 | 4 | data Error 5 | = NoDocs 6 | | OnlyInDocs String [String] 7 | | OnlyInExports [String] 8 | | NoComment String 9 | | NoType String 10 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/HTML/Inline.html: -------------------------------------------------------------------------------- 1 |

hi 2 | hi 3 | 5 | Hello there. 7 | A line
break. 8 | <not a tag>

9 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/TwoBlankLinesEndList.markdown: -------------------------------------------------------------------------------- 1 | 1. one 2 | 3 | 2. two 4 | 5 | 6 | 1. new list 7 | 8 | 9 | > - one 10 | > 11 | > - two 12 | > 13 | > 14 | > - new list 15 | 16 | 17 | 1. one 18 | 19 | 20 | code 21 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/TailRecursive.elm: -------------------------------------------------------------------------------- 1 | 2 | any f l = 3 | case l of 4 | x :: xs -> 5 | if f x then 6 | True 7 | else 8 | any f xs 9 | _ -> 10 | False -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/QuickCheck-4562ebccb71ea9f622fb99cdf32b2923f6f9d34f-2529668492575674138.elm: -------------------------------------------------------------------------------- 1 | module --A 2 | Main 3 | ( 4 | a ,b --A 5 | , --A 6 | c){-A-}where 7 | 8 | foo={-A-}{-B-}"ABC" ({-A-}{-B-}){-A-}{-B-} "ABC" ( ) 1 9 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ExplicitlyListExposedValues.elm: -------------------------------------------------------------------------------- 1 | x = 2 | () 3 | 4 | 5 | type alias X = 6 | String 7 | 8 | 9 | type Foo 10 | = A 11 | | B 12 | | C 13 | 14 | 15 | port check : String -> Cmd msg 16 | -------------------------------------------------------------------------------- /tests/test-files/validate1.json: -------------------------------------------------------------------------------- 1 | [{"path":"_input2.elm","message":"File is not formatted with elm-format- --elm-version=0.19"} 2 | ,{"path":"_input.elm","message":"File is not formatted with elm-format- --elm-version=0.19"} 3 | ] 4 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Misc/Laziness.markdown: -------------------------------------------------------------------------------- 1 | > 1. one 2 | > two 3 | 4 | Laziness only affects paragraph continuations: 5 | 6 | > code 7 | not same code block 8 | 9 | 1. hello 10 | ----- 11 | 12 | > ``` 13 | code 14 | ``` 15 | -------------------------------------------------------------------------------- /package/win/shell/InstallChocolatey.ps1: -------------------------------------------------------------------------------- 1 | $ChocoInstallPath = "$env:SystemDrive\ProgramData\Chocolatey\bin" 2 | 3 | if (!(Test-Path $ChocoInstallPath)) { 4 | iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) 5 | } 6 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/ModuleMultiline.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.ModuleMultiline exposing 2 | ( a 3 | , b 4 | , c 5 | ) 6 | 7 | 8 | a = 9 | 1 10 | 11 | 12 | b = 13 | 2 14 | 15 | 16 | c = 17 | 3 18 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/Inline.markdown: -------------------------------------------------------------------------------- 1 | All of these are equivalent: 2 | 3 | - `*hi*` 4 | - ` *hi* ` 5 | - ``*hi* `` 6 | - ````*hi*```` 7 | - `*hi* 8 | ` 9 | 10 | Backticks in code spans: 11 | 12 | - ``` ``code`` ``` 13 | - ` ``code`` ` 14 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Headers/Setext.markdown: -------------------------------------------------------------------------------- 1 | Level one 2 | ========= 3 | 4 | Two 5 | --- 6 | 7 | In a paragraph 8 | Level two 9 | --------- 10 | more text 11 | 12 | ====== 13 | no empty headers 14 | 15 | not a header 16 | ------------ ----- 17 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Blockquotes_with_code_blocks.markdown: -------------------------------------------------------------------------------- 1 | > Example: 2 | > 3 | > sub status { 4 | > print "working"; 5 | > } 6 | > 7 | > Or: 8 | > 9 | > sub status { 10 | > return "working"; 11 | > } 12 | -------------------------------------------------------------------------------- /src/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import qualified ElmFormat.Cli 4 | import qualified System.Environment 5 | 6 | 7 | main :: IO () 8 | main = 9 | do 10 | args <- System.Environment.getArgs 11 | ElmFormat.Cli.mainIO args 12 | -------------------------------------------------------------------------------- /package/npm/index.js: -------------------------------------------------------------------------------- 1 | function dummy() { 2 | return Promise.resolve(); 3 | } 4 | 5 | module.exports = { 6 | paths: { 7 | "elm-format": require("./binary.js")(), 8 | }, 9 | install: dummy, 10 | prepare: dummy, 11 | test: dummy, 12 | }; 13 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/PortsWithTypeAliases.elm: -------------------------------------------------------------------------------- 1 | 2 | 3 | type alias Point2D = 4 | Point Float Float 5 | 6 | type alias Point x y = 7 | { x:x, y:y } 8 | 9 | 10 | port points : Point2D 11 | 12 | 13 | port pairs : Point String String 14 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/AllSyntax/Types.formatted.elm: -------------------------------------------------------------------------------- 1 | module Types exposing (Unit) 2 | 3 | 4 | type alias Unit = 5 | ( () 6 | , () 7 | ) 8 | 9 | 10 | type alias Parens = 11 | ( Int 12 | , Int 13 | , Int 14 | ) 15 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ParseTabsInLiterals.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (char, multilineString, string) 2 | 3 | 4 | string = 5 | "\t.\t" 6 | 7 | 8 | char = 9 | '\t' 10 | 11 | 12 | multilineString = 13 | """\t.\t""" 14 | -------------------------------------------------------------------------------- /.github/actions/git-tags/action.yml: -------------------------------------------------------------------------------- 1 | name: Fetch git tags 2 | 3 | runs: 4 | using: "composite" 5 | steps: 6 | - name: Workaround for https://github.com/actions/checkout/issues/290 7 | shell: bash 8 | run: git fetch --tags --prune --unshallow --force 9 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/AutoLinks.markdown: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/ReferenceLinks.markdown: -------------------------------------------------------------------------------- 1 | 1. [Link references] can be defined anywhere. 2 | 3 | [Link references]: /url 4 | (even in a list item) 5 | 6 | > [another] one 7 | > 8 | > [another]: 9 | > /foo "can break 10 | > lines" 11 | -------------------------------------------------------------------------------- /package/npm/bin/elm-format: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var spawn = require("child_process").spawn; 3 | 4 | var binPath = require("../binary.js")(); 5 | 6 | spawn(binPath, process.argv.slice(2), { stdio: "inherit" }).on( 7 | "exit", 8 | process.exit 9 | ); 10 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.17/AllSyntax/ModuleEffect.elm: -------------------------------------------------------------------------------- 1 | effect module AllSyntax.ModuleEffect where { command = MyCmd, subscription = MySub } exposing (a, b, c) 2 | 3 | 4 | type MyCmd msg 5 | = MyCmd msg 6 | 7 | 8 | type MySub msg 9 | = MySub msg 10 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Blockquotes/Indents.html: -------------------------------------------------------------------------------- 1 |
2 |

one 3 | blockquote

4 |
5 |
6 |
7 |
8 |

triply nested 9 | triply nested

10 |
11 |
12 |
13 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Inline_HTML_comments.html: -------------------------------------------------------------------------------- 1 |

Paragraph one.

2 | 3 | 6 |

Paragraph two.

7 | 8 |

The end.

9 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/AllSyntax/Types.elm: -------------------------------------------------------------------------------- 1 | module Types exposing (Unit) 2 | 3 | type alias Unit = 4 | ( ( ) 5 | , ( 6 | ) 7 | ) 8 | 9 | 10 | type alias Parens = 11 | ( (Int) 12 | , ( Int ) 13 | , ( 14 | Int 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/BlankLinesAtEnd.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • List

    3 |
    code
     4 | 
  • 5 |
6 |
    7 |
  • one
  • 8 |
  • two
  • 9 |
10 |
    11 |
  • one 12 | not code

  • 13 |
  • two

  • 14 |
15 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/ReferenceLinks.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. Link references can be defined anywhere.

  2. 3 |
4 |
5 |

another one

7 |
8 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/CodeBlocksInLists.markdown: -------------------------------------------------------------------------------- 1 | 1. list item 2 | code 3 | 4 | 2. list item 5 | ~~~ 6 | code 7 | ~~~ 8 | 9 | 3. ~~~ 10 | code 11 | ~~~ 12 | 13 | 4. ~~~ 14 | code 15 | ~~~ 16 | 17 | 5. code 18 | code 19 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/QuotesAndComments.elm: -------------------------------------------------------------------------------- 1 | 2 | 3 | variablesWithPrimes x = 4 | let x' = x 5 | in 6 | x' 7 | 8 | 9 | doubleQuote = '\"' 10 | 11 | 12 | singleQuote = '\'' 13 | 14 | 15 | {- this is an {- embeded comment -} -} 16 | commentStart = "{-" -------------------------------------------------------------------------------- /parser/tests/test-files/good/AliasSubstitution.elm: -------------------------------------------------------------------------------- 1 | 2 | 3 | type alias Vec2Ext record = 4 | { record | x:Float, y:Float } 5 | 6 | 7 | type alias Vec2 = 8 | Vec2Ext {} 9 | 10 | 11 | extractVec : Vec2Ext a -> Vec2 12 | extractVec v = 13 | { x = v.x, y = v.y } 14 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Strong_and_em_together.html: -------------------------------------------------------------------------------- 1 |

This is strong and em.

2 |

So is this word.

3 |

This is strong and em.

4 |

So is this word.

5 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/Examples.elm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ratio = graphHeight / (if range == 0 then 0.1 else toFloat range) 4 | 5 | -- foo=(case x of {True->1;False->3}) 6 | 7 | bar = (if if a then True else False then "a" else "b") 8 | 9 | multilineList = [1,2,3 10 | ] 11 | -------------------------------------------------------------------------------- /Release Notes/0.5.2-alpha.md: -------------------------------------------------------------------------------- 1 | Bug fixes: 2 | - When upgrading backticks, parentheses are correctly added if the second argument is a function call 3 | - Added a workaround for an elm-compiler bug where patterns with literal negative numbers cannot be used without parentheses in case expressions 4 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/IndentedInLists.markdown: -------------------------------------------------------------------------------- 1 | - code starts here 2 | 3 | 1. foo 4 | 5 | code starts here 6 | 7 | 2. foo 8 | 9 | code starts here 10 | 11 | - foo 12 | 13 | code starts here 14 | 15 | - foo 16 | 17 | code starts here 18 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Code_Spans.html: -------------------------------------------------------------------------------- 1 |

<test a=" content of attribute ">

2 |

Fix for backticks within HTML tag: like this

3 |

Here's how you put `backticks` in a code span.

4 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Inline_HTML_comments.markdown: -------------------------------------------------------------------------------- 1 | Paragraph one. 2 | 3 | 4 | 5 | 8 | 9 | Paragraph two. 10 | 11 | 12 | 13 | The end. 14 | -------------------------------------------------------------------------------- /dev/Documentation/README.md: -------------------------------------------------------------------------------- 1 | 2 | Documentation about the development and maintenance of elm-format itself. 3 | 4 | - [Build Commands.md](./Build Commands.md): List of useful build and dev commands 5 | - [Publishing.md](./Publishing.md): Instructions on how to publish a new release of elm-format 6 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/Indents.html: -------------------------------------------------------------------------------- 1 |
2 |
    3 |
  • foo

    4 |

    bar

  • 5 |
6 |
7 |
    8 |
  • one
  • 9 |
  • two
  • 10 |
11 |
    12 |
  • one 13 |
      14 |
    • two
    • 15 |
  • 16 |
  • three
  • 17 |
18 | -------------------------------------------------------------------------------- /dev/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | (cd Shakefile && hpack) 5 | (cd avh4-lib && hpack) 6 | (cd elm-format-markdown && hpack) 7 | (cd elm-format-lib && hpack) 8 | (cd elm-format-test-lib && hpack) 9 | hpack 10 | exec cabal run build-elm-format:exe:build-elm-format -- "$@" 11 | -------------------------------------------------------------------------------- /package/win/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure(2) do |config| 2 | config.vm.box = "opentable/win-2012r2-standard-amd64-nocm" 3 | 4 | config.vm.communicator = "winrm" 5 | 6 | config.vm.provision :shell, path: "shell/main.cmd" 7 | config.vm.provision :shell, path: "shell/InstallPackages.bat" 8 | end 9 | -------------------------------------------------------------------------------- /src/ElmFormat/Version.hs: -------------------------------------------------------------------------------- 1 | module ElmFormat.Version (asString, experimental) where 2 | 3 | import qualified Build_elm_format 4 | 5 | 6 | asString :: String 7 | asString = 8 | Build_elm_format.gitDescribe 9 | 10 | 11 | experimental :: Maybe String 12 | experimental = 13 | Nothing 14 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.17/TopLevelSpacing.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (Model, class, classList, id) 2 | 3 | 4 | { id, class, classList } = 5 | CssCommon.helpers 6 | 7 | 8 | type alias Model = 9 | { mnemonic : String 10 | , operand : String 11 | , offset : Int 12 | } 13 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/TopLevelSpacing.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (Model, class, classList, id) 2 | 3 | 4 | { id, class, classList } = 5 | CssCommon.helpers 6 | 7 | 8 | type alias Model = 9 | { mnemonic : String 10 | , operand : String 11 | , offset : Int 12 | } 13 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.19/TopLevelSpacing.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (Model, class, classList, id) 2 | 3 | 4 | { id, class, classList } = 5 | CssCommon.helpers 6 | 7 | 8 | type alias Model = 9 | { mnemonic : String 10 | , operand : String 11 | , offset : Int 12 | } 13 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/AllSyntax/Patterns.formatted.elm: -------------------------------------------------------------------------------- 1 | module Patterns exposing (consList) 2 | 3 | 4 | consList ( a :: b :: c, a {- 1 -} :: {- 2 -} b {- 3 -} :: {- 4 -} c, d :: e :: f ) = 5 | () 6 | 7 | 8 | complexCons (a :: (x :: []) :: ((b :: _) as blah)) = 9 | () 10 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/InlineLinks.markdown: -------------------------------------------------------------------------------- 1 | 1. [link](/url) 2 | 2. [link](/url "title") 3 | 3. [link](/url 4 | "title") 5 | 4. [link *with 6 | linebreak*](
"title 7 | with linebreak"). 8 | 5. [link](/url(withparens) 'and single quoted title') 9 | 6. [not a link] (/url) 10 | -------------------------------------------------------------------------------- /package/win/shell/InstallPackages.bat: -------------------------------------------------------------------------------- 1 | chocolatey feature enable -n=allowGlobalConfirmation 2 | choco install BoxStarter 3 | choco install git 4 | choco install mingw 5 | choco install python 6 | choco install zip 7 | choco install --x86 haskell-stack 8 | chocolatey feature disable -n=allowGlobalConfirmation 9 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Misc/Transitions.markdown: -------------------------------------------------------------------------------- 1 | > blockquote 2 | > > blockquote 3 | 1. list 4 | 2. list 5 | - sublist 6 | * * * * * 7 | paragraph 8 | header 9 | ------ 10 | ### header 11 | code 12 | ``` 13 | code 14 | ``` 15 |
16 |
17 | # not a header 18 |
19 |
20 | -------------------------------------------------------------------------------- /elm-format-lib/src/AST/Helpers.hs: -------------------------------------------------------------------------------- 1 | module AST.Helpers where 2 | 3 | import qualified Data.Char as Char 4 | 5 | 6 | isOp :: String -> Bool 7 | isOp name = 8 | all isSymbol name 9 | 10 | 11 | isSymbol :: Char -> Bool 12 | isSymbol c = 13 | Char.isSymbol c || elem c ("+-/*=.$<>:&|^?%#@~!" :: String) 14 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Code_Blocks.markdown: -------------------------------------------------------------------------------- 1 | code block on the first line 2 | 3 | Regular text. 4 | 5 | code block indented by spaces 6 | 7 | Regular text. 8 | 9 | the lines in this block 10 | all contain trailing spaces 11 | 12 | Regular Text. 13 | 14 | code block on the last line -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/Expressions/Unary.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (multilineUnaryOperator, unaryOperator) 2 | 3 | 4 | unaryOperator a = 5 | -(a - 1) + -2 + -a 6 | 7 | 8 | multilineUnaryOperator a = 9 | -(if a then 10 | 1 11 | 12 | else 13 | 2 14 | ) 15 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ExplicitlyListExposedValues.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (Foo(..), X, check, x) 2 | 3 | 4 | x = 5 | () 6 | 7 | 8 | type alias X = 9 | String 10 | 11 | 12 | type Foo 13 | = A 14 | | B 15 | | C 16 | 17 | 18 | port check : String -> Cmd msg 19 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/IndentedFences.markdown: -------------------------------------------------------------------------------- 1 | ``` 2 | a 3 | ``` 4 | 5 | ``` 6 | z 7 | ``` 8 | 9 | ``` 10 | a 11 | a 12 | a 13 | a 14 | ``` 15 | 16 | * foo 17 | 18 | ``` 19 | Hello 20 | 21 | ``` 22 | 23 | World 24 | ``` 25 | 26 | > ``` 27 | >a 28 | >``` -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Blockquotes_with_code_blocks.html: -------------------------------------------------------------------------------- 1 |
2 |

Example:

3 |
sub status {
 4 |     print "working";
 5 | }
 6 | 
7 |

Or:

8 |
sub status {
 9 |     return "working";
10 | }
11 | 
12 |
13 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/BlankLines.markdown: -------------------------------------------------------------------------------- 1 | foo 2 | 3 | 4 | 5 | bar 6 | > foo 7 | > 8 | > 9 | > 10 | > bar 11 | foo 12 | 13 | 14 | 15 | bar 16 | 17 | 1. One 18 | 19 | CodeA 20 | 21 | CodeB 22 | 23 | 2. Two 24 | 25 | CodeA 26 | 27 | 28 | 1. One 29 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/Start.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. this list starts with 4.
  2. 3 |
  3. and continues
  4. 4 |
  5. the continuation number is irrelevant.
  6. 5 |
6 |
    7 |
  1. a space odyssey
  2. 8 |
9 |
    10 |
  1. standard lists get no start attribute
  2. 11 |
12 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Blockquotes/Nesting.markdown: -------------------------------------------------------------------------------- 1 | These are all equivalent: 2 | 3 | > > nested 4 | > > blockquote 5 | 6 | 7 | >> nested 8 | >> blockquote 9 | 10 | 11 | > > nested 12 | blockquote 13 | 14 | 15 | > > nested 16 | > blockquote 17 | 18 | 19 | This is not: 20 | 21 | > nested 22 | > > blockquote 23 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.17/AllSyntax/InfixOperators.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (infixApplication, infixApplicationMultiline) 2 | 3 | 4 | infixApplication = 5 | 1 `operator` 2 6 | 7 | 8 | infixApplicationMultiline = 9 | x 10 | `infixOperator` 11 | [ y 12 | , z 13 | ] 14 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/ListBreakAfter.markdown: -------------------------------------------------------------------------------- 1 | * foo 2 | * bar 3 | 4 | code1 5 | code2 6 | 7 | code? 8 | 9 | * foo 10 | * bar 11 | 12 | code1 13 | code2 14 | 15 | 16 | code? 17 | 18 | * foo 19 | * bar 20 | 21 | code1 22 | code2 23 | 24 | 25 | 26 | code? 27 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Links_shortcut_references.html: -------------------------------------------------------------------------------- 1 |

This is the simple case.

2 |

This one has a line 3 | break.

4 |

This one has a line 5 | break with a line-ending space.

6 |

this and the other

7 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/AllSyntax/Patterns.elm: -------------------------------------------------------------------------------- 1 | module Patterns exposing (consList) 2 | 3 | consList 4 | ( a::b::c 5 | , a{- 1 -}::{- 2 -}b{- 3 -}::{- 4 -}c 6 | , d 7 | :: 8 | e 9 | :: 10 | f 11 | ) 12 | = 13 | () 14 | 15 | 16 | complexCons (a::(x::[])::((b::_)as blah)) = 17 | () 18 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/QuickCheck-94f37da84c1310f03dcfa1059ce870b73c94a825--6449652945938213463.formatted.elm: -------------------------------------------------------------------------------- 1 | module {- A -} Main {- A -} exposing (..) 2 | 3 | 4 | foo = 5 | {- A -} 6 | {- B -} 7 | --A 8 | ( a 9 | , --A 10 | b 11 | , c {- A -} 12 | ) 13 | 14 | 15 | 16 | --A 17 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ListDocumentedExportsNoExposing.elm: -------------------------------------------------------------------------------- 1 | module ListDocumentedExportsNoExposing 2 | 3 | {-| 4 | 5 | @docs a 6 | 7 | # Heading 8 | 9 | @docs X 10 | @docs Y 11 | @docs b, c 12 | 13 | -} 14 | 15 | type alias X = () 16 | type Y = Y1 | Y2 17 | q = 4 18 | a = 1 19 | b = 2 20 | c = 3 21 | p = 5 22 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/CodeBlocksInLists.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. list item 3 | code

  2. 4 |
  3. list item

    5 |
    code
     6 | 
  4. 7 |
  5. code
     8 | 
  6. 9 |
  7. code
    10 | 
  8. 11 |
  9. code
    12 | code
    13 | 
  10. 14 |
15 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/ConsecutiveLists.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • one
  • 3 |
  • one
  • 4 |
5 |
    6 |
  • two
  • 7 |
  • two
  • 8 |
9 |
    10 |
  • three
  • 11 |
  • three
  • 12 |
13 |
    14 |
  1. four
  2. 15 |
  3. four
  4. 16 |
17 |
    18 |
  1. five
  2. 19 |
  3. five
  4. 20 |
21 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/HTML/Blocks.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | *raw html* 4 |
5 |
6 |
7 |
8 |

this is markdown

9 |
10 |
11 | 13 | 16 |
17 | * raw html with trailing space 18 |
19 | -------------------------------------------------------------------------------- /tests/test-files/from-json/Elm-0.19/Simple.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleName": "Simple", 3 | "body": [ 4 | { 5 | "tag": "Definition", 6 | "name": "f", 7 | "parameters": [], 8 | "expression": { 9 | "tag": "UnitLiteral" 10 | } 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Headers/ATX.markdown: -------------------------------------------------------------------------------- 1 | # One 2 | ## Two 3 | ### Three 4 | #### Four 5 | ##### Five 6 | 7 | ###### Six 8 | 9 | ####### Seven 10 | 11 | ### Three with ### 12 | ## Spacing doesn't matter ## 13 | ## Escaped final \## 14 | 15 | \## Not a header 16 | 17 | #5 not a header 18 | 19 | ## 20 | (empty header) 21 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/Sublists.markdown: -------------------------------------------------------------------------------- 1 | Four levels: 2 | 3 | - one 4 | - two 5 | - three 6 | - four 7 | 8 | 9 | 1. one 10 | 1. two 11 | 1. three 12 | 1. four 13 | 14 | 15 | 1) one 16 | - two 17 | 1) three 18 | - four 19 | 20 | 21 | - one 22 | - two 23 | 1. three 24 | 1) four 25 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/HTML/Blocks.markdown: -------------------------------------------------------------------------------- 1 |
2 |
3 | *raw html* 4 |
5 |
6 | 7 |
8 |
9 | 10 | *this is markdown* 11 | 12 |
13 |
14 | 15 | 17 | 18 | 23 | 24 |
25 | * raw html with trailing space 26 |
27 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Headers/ATX.html: -------------------------------------------------------------------------------- 1 |

One

2 |

Two

3 |

Three

4 |

Four

5 |
Five
6 |
Six
7 |

####### Seven

8 |

Three with

9 |

Spacing doesn't matter

10 |

Escaped final #

11 |

## Not a header

12 |

#5 not a header

13 |

14 |

(empty header)

15 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Auto_links.markdown: -------------------------------------------------------------------------------- 1 | Link: . 2 | 3 | With an ampersand: 4 | 5 | * In a list? 6 | * 7 | * It should. 8 | 9 | > Blockquoted: 10 | 11 | Auto-links should not occur here: `` 12 | 13 | or here: -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ReplaceThenByOfInCase.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (Foo(..), a, b) 2 | 3 | 4 | type Foo 5 | = A 6 | | B 7 | | C 8 | 9 | 10 | a = 11 | A 12 | 13 | 14 | b = 15 | case a of 16 | A -> 17 | 1 18 | 19 | B -> 20 | 2 21 | 22 | C -> 23 | 3 24 | -------------------------------------------------------------------------------- /Release Notes/0.3.1-alpha.md: -------------------------------------------------------------------------------- 1 | This is a bug fix release. 2 | 3 | ### Changelog 4 | - BUG: Fixed formatting of the following code (in 0.3.0-alpha it would format to invalid syntax) [#179](https://github.com/avh4/elm-format/issues/179) 5 | 6 | ``` 7 | import Dict as D 8 | exposing 9 | ( empty 10 | , fromList 11 | ) 12 | ``` 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | avh4-lib/avh4-lib.cabal linguist-generated=true 2 | elm-format-lib/elm-format-lib.cabal linguist-generated=true 3 | elm-format-markdown/elm-format-markdown.cabal linguist-generated=true 4 | elm-format-test-lib/elm-format-test-lib.cabal linguist-generated=true 5 | elm-format.cabal linguist-generated=true 6 | Shakefile/build-elm-format.cabal linguist-generated=true 7 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/IndentedFences.html: -------------------------------------------------------------------------------- 1 |
a
 2 | 
3 |
z
 4 | 
5 |
a
 6 |  a
 7 | a
 8 |  a
 9 | 
10 |
    11 |
  • foo

    12 |
         Hello
    13 | 
    14 |  ```
    15 | 
    16 | World
    17 | 
  • 18 |
19 |
20 |
a
21 | 
22 |
23 | -------------------------------------------------------------------------------- /tests/test-files/CommonMark/.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | end_of_line = lf 7 | charset = utf-8 8 | insert_final_newline = true 9 | 10 | [*.{c,h}] 11 | trim_trailing_whitespace = true 12 | indent_style = tab 13 | indent_size = 8 14 | 15 | [Makefile] 16 | trim_trailing_whitespace = true 17 | indent_style = tab 18 | indent_size = 8 19 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/QuickCheck-4562ebccb71ea9f622fb99cdf32b2923f6f9d34f-2529668492575674138.formatted.elm: -------------------------------------------------------------------------------- 1 | module 2 | --A 3 | Main 4 | {- A -} exposing 5 | ( a 6 | , b 7 | --A 8 | , --A 9 | c 10 | ) 11 | 12 | 13 | foo = 14 | {- A -} 15 | {- B -} 16 | "ABC" ({- A -} {- B -}) {- A -} {- B -} "ABC" () 1 17 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ListAllExportsNoModuleLine.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (X, Y(..), a, b, c, p, q) 2 | 3 | 4 | type alias X = 5 | () 6 | 7 | 8 | type Y 9 | = Y1 10 | | Y2 11 | 12 | 13 | q = 14 | 4 15 | 16 | 17 | a = 18 | 1 19 | 20 | 21 | b = 22 | 2 23 | 24 | 25 | c = 26 | 3 27 | 28 | 29 | p = 30 | 5 31 | -------------------------------------------------------------------------------- /Shakefile/src/Shakefiles/Prelude.hs: -------------------------------------------------------------------------------- 1 | module Shakefiles.Prelude where 2 | 3 | import Development.Shake 4 | 5 | 6 | nTimes :: Int -> (a -> a) -> (a -> a) 7 | nTimes 0 _ = id 8 | nTimes 1 f = f 9 | nTimes n f = f . nTimes (n-1) f 10 | 11 | 12 | hashNeed :: [FilePath] -> Action String 13 | hashNeed files = do 14 | need files 15 | liftIO $ getHashedShakeVersion files 16 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/Inline.html: -------------------------------------------------------------------------------- 1 |

All of these are equivalent:

2 |
    3 |
  • *hi*
  • 4 |
  • *hi*
  • 5 |
  • *hi*
  • 6 |
  • *hi*
  • 7 |
  • *hi*
  • 8 |
9 |

Backticks in code spans:

10 |
    11 |
  • ``code``
  • 12 |
  • ``code``
  • 13 |
14 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ListAllExportsNoExposing.formatted.elm: -------------------------------------------------------------------------------- 1 | module ListAllExportsNoExposing exposing (X, Y(..), a, b, c, p, q) 2 | 3 | 4 | type alias X = 5 | () 6 | 7 | 8 | type Y 9 | = Y1 10 | | Y2 11 | 12 | 13 | q = 14 | 4 15 | 16 | 17 | a = 18 | 1 19 | 20 | 21 | b = 22 | 2 23 | 24 | 25 | c = 26 | 3 27 | 28 | 29 | p = 30 | 5 31 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Emphasis/Punctuation.markdown: -------------------------------------------------------------------------------- 1 | Here is a _ that is _cool_. 2 | 3 | _Foo._ 4 | 5 | __Foo.__ 6 | 7 | ___Foo.___ 8 | 9 | _Foo_. 10 | 11 | __Foo__. 12 | 13 | ___Foo___. 14 | 15 | _Foo_. _Foo_? _Foo_! _Foo_: _Foo_; (_Foo_) 16 | 17 | __Foo__. __Foo__? __Foo__! __Foo__: __Foo__; (__Foo__) 18 | 19 | ___Foo___. ___Foo___? ___Foo___! ___Foo___: ___Foo___; (___Foo___) 20 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/TwoBlankLinesEndList.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. one

  2. 3 |
  3. two

  4. 4 |
5 |
    6 |
  1. new list
  2. 7 |
8 |
9 |
    10 |
  • one

  • 11 |
  • two

  • 12 |
13 |
    14 |
  • new list
  • 15 |
16 |
17 |
    18 |
  1. one
  2. 19 |
20 |
code
21 | 
22 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Links_shortcut_references.markdown: -------------------------------------------------------------------------------- 1 | This is the [simple case]. 2 | 3 | [simple case]: /simple 4 | 5 | 6 | 7 | This one has a [line 8 | break]. 9 | 10 | This one has a [line 11 | break] with a line-ending space. 12 | 13 | [line break]: /foo 14 | 15 | 16 | [this] [that] and the [other] 17 | 18 | [this]: /this 19 | [that]: /that 20 | [other]: /other 21 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/DocCommentCheapskateReferenceBug.elm: -------------------------------------------------------------------------------- 1 | module DocCommentCheapskateReferenceBug exposing (f) 2 | 3 | 4 | {-| docs 5 | 6 | [link1]: http://example.com 7 | [link2]: http://example.com 8 | (cheapskate bug]: http://example.com 9 | [not a link]: http://example.com 10 | 11 | [bug]: http://example.com 12 | sdfjkl 13 | 14 | -} 15 | 16 | 17 | f = 18 | () 19 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/CaseExpression3.elm: -------------------------------------------------------------------------------- 1 | 2 | type List a 3 | = Nil 4 | | Cons a (List a) 5 | 6 | 7 | zip : List a -> List b -> List (a, b) 8 | zip list1 list2 = 9 | case (list1, list2) of 10 | (Nil, _) -> 11 | Nil 12 | 13 | (_, Nil) -> 14 | Nil 15 | 16 | (Cons x xs, Cons y ys) -> 17 | Cons (x, y) (zip xs ys) 18 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.17/AllSyntax/LineComments/Module.elm: -------------------------------------------------------------------------------- 1 | --A 2 | 3 | 4 | module 5 | --B 6 | AllSyntax.LineComments.Module 7 | --C 8 | exposing 9 | --D 10 | ( --K 11 | D 12 | --L 13 | , --E 14 | a 15 | --F 16 | , --G 17 | b 18 | --H 19 | , --I 20 | c 21 | --J 22 | ) 23 | 24 | 25 | a = 26 | 1 27 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Code_Blocks.html: -------------------------------------------------------------------------------- 1 |
code block on the first line
 2 | 
3 |

Regular text.

4 |
code block indented by spaces
 5 | 
6 |

Regular text.

7 |
the lines in this block  
 8 | all contain trailing spaces  
 9 | 
10 |

Regular Text.

11 |
code block on the last line
12 | 
13 | -------------------------------------------------------------------------------- /package/npm/shell.nix: -------------------------------------------------------------------------------- 1 | {pkgs ? import {}}: let 2 | workspace = import ./. {inherit pkgs;}; 3 | in 4 | pkgs.mkShell { 5 | buildInputs = with pkgs; [ 6 | # Required 7 | nodejs 8 | 9 | # Debugging tools 10 | jq 11 | jless 12 | ]; 13 | shellHook = '' 14 | cd ${workspace} 15 | export PS1="[Publishing elm-format] " 16 | ''; 17 | } 18 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/TightLooseBlockquote.markdown: -------------------------------------------------------------------------------- 1 | * tight I 2 | > bq 3 | > 4 | * tight I 5 | 6 | 7 | * tight II 8 | > bq 9 | > 10 | foo 11 | * tight II 12 | 13 | 1. Blank lines in bq don't break list 14 | > bq 15 | > 16 | > 17 | 1. Should say (2) in output 18 | 19 | * Blank lines in bq don't break LI 20 | * item A 21 | > bq 22 | > 23 | > 24 | * item B 25 | -------------------------------------------------------------------------------- /Style Guide/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Summary 2 | 3 | * [Introduction](README.md) 4 | * [Imports](Imports.md) 5 | * [Declarations](Declarations.md) 6 | * [Expressions](Expressions.md) 7 | * [Lists](Lists.md) 8 | * [Documentation](Documentation.md) 9 | * [Sections and Grouping](Sections.md) 10 | * [Markdown](Markdown.md) 11 | * Extra features 12 | * [CI support](CI.md) 13 | * [Upgrading old Elm files](Upgrading.md) 14 | -------------------------------------------------------------------------------- /tests/test-files/from-json/Elm-0.19/ModuleImports.elm: -------------------------------------------------------------------------------- 1 | module ModuleImports exposing (f) 2 | 3 | import Exposing.Everything exposing (..) 4 | import Exposing.Types exposing (ExposeAllTags(..), ExposeNoTags) 5 | import Exposing.Values exposing (a, b) 6 | import Multi.Word.Alias as WordAlias 7 | import Multi.Word.NoAlias 8 | import SingleWordAlias as S 9 | import SingleWordNoAlias 10 | 11 | 12 | f = 13 | () 14 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/DocCommentCheapskateReferenceBug.formatted.elm: -------------------------------------------------------------------------------- 1 | module DocCommentCheapskateReferenceBug exposing (f) 2 | 3 | {-| docs 4 | 5 | [link1]: http://example.com 6 | [link2]: http://example.com 7 | 8 | (cheapskate bug]: 9 | [not a link]: 10 | 11 | [bug]: http://example.com 12 | 13 | sdfjkl 14 | 15 | -} 16 | 17 | 18 | f = 19 | () 20 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/InBlockquote.html: -------------------------------------------------------------------------------- 1 |
2 |
    3 |
  • tight
  • 4 |
  • tight
  • 5 |
6 |
7 |
8 |
    9 |
  • loose

  • 10 |
  • loose

  • 11 |
12 |
13 |
14 |
    15 |
  • one-item list
  • 16 |
17 |
18 |
19 |
    20 |
  • one-item list
  • 21 |
22 |
23 | -------------------------------------------------------------------------------- /elm-format-lib/src/ElmFormat/AST/PublicAST.hs: -------------------------------------------------------------------------------- 1 | module ElmFormat.AST.PublicAST 2 | ( module ElmFormat.AST.PublicAST.Core 3 | , module ElmFormat.AST.PublicAST.Config 4 | , module ElmFormat.AST.PublicAST.Module 5 | ) where 6 | 7 | import ElmFormat.AST.PublicAST.Core (ToPublicAST(..), FromPublicAST(..)) 8 | import ElmFormat.AST.PublicAST.Config 9 | import ElmFormat.AST.PublicAST.Module (fromModule, toModule) 10 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Blockquotes/Separation.markdown: -------------------------------------------------------------------------------- 1 | One blockquote, two paragraphs: 2 | 3 | > one 4 | > 5 | > two 6 | 7 | Two blockquotes: 8 | 9 | > one 10 | 11 | > two 12 | 13 | Nested blockquote, two paragraphs: 14 | 15 | > > one 16 | > > 17 | > > two 18 | 19 | Nested blockquote, two blockquotes: 20 | 21 | > > one 22 | > 23 | > > two 24 | 25 | Two nested blockquotes: 26 | 27 | > > one 28 | 29 | > > two 30 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/InlineLinks.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. link
  2. 3 |
  3. link
  4. 4 |
  5. link
  6. 5 |
  7. link with 7 | linebreak.
  8. 8 |
  9. link
  10. 9 |
  11. [not a link] (/url)
  12. 10 |
11 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Misc/BackslashEscapes.markdown: -------------------------------------------------------------------------------- 1 | \*not emphasized* 2 | \\*emphasis* 3 | \**not bold** 4 | \
not a tag 5 | \[link](/foo) not a link 6 | [link](/foo\) "title\"") 7 | \`not code` 8 | 9 | 1\. not a list item 10 | 11 | \* not a list. 12 | 13 | \# Not a header 14 | 15 | \[foo]: /url "not a reference" 16 | 17 | \$ \^ \; can be escaped. 18 | \a \b \T cannot. 19 | unicode letters and symbols cannot: \π \‥. 20 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Misc/Laziness.html: -------------------------------------------------------------------------------- 1 |
2 |
    3 |
  1. one 4 | two
  2. 5 |
6 |
7 |

Laziness only affects paragraph continuations:

8 |
9 |
code
10 | 
11 |
12 |
not same code block
13 | 
14 |
    15 |
  1. hello
  2. 16 |
17 |
18 |
19 |
code
20 | 
21 |
22 | -------------------------------------------------------------------------------- /tests/test-files/CommonMark/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "commonmark-spec", 3 | "version": "0.27.0", 4 | "description": "CommonMark spec and test cases", 5 | "homepage": "http://commonmark.org", 6 | "license": "CC-BY-SA-4.0", 7 | "keywords": [ 8 | "commonmark", 9 | "markdown" 10 | ], 11 | "repository": "jgm/CommonMark", 12 | "license": "MIT", 13 | "files": [ 14 | "index.js", 15 | "spec.txt" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/WindowsEol.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.WindowsEol exposing (string) 2 | 3 | {-| elm-format converts all CRLF line-endings to LF. 4 | 5 | Raw CRs that are within strings will be escaped. 6 | 7 | Escaped CRs will be retained. 8 | -} 9 | 10 | 11 | multilineString = 12 | """ 13 | """ 14 | 15 | 16 | string = " 17 | " 18 | 19 | 20 | rawCR = " " 21 | 22 | 23 | escapedCR = "\x0D" 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated source files 2 | /generated/ 3 | 4 | # Files generated by the test suite 5 | /formatted.elm 6 | /_input.elm 7 | /_input2.elm 8 | /_stdout.txt 9 | /tests/**/actual 10 | 11 | # Files generated by the build system 12 | /.direnv/ 13 | /.shake/ 14 | /.shake.cache/ 15 | /_build/ 16 | /dist-newstyle/ 17 | /bin/ 18 | 19 | # Output files 20 | /dist/ 21 | /publish/ 22 | /downloads/ 23 | /result 24 | /_profile/ 25 | /_coverage/ 26 | -------------------------------------------------------------------------------- /parser/tests/test-files/bad/IncompletePatternMatch.elm: -------------------------------------------------------------------------------- 1 | 2 | type List a 3 | = Nil 4 | | Cons a (List a) 5 | 6 | 7 | zip : List a -> List b -> List (a, b) 8 | zip list1 list2 = 9 | case (list1, list2) of 10 | (Nil, _) -> 11 | Nil 12 | 13 | (Cons x xs, Cons y ys) -> 14 | Cons (x, y) (zip xs ys) 15 | 16 | -- incomplete pattern match is an error 17 | -- missing: (_, Nil) -> Nil 18 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.17/AllSyntax/BlockComments/ModuleEffect.elm: -------------------------------------------------------------------------------- 1 | effect {- T -} module {- A -} AllSyntax.BlockComments.ModuleEffect {- B -} where {- C -} { {- D -} command {- E -} = {- F -} MyCmd {- G -}, {- H -} subscription {- I -} = {- J -} MySub {- K -} } {- L -} exposing {- M -} ({- N -} a {- O -}, {- P -} b {- Q -}, {- R -} c {- S -}) 2 | 3 | 4 | type MyCmd msg 5 | = MyCmd msg 6 | 7 | 8 | type MySub msg 9 | = MySub msg 10 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Tabs.markdown: -------------------------------------------------------------------------------- 1 | + this is a list item 2 | indented with tabs 3 | 4 | + this is a list item 5 | indented with spaces 6 | 7 | Code: 8 | 9 | this code block is indented by one tab 10 | 11 | And: 12 | 13 | this code block is indented by two tabs 14 | 15 | And: 16 | 17 | + this is an example list item 18 | indented with tabs 19 | 20 | + this is an example list item 21 | indented with spaces 22 | -------------------------------------------------------------------------------- /parser/tests/test-files/good/Ports.elm: -------------------------------------------------------------------------------- 1 | 2 | -- incoming 3 | port userID : String 4 | port number : Int 5 | port tuple : (Float,Bool) 6 | port array : List Int 7 | port record : { x:Float, y:Float } 8 | 9 | -- outgoing 10 | port fortyTwo : Int 11 | port fortyTwo = 12 | 42 13 | 14 | 15 | port time : Float 16 | port time = 17 | 3.14 18 | 19 | port students : List { name:String, age:Int } 20 | port students = 21 | [ { name = "Tom", age = 42 } ] -------------------------------------------------------------------------------- /tests/json-format-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "array", 3 | "items": { 4 | "type": "object", 5 | "properties": { 6 | "path": { 7 | "type": "string" 8 | }, 9 | "line": { 10 | "type": "number" 11 | }, 12 | "column": { 13 | "type": "number" 14 | }, 15 | "message": { 16 | "type": "string" 17 | } 18 | }, 19 | "required": ["path", "message"] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Misc/LineBreaks.html: -------------------------------------------------------------------------------- 1 |

Two spaces
2 | break a line. Or more than two
3 | and spaces in the following line are absorbed.

4 |

You can also break lines with
5 | a backslash.

6 |

Two spaces at the end of a paragraph are 7 | not a line break.

8 |

A backslash at the end of a paragraph is 9 | not a line break.\

10 |

Similarly with setext headers

11 |

And with backslashes\

12 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/WindowsEol.formatted.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.WindowsEol exposing (string) 2 | 3 | {-| elm-format converts all CRLF line-endings to LF. 4 | 5 | Raw CRs that are within strings will be escaped. 6 | 7 | Escaped CRs will be retained. 8 | 9 | -} 10 | 11 | 12 | multilineString = 13 | """ 14 | """ 15 | 16 | 17 | string = 18 | "\n" 19 | 20 | 21 | rawCR = 22 | "\x0D" 23 | 24 | 25 | escapedCR = 26 | "\x0D" 27 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/ParensInURLs.markdown: -------------------------------------------------------------------------------- 1 | [Inline link 1 with parens](/url\(test\) "title"). 2 | 3 | [Inline link 2 with parens]( "title"). 4 | 5 | [Inline link 3 with non-escaped parens](/url(test) "title"). 6 | 7 | [Inline link 4 with non-escaped parens]( "title"). 8 | 9 | [Reference link 1 with parens][1]. 10 | 11 | [Reference link 2 with parens][2]. 12 | 13 | [1]: /url(test) "title" 14 | [2]: "title" 15 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/MultipleBlankLines.markdown: -------------------------------------------------------------------------------- 1 | 1. First Item 2 | 3 | * one 4 | * two 5 | 6 | * one 7 | * two 8 | 9 | 1. Second Item 10 | 11 | * one 12 | * two 13 | 14 | 15 | * one 16 | * two 17 | 18 | 1. Third Item 19 | 20 | * one 21 | * two 22 | 23 | 24 | 25 | * one 26 | * two 27 | 28 | 1. Fourth Item 29 | 30 | * one 31 | * two 32 | 33 | 34 | 35 | 36 | * one 37 | * two 38 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.17/AllSyntax/OldKeywords.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.OldKeywords exposing (OldKeywords, deriving, foreign, hiding) 2 | 3 | 4 | type alias OldKeywords = 5 | { foreign : Int 6 | , hiding : Bool 7 | , deriving : String 8 | } 9 | 10 | 11 | foreign : Float 12 | foreign = 13 | 0 14 | 15 | 16 | hiding : Int -> Int 17 | hiding x = 18 | x + 1 19 | 20 | 21 | deriving : Maybe OldKeywords 22 | deriving = 23 | Nothing 24 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/OldKeywords.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.OldKeywords exposing (OldKeywords, deriving, foreign, hiding) 2 | 3 | 4 | type alias OldKeywords = 5 | { foreign : Int 6 | , hiding : Bool 7 | , deriving : String 8 | } 9 | 10 | 11 | foreign : Float 12 | foreign = 13 | 0 14 | 15 | 16 | hiding : Int -> Int 17 | hiding x = 18 | x + 1 19 | 20 | 21 | deriving : Maybe OldKeywords 22 | deriving = 23 | Nothing 24 | -------------------------------------------------------------------------------- /dev/Documentation/Build Commands.md: -------------------------------------------------------------------------------- 1 | 2 | - `dev/build.sh`: build and run tests 3 | - `dev/build.sh build`: build a local binary to `./_build/elm-format` 4 | - `dev/build.sh ci`: run all build targets that are checked on CI 5 | - `dev/build.sh coverage`: write coverage report to `_coverage/*/*.txt` 6 | - `dev/build.sh serve:docs`: start a local HTTP server with the public Haskell API docs 7 | - `dev/build.sh serve:coverage`: start a local HTTP server with code coverage reports 8 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Misc/BackslashEscapes.html: -------------------------------------------------------------------------------- 1 |

*not emphasized* 2 | \emphasis 3 | **not bold** 4 | <br/> not a tag 5 | [link](/foo) not a link 6 | link 7 | `not code`

8 |

1. not a list item

9 |

* not a list.

10 |

# Not a header

11 |

[foo]: /url "not a reference"

12 |

$ ^ ; can be escaped. 13 | \a \b \T cannot. 14 | unicode letters and symbols cannot: \π \‥.

15 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.19/GLShader.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.GLShader exposing (vertexShader) 2 | 3 | 4 | vertexShader : Shader { position : Vec3, coord : Vec3 } { u | view : Mat4 } { vcoord : Vec2 } 5 | vertexShader = 6 | [glsl| 7 | 8 | attribute vec3 position; 9 | attribute vec3 coord; 10 | uniform mat4 view; 11 | varying vec2 vcoord; 12 | 13 | void main () { 14 | gl_Position = view * vec4(position, 1.0); 15 | vcoord = coord.xy; 16 | } 17 | 18 | |] 19 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/MissingImportParens.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (x) 2 | 3 | import Import.As1 as ImportAs1 4 | import Import.As2 as ImportAs2 exposing (A) 5 | import ImportDotDot exposing (..) 6 | import ImportName exposing (A) 7 | import ImportNames exposing (A, B, x, y) 8 | import ImportNamesLineBreak exposing (A, B) 9 | import MergeImport exposing (A, B, Z) 10 | import OtherImport exposing (A(X, Y), b, z) 11 | 12 | 13 | x = 14 | () 15 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/BlankLines.html: -------------------------------------------------------------------------------- 1 |
foo
 2 | 
 3 | 
 4 | 
 5 | bar
 6 | 
7 |
8 |
foo
 9 | 
10 | 
11 | 
12 | bar
13 | 
14 |
15 |
foo
16 | 
17 |     
18 | 
19 | bar
20 | 
21 |
    22 |
  1. One

    23 |
    CodeA
    24 | 
    25 | CodeB
    26 | 
  2. 27 |
  3. Two

    28 |
    CodeA
    29 | 
  4. 30 |
31 |
    32 |
  1. One
  2. 33 |
34 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Misc/Transitions.html: -------------------------------------------------------------------------------- 1 |
2 |

blockquote

3 |
4 |

blockquote

5 |
6 |
7 |
    8 |
  1. list
  2. 9 |
  3. list 10 |
      11 |
    • sublist
    • 12 |
  4. 13 |
14 |
15 |

paragraph

16 |

header

17 |

header

18 |
code
19 | 
20 |
code
21 | 
22 |
23 |
24 | # not a header 25 |
26 |
27 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/GLShader.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.GLShader exposing (vertexShader) 2 | 3 | 4 | vertexShader : Shader { position : Vec3, coord : Vec3 } { u | view : Mat4 } { vcoord : Vec2 } 5 | vertexShader = 6 | [glsl| 7 | 8 | attribute vec3 position; 9 | attribute vec3 coord; 10 | uniform mat4 view; 11 | varying vec2 vcoord; 12 | 13 | void main () { 14 | gl_Position = view * vec4(position, 1.0); 15 | vcoord = coord.xy; 16 | } 17 | 18 | |] 19 | -------------------------------------------------------------------------------- /parser/bench/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "Benchmarking based on benchmark.js", 4 | "repository": "https://github.com/JoeyEremondi/elm-benchmark.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "src" 8 | ], 9 | "exposed-modules": [], 10 | "native-modules": true, 11 | "dependencies": { 12 | "elm-lang/core": "2.1.0 <= v < 3.0.0" 13 | }, 14 | "elm-version": "0.15.1 <= v < 0.16.0" 15 | } 16 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/DocCommentAtDocs.elm: -------------------------------------------------------------------------------- 1 | module DocCommentAtDocs exposing (x, y, z, T(..)) 2 | 3 | {-| 4 | 5 | @docs 6 | x, 7 | y, 8 | z 9 | @docs T(..) 10 | 11 | @docs a , b , c 12 | @docs d 13 | 14 | Paragraph 15 | @docs startABlock, 16 | moreDocs 17 | 18 | -} 19 | 20 | 21 | {-| X 22 | -} 23 | x : () 24 | x = 25 | () 26 | 27 | 28 | {-| Y 29 | -} 30 | y : () 31 | y = 32 | () 33 | 34 | 35 | {-| Z 36 | -} 37 | z : () 38 | z = 39 | () 40 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/IndentedCodeBlocks.markdown: -------------------------------------------------------------------------------- 1 | Indented code with two space indent in first and last line: 2 | 3 | two spaces *hello* 4 | { more } 5 | 6 | and 7 | 8 | Indented code requires a leading/trailing blank line: 9 | quick-command --option "$*" 10 | 11 | Indented code does not require a trailing blank line: 12 | 13 | code 14 | and not code. 15 | 16 | Code in blockquote: 17 | 18 | > code 19 | 20 | Code in list: 21 | 22 | 1. code 23 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/IndentedInLists.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • code starts here
     3 | 
  • 4 |
5 |
    6 |
  1. foo

    7 |
    code starts here
     8 | 
  2. 9 |
  3. foo

    10 |
    code starts here
    11 | 
  4. 12 |
13 |
    14 |
  • foo

    15 |
    code starts here
    16 | 
    17 |
      18 |
    • foo

      19 |
      code starts here
      20 | 
    • 21 |
  • 22 |
23 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/AutoLinks.html: -------------------------------------------------------------------------------- 1 |

http://google.com?query=blah&time=15 2 | someone.else@somedomain.com 3 | ftp://old.ftp.server.edu 4 | git://some.git.repo/project.git 5 | <not autolink> 6 | <http://not.an autolink> 7 | <relative/not/autolink>

8 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/MissingImportParens.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (x) 2 | 3 | import OtherImport exposing (A(X, Y), b, z) 4 | import Import.As1 as ImportAs1 5 | import Import.As2 as ImportAs2 exposing A 6 | import ImportDotDot exposing .. 7 | import ImportName exposing A 8 | import ImportNames exposing A, B, x, y 9 | import ImportNamesLineBreak exposing 10 | A, B 11 | import MergeImport exposing (Z) 12 | import MergeImport exposing A, B 13 | 14 | 15 | x = 16 | () 17 | -------------------------------------------------------------------------------- /.github/actions/cache-haskell-deps/action.yml: -------------------------------------------------------------------------------- 1 | inputs: 2 | cabal-store: 3 | required: false 4 | default: ~/.cabal/store 5 | runs: 6 | using: "composite" 7 | steps: 8 | - name: Cache ~/.cabal/store 9 | uses: actions/cache@v3 10 | with: 11 | path: ${{ inputs.cabal-store }} 12 | key: cabal-v3-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cabal.project.freeze') }} 13 | restore-keys: | 14 | cabal-v3-${{ runner.os }}-${{ runner.arch }}- 15 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/TightAndLoose.markdown: -------------------------------------------------------------------------------- 1 | 1. tight 2 | 3 | 4 | - tight 5 | - list 6 | 7 | 8 | - loose 9 | 10 | - list 11 | 12 | 13 | 1. tight 14 | 2. list 15 | 16 | 17 | 1. loose 18 | 19 | 2. list 20 | 21 | 22 | 1. loose 23 | 24 | - sublist 25 | 26 | 27 | 28 | 1. tight 29 | - sublist 30 | 31 | 32 | - tight 33 | > blockquote 34 | and 35 | ``` 36 | code 37 | ``` 38 | - tight 39 | 40 | 41 | - loose 42 | - with loose 43 | 44 | - sublist 45 | - loose 46 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Inline_HTML_Advanced.html: -------------------------------------------------------------------------------- 1 |

Simple block on one line:

2 |
foo
3 |

And nested without indentation:

4 |
5 |
6 |
7 | foo 8 |
9 |
10 |
11 |
bar
12 |
13 |

And with attributes:

14 |
15 |
16 |
17 |
18 |

This was broken in 1.0.2b7:

19 |
20 |
21 | foo 22 |
23 |
24 | -------------------------------------------------------------------------------- /tests/test-files/CommonMark/RELEASE_CHECKLIST.md: -------------------------------------------------------------------------------- 1 | Release checklist 2 | 3 | _ update changelog.txt 4 | _ update version in package.json 5 | _ tag release 6 | _ git push 7 | _ git push --tags 8 | _ npm publish 9 | _ update dingus: 10 | 11 | cd ../commonmark.js 12 | cd dingus 13 | make 14 | 15 | _ update site: 16 | 17 | cd ../../CommonMark-site 18 | make update 19 | make 20 | make upload 21 | 22 | _ update babelmark2: copy commonmark.js to src/babelmark2/js on server 23 | -------------------------------------------------------------------------------- /Shakefile/src/Shakefiles/Extra.hs: -------------------------------------------------------------------------------- 1 | module Shakefiles.Extra (phonyPrefix, forEach) where 2 | 3 | import Development.Shake 4 | import Data.List (stripPrefix) 5 | 6 | 7 | phonyPrefix :: String -> (String -> Action ()) -> Rules () 8 | phonyPrefix prefix action = 9 | phonys $ \s -> case stripPrefix prefix s of 10 | Nothing -> Nothing 11 | Just match -> Just (action match) 12 | 13 | 14 | 15 | forEach :: Monad m => [a] -> (a -> m ()) -> m () 16 | forEach list f = 17 | mapM_ f list 18 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Misc/LineBreaks.markdown: -------------------------------------------------------------------------------- 1 | Two spaces 2 | break a line. Or more than two 3 | and spaces in the following line are absorbed. 4 | 5 | You can also break lines with\ 6 | a backslash. 7 | 8 | Two spaces at the end of a paragraph are 9 | not a line break. 10 | 11 | A backslash at the end of a paragraph is 12 | not a line break.\ 13 | 14 | Similarly with setext headers 15 | ------------------------------- 16 | 17 | And with backslashes\ 18 | --------------------- 19 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Inline_HTML_Advanced.markdown: -------------------------------------------------------------------------------- 1 | Simple block on one line: 2 | 3 |
foo
4 | 5 | And nested without indentation: 6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | 17 | And with attributes: 18 | 19 |
20 |
21 |
22 |
23 | 24 | This was broken in 1.0.2b7: 25 | 26 |
27 |
28 | foo 29 |
30 |
31 | -------------------------------------------------------------------------------- /Style Guide/Declarations.md: -------------------------------------------------------------------------------- 1 | # Declarations 2 | 3 | 4 | 5 | 6 | ## Infix operators 7 | 8 | Avoid infix operators when possible and prefer using named functions. 9 | 10 | Infix operator declartions should prefer the following ordering: 11 | documentation comment, 12 | infix properties (if not the default), 13 | type annotation, 14 | definition. 15 | 16 | ```elm 17 | {-| Documentation 18 | -} 19 | infixr 5 ::? 20 | (::?) : Maybe a -> List a -> List a 21 | (::?) elem list = 22 | list 23 | ``` 24 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.17/WorkaroundNegativeCasePatterns.elm: -------------------------------------------------------------------------------- 1 | module MinusErr exposing (errFloats, errInts) 2 | 3 | 4 | errInts : Int -> Int 5 | errInts x = 6 | case x of 7 | (-1) -> 8 | 0 9 | 10 | (-2) -> 11 | 0 12 | 13 | _ -> 14 | 1 15 | 16 | 17 | errFloats : Float -> Float 18 | errFloats x = 19 | case x of 20 | (-1.0) -> 21 | 0 22 | 23 | (-2.1) -> 24 | 0 25 | 26 | _ -> 27 | 1 28 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/WorkaroundNegativeCasePatterns.elm: -------------------------------------------------------------------------------- 1 | module MinusErr exposing (errFloats, errInts) 2 | 3 | 4 | errInts : Int -> Int 5 | errInts x = 6 | case x of 7 | (-1) -> 8 | 0 9 | 10 | (-2) -> 11 | 0 12 | 13 | _ -> 14 | 1 15 | 16 | 17 | errFloats : Float -> Float 18 | errFloats x = 19 | case x of 20 | (-1.0) -> 21 | 0 22 | 23 | (-2.1) -> 24 | 0 25 | 26 | _ -> 27 | 1 28 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.19/WorkaroundNegativeCasePatterns.elm: -------------------------------------------------------------------------------- 1 | module MinusErr exposing (errFloats, errInts) 2 | 3 | 4 | errInts : Int -> Int 5 | errInts x = 6 | case x of 7 | (-1) -> 8 | 0 9 | 10 | (-2) -> 11 | 0 12 | 13 | _ -> 14 | 1 15 | 16 | 17 | errFloats : Float -> Float 18 | errFloats x = 19 | case x of 20 | (-1.0) -> 21 | 0 22 | 23 | (-2.1) -> 24 | 0 25 | 26 | _ -> 27 | 1 28 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Links/ParensInURLs.html: -------------------------------------------------------------------------------- 1 |

Inline link 1 with parens.

2 |

Inline link 2 with parens.

3 |

Inline link 3 with non-escaped parens.

4 |

Inline link 4 with non-escaped parens.

5 |

Reference link 1 with parens.

6 |

Reference link 2 with parens.

7 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/DocCommentCodeExample.elm: -------------------------------------------------------------------------------- 1 | module DocCommentCodeExample exposing (f) 2 | 3 | {-| -} 4 | 5 | 6 | {-| Compute with f (indented code block) 7 | 8 | myValue = f 20 9 | -} 10 | f x = 11 | x * x 12 | 13 | 14 | {-| Compute with g (backticks code block) 15 | 16 | ``` 17 | myValue = g 99 18 | ``` 19 | -} 20 | g y = 21 | y + (4 * y) 22 | 23 | 24 | {-| Format expressions in code blocks 25 | 26 | h 20 --> 21 27 | 28 | h 21 --> 22 29 | 30 | -} 31 | h z = 32 | z + 1 33 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Amps_and_angle_encoding.markdown: -------------------------------------------------------------------------------- 1 | AT&T has an ampersand in their name. 2 | 3 | AT&T is another way to write it. 4 | 5 | This & that. 6 | 7 | 4 < 5. 8 | 9 | 6 > 5. 10 | 11 | Here's a [link] [1] with an ampersand in the URL. 12 | 13 | Here's a link with an amersand in the link text: [AT&T] [2]. 14 | 15 | Here's an inline [link](/script?foo=1&bar=2). 16 | 17 | Here's an inline [link](). 18 | 19 | 20 | [1]: http://example.com/?foo=1&bar=2 21 | [2]: http://att.com/ "AT&T" -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/ListBreakAfter.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • foo

    3 |
      4 |
    • bar

      5 |
      code1
       6 | code2
       7 | 
      8 |

      code?

    • 9 |
  • 10 |
  • foo

    11 |
      12 |
    • bar

      13 |
      code1
      14 | code2
      15 | 
    • 16 |
  • 17 |
18 |
code?
19 | 
20 |
    21 |
  • foo 22 |
      23 |
    • bar

      24 |
      code1
      25 | code2
      26 | 
    • 27 |
  • 28 |
29 |
code?
30 | 
31 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/DocCommentAtDocs.formatted.elm: -------------------------------------------------------------------------------- 1 | module DocCommentAtDocs exposing 2 | ( x 3 | , y 4 | , z 5 | , T(..) 6 | ) 7 | 8 | {-| 9 | 10 | @docs x 11 | @docs y 12 | @docs z 13 | @docs T 14 | 15 | @docs a, b, c 16 | @docs d 17 | 18 | Paragraph 19 | 20 | @docs startABlock 21 | @docs moreDocs 22 | 23 | -} 24 | 25 | 26 | {-| X 27 | -} 28 | x : () 29 | x = 30 | () 31 | 32 | 33 | {-| Y 34 | -} 35 | y : () 36 | y = 37 | () 38 | 39 | 40 | {-| Z 41 | -} 42 | z : () 43 | z = 44 | () 45 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Tabs.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • this is a list item 3 | indented with tabs

  • 4 |
  • this is a list item 5 | indented with spaces

  • 6 |
7 |

Code:

8 |
this code block is indented by one tab
 9 | 
10 |

And:

11 |
    this code block is indented by two tabs
12 | 
13 |

And:

14 |
+   this is an example list item
15 |     indented with tabs
16 | 
17 | +   this is an example list item
18 |     indented with spaces
19 | 
20 | -------------------------------------------------------------------------------- /tests/test-files/CommonMark/tools/spec2js.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var fs = require('fs'); 4 | var util = require('util'); 5 | 6 | fs.readFile('spec.txt', 'utf8', function(err, data) { 7 | if (err) { 8 | return console.log(err); 9 | } 10 | var examples = []; 11 | data.replace(/^\.\n([\s\S]*?)^\.\n([\s\S]*?)^\.$/gm, 12 | function(_,x,y){ 13 | examples.push({markdown: x, html: y}); 14 | }); 15 | console.log(util.inspect(examples, { depth: null })); 16 | console.warn(examples.length + ' examples'); 17 | }); 18 | -------------------------------------------------------------------------------- /package/win/wine.sh: -------------------------------------------------------------------------------- 1 | 2 | # brew install wine 3 | 4 | curl -O 'https://www.haskell.org/cabal/release/cabal-install-1.24.0.2/cabal-install-1.24.0.2-i386-unknown-mingw32.zip' 5 | curl -O 'http://downloads.haskell.org/~ghc/8.0.1/ghc-8.0.1-i386-unknown-mingw32.tar.xz' 6 | 7 | # unzip cabal, ghc 8 | 9 | function wine_cabal { 10 | wine cabal.exe --with-ghc=ghc-8.0.1/bin/ghc.exe 11 | } 12 | 13 | wine_cabal update 14 | wine_cabal install --only-dependencies 15 | wine_cabal build 16 | # wine_cabal install --enable-test --only-dependencies 17 | # wine_cabal test 18 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/DocCommentCodeExample.formatted.elm: -------------------------------------------------------------------------------- 1 | module DocCommentCodeExample exposing (f) 2 | 3 | {-| -} 4 | 5 | 6 | {-| Compute with f (indented code block) 7 | 8 | myValue = 9 | f 20 10 | 11 | -} 12 | f x = 13 | x * x 14 | 15 | 16 | {-| Compute with g (backticks code block) 17 | 18 | myValue = 19 | g 99 20 | 21 | -} 22 | g y = 23 | y + (4 * y) 24 | 25 | 26 | {-| Format expressions in code blocks 27 | 28 | h 20 --> 21 29 | 30 | h 21 --> 22 31 | 32 | -} 33 | h z = 34 | z + 1 35 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.19/InfixAsVariableName.elm: -------------------------------------------------------------------------------- 1 | module InfixAsVariableName exposing (..) 2 | 3 | {-| Despite being a keyword, "infix" is not a _reserved word_ in Elm 0.19, 4 | and is allowed as a variable name in expressions, type, and patterns. 5 | -} 6 | 7 | 8 | inExpression infix = 9 | infix + 1 10 | 11 | 12 | type InType infix 13 | = A infix 14 | 15 | 16 | {-| As top-level declaration 17 | -} 18 | infix x = 19 | () 20 | 21 | 22 | inLetDeclaration = 23 | let 24 | infix y = 25 | () 26 | in 27 | infix 28 | -------------------------------------------------------------------------------- /Release Notes/0.5.0-alpha.md: -------------------------------------------------------------------------------- 1 | Support for Elm 0.18: 2 | - Added the `--upgrade` option to help migration code from Elm 0.17 to Elm 0.18 3 | - Infix function calls using backticks become normal functions calls 4 | - Infix function calls using backticks with `andThen` and `onError` become pipelines 5 | - Ranges become calls to `List.range` 6 | - Primes in variable names become underscores 7 | - References to `fst` and `snd` become `Tuple.first` and `Tuple.second` 8 | 9 | Bug fixes: 10 | - Type tags starting with `True` and `False` are now handled correctly 11 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.19/ListDocumentedExportsNoExposing.formatted.elm: -------------------------------------------------------------------------------- 1 | module ListDocumentedExportsNoExposing exposing 2 | ( a 3 | , X 4 | , Y(..) 5 | , b, c 6 | ) 7 | 8 | {-| 9 | 10 | @docs a 11 | 12 | 13 | # Heading 14 | 15 | @docs X 16 | @docs Y 17 | @docs b, c 18 | 19 | -} 20 | 21 | 22 | type alias X = 23 | () 24 | 25 | 26 | type Y 27 | = Y1 28 | | Y2 29 | 30 | 31 | q = 32 | 4 33 | 34 | 35 | a = 36 | 1 37 | 38 | 39 | b = 40 | 2 41 | 42 | 43 | c = 44 | 3 45 | 46 | 47 | p = 48 | 5 49 | -------------------------------------------------------------------------------- /Shakefile/package.yaml: -------------------------------------------------------------------------------- 1 | name: build-elm-format 2 | version: 0.0.0 3 | build-type: Simple 4 | 5 | language: Haskell2010 6 | 7 | default-extensions: 8 | - LambdaCase 9 | 10 | ghc-options: 11 | - -rtsopts 12 | - -threaded 13 | - -with-rtsopts=-I0 14 | - -Werror=unused-packages 15 | 16 | dependencies: 17 | aeson: ">= 2.0.0.0" 18 | base: ">= 4.16.2.0" 19 | directory: ">= 1.3.6.2" 20 | shake: ">=0.19.6 && <0.20" 21 | relude: {} 22 | yaml: {} 23 | 24 | 25 | executables: 26 | build-elm-format: 27 | main: Main.hs 28 | source-dirs: 29 | - src 30 | -------------------------------------------------------------------------------- /nix/tools.nix: -------------------------------------------------------------------------------- 1 | { sources ? import ./sources.nix, compiler }: 2 | 3 | let 4 | haskellToolsOverrides = pkgs: self: super: { }; 5 | 6 | haskellToolsPkgs = import sources.nixpkgs { 7 | config = { 8 | packageOverrides = pkgs: { 9 | haskell = pkgs.haskell // { 10 | packages = pkgs.haskell.packages // { 11 | tools = pkgs.haskell.packages."${compiler}".override { 12 | overrides = haskellToolsOverrides pkgs; 13 | }; 14 | }; 15 | }; 16 | }; 17 | }; 18 | }; 19 | in haskellToolsPkgs.haskell.packages.tools 20 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Images.markdown: -------------------------------------------------------------------------------- 1 | ![Alt text](/path/to/img.jpg) 2 | 3 | ![Alt text](/path/to/img.jpg "Optional title") 4 | 5 | Inline within a paragraph: [alt text](/url/). 6 | 7 | ![alt text](/url/ "title preceded by two spaces") 8 | 9 | ![alt text](/url/ "title has spaces afterward" ) 10 | 11 | ![alt text]() 12 | 13 | ![alt text]( "with a title"). 14 | 15 | ![Empty]() 16 | 17 | ![this is a stupid URL](http://example.com/(parens).jpg) 18 | 19 | 20 | ![alt text][foo] 21 | 22 | [foo]: /url/ 23 | 24 | ![alt text][bar] 25 | 26 | [bar]: /url/ "Title here" -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.19/GLShader.json-roundtrip: -------------------------------------------------------------------------------- 1 | module AllSyntax.GLShader exposing (vertexShader) 2 | 3 | 4 | vertexShader : 5 | Shader 6 | { coord : Vec3 7 | , position : Vec3 8 | } 9 | { u 10 | | view : Mat4 11 | } 12 | { vcoord : Vec2 13 | } 14 | vertexShader = 15 | [glsl| 16 | 17 | attribute vec3 position; 18 | attribute vec3 coord; 19 | uniform mat4 view; 20 | varying vec2 vcoord; 21 | 22 | void main () { 23 | gl_Position = view * vec4(position, 1.0); 24 | vcoord = coord.xy; 25 | } 26 | 27 | |] 28 | -------------------------------------------------------------------------------- /Shakefile/src/Shakefiles/Signature.hs: -------------------------------------------------------------------------------- 1 | module Shakefiles.Signature (rules) where 2 | 3 | import Development.Shake 4 | import Development.Shake.Command 5 | import Development.Shake.FilePath 6 | import Development.Shake.Util 7 | import qualified System.Directory 8 | 9 | 10 | rules = do 11 | homeDir <- liftIO System.Directory.getHomeDirectory 12 | let keybaseConfig = homeDir ".config" "keybase" "config.json" 13 | 14 | "//*.asc" %> \out -> do 15 | let src = dropExtension out 16 | need [ src ] 17 | cmd_ "gpg" "--detach-sign" "--armor" "--output" out src 18 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.19/AllSyntax/InfixDeclaration.elm: -------------------------------------------------------------------------------- 1 | module InfixDeclaration exposing ((<<), (<|), (==)) 2 | 3 | -- INFIX OPERATORS 4 | 5 | 6 | infix right 0 (<|) = apL 7 | infix non 4 (==) = eq 8 | infix left 9 (<<) = composeL 9 | 10 | 11 | 12 | -- DEFINITIONS 13 | 14 | 15 | apL f x = 16 | f x 17 | 18 | 19 | eq _ _ = 20 | True 21 | 22 | 23 | composeL g f x = 24 | g (f x) 25 | 26 | 27 | 28 | -- declarations close to "infix" should still parse 29 | 30 | 31 | infi = 32 | () 33 | 34 | 35 | infiz = 36 | () 37 | 38 | 39 | infixy right = 40 | right 41 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Amps_and_angle_encoding.html: -------------------------------------------------------------------------------- 1 |

AT&T has an ampersand in their name.

2 |

AT&T is another way to write it.

3 |

This & that.

4 |

4 < 5.

5 |

6 > 5.

6 |

Here's a link with an ampersand in the URL.

7 |

Here's a link with an amersand in the link text: AT&T.

8 |

Here's an inline link.

9 |

Here's an inline link.

10 | -------------------------------------------------------------------------------- /parser/bench/src/SmallTupleBench.elm: -------------------------------------------------------------------------------- 1 | module SmallTupleBench where 2 | 3 | type alias SmallTuple = 4 | ( Float 5 | , Float 6 | , Float 7 | , Float 8 | , Float 9 | , Float 10 | , Float 11 | , Float 12 | , Float 13 | ) 14 | 15 | defaultTuple = 16 | (1.0, 2.0, 3.0) 17 | 18 | getField (x1, x2, x3) i = 19 | case (i % 3) of 20 | 1 -> 21 | x1 22 | 2 -> 23 | x2 24 | 0 -> 25 | x3 26 | 27 | 28 | sumRandomElems : List Int -> Float 29 | sumRandomElems randomInts = 30 | List.foldr (\i sumSoFar -> (getField defaultTuple i) + sumSoFar ) 0.0 randomInts -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/Comments.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.Comments exposing (blockComment, indentedMultilineBlockComment, multilineCommentTrickDisabled, nestedBlockComment) 2 | 3 | 4 | blockComment = 5 | {- A -} 6 | () 7 | 8 | 9 | nestedBlockComment = 10 | {- A {- {- C -} B {- D -} -} {- E -} -} 11 | () 12 | 13 | 14 | indentedMultilineBlockComment = 15 | {- A 16 | B 17 | C 18 | -} 19 | () 20 | 21 | 22 | {--} 23 | multilineCommentTrickDisabled = 24 | () 25 | --} 26 | 27 | 28 | 29 | {-- 30 | multilineCommentTrickEnabled = 31 | () 32 | --} 33 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/Examples.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (bar, multilineList, ratio) 2 | 3 | 4 | ratio = 5 | graphHeight 6 | / (if range == 0 then 7 | 0.1 8 | 9 | else 10 | toFloat range 11 | ) 12 | 13 | 14 | 15 | -- foo=(case x of {True->1;False->3}) 16 | 17 | 18 | bar = 19 | if 20 | if a then 21 | True 22 | 23 | else 24 | False 25 | then 26 | "a" 27 | 28 | else 29 | "b" 30 | 31 | 32 | multilineList = 33 | [ 1 34 | , 2 35 | , 3 36 | ] 37 | -------------------------------------------------------------------------------- /avh4-lib/src/Data/Coapplicative.hs: -------------------------------------------------------------------------------- 1 | module Data.Coapplicative (Coapplicative(..)) where 2 | 3 | import Data.Functor.Compose 4 | import Data.Functor.Identity 5 | 6 | 7 | class Functor f => Coapplicative f where 8 | extract :: f a -> a 9 | 10 | instance Coapplicative ((,) x) where 11 | extract (_, a) = a 12 | {-# INLINE extract #-} 13 | 14 | instance Coapplicative Identity where 15 | extract = runIdentity 16 | {-# INLINE extract #-} 17 | 18 | instance (Coapplicative a, Coapplicative b) => Coapplicative (Compose a b) where 19 | extract = extract . extract . getCompose 20 | {-# INLINE extract #-} 21 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Horizontal_rules.html: -------------------------------------------------------------------------------- 1 |

Dashes:

2 |
3 |
4 |
5 |
6 |
---
 7 | 
8 |
9 |
10 |
11 |
12 |
- - -
13 | 
14 |

Asterisks:

15 |
16 |
17 |
18 |
19 |
***
20 | 
21 |
22 |
23 |
24 |
25 |
* * *
26 | 
27 |

Underscores:

28 |
29 |
30 |
31 |
32 |
___
33 | 
34 |
35 |
36 |
37 |
38 |
_ _ _
39 | 
40 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/TightLooseBlockquote.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • tight I 3 |
    4 |

    bq

    5 |
  • 6 |
  • tight I
  • 7 |
8 |
    9 |
  • tight II 10 |
    11 |

    bq

    12 |
    13 | foo
  • 14 |
  • tight II
  • 15 |
16 |
    17 |
  1. Blank lines in bq don't break list 18 |
    19 |

    bq

    20 |
  2. 21 |
  3. Should say (2) in output
  4. 22 |
23 |
    24 |
  • Blank lines in bq don't break LI 25 |
      26 |
    • item A 27 |
      28 |

      bq

      29 |
    • 30 |
    • item B
    • 31 |
  • 32 |
33 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Auto_links.html: -------------------------------------------------------------------------------- 1 |

Link: http://example.com/.

2 |

With an ampersand: http://example.com/?foo=1&bar=2

3 | 8 |
9 |

Blockquoted: http://example.com/

10 |
11 |

Auto-links should not occur here: <http://example.com/>

12 |
or here: <http://example.com/>
13 | 
14 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/IndentedCodeBlocks.html: -------------------------------------------------------------------------------- 1 |

Indented code with two space indent in first and last line:

2 |
  two spaces *hello*
 3 | { more }
 4 | 
 5 |   and
 6 | 
7 |

Indented code requires a leading/trailing blank line: 8 | quick-command --option "$*"

9 |

Indented code does not require a trailing blank line:

10 |
code
11 | 
12 |

and not code.

13 |

Code in blockquote:

14 |
15 |
code
16 | 
17 |
18 |

Code in list:

19 |
    20 |
  1. code
    21 | 
  2. 22 |
23 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/DocCommentMarkdownSafety.elm: -------------------------------------------------------------------------------- 1 | module DocCommentMarkdownSafety exposing (x) 2 | 3 | {-| These are examples where the input markdown is unsafe (meaning it 4 | is parsed differently by some popular markdown implementations). 5 | 6 | We transform these cases to use markdown syntax that is more consistent 7 | across parsers. 8 | -} 9 | 10 | 11 | {-| Indented code after an indented list. 12 | 13 | - Item 1 14 | - Item 2 15 | 16 | 17 | myValue = f 20 18 | -} 19 | f x = 20 | x * x 21 | 22 | 23 | {-| Test 24 | 25 | - Item 1 26 | - Item 2 27 | 28 | 29 | Code ... 30 | -} 31 | x = () 32 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Blockquotes/Nesting.html: -------------------------------------------------------------------------------- 1 |

These are all equivalent:

2 |
3 |
4 |

nested 5 | blockquote

6 |
7 |
8 |
9 |
10 |

nested 11 | blockquote

12 |
13 |
14 |
15 |
16 |

nested 17 | blockquote

18 |
19 |
20 |
21 |
22 |

nested 23 | blockquote

24 |
25 |
26 |

This is not:

27 |
28 |

nested

29 |
30 |

blockquote

31 |
32 |
33 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Horizontal_rules.markdown: -------------------------------------------------------------------------------- 1 | Dashes: 2 | 3 | --- 4 | 5 | --- 6 | 7 | --- 8 | 9 | --- 10 | 11 | --- 12 | 13 | - - - 14 | 15 | - - - 16 | 17 | - - - 18 | 19 | - - - 20 | 21 | - - - 22 | 23 | 24 | Asterisks: 25 | 26 | *** 27 | 28 | *** 29 | 30 | *** 31 | 32 | *** 33 | 34 | *** 35 | 36 | * * * 37 | 38 | * * * 39 | 40 | * * * 41 | 42 | * * * 43 | 44 | * * * 45 | 46 | 47 | Underscores: 48 | 49 | ___ 50 | 51 | ___ 52 | 53 | ___ 54 | 55 | ___ 56 | 57 | ___ 58 | 59 | _ _ _ 60 | 61 | _ _ _ 62 | 63 | _ _ _ 64 | 65 | _ _ _ 66 | 67 | _ _ _ 68 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.19/AllSyntax/Module.json-roundtrip: -------------------------------------------------------------------------------- 1 | module AllSyntax.Module exposing (CustomType(..), a, b, c) 2 | 3 | import Dict as D exposing (Dict, empty, fromList) 4 | import Json.Decode as Json 5 | import Maybe exposing (Maybe(..), map) 6 | import Result exposing (Result(..)) 7 | import Signal exposing (..) 8 | import String 9 | import Task exposing (andMap, andThen, fail, fromMaybe, fromResult, map, map2, map3, map4, map5, mapError, onError, succeed, toMaybe, toResult) 10 | 11 | 12 | type CustomType 13 | = TagA 14 | | TagB 15 | 16 | 17 | a = 18 | 1 19 | 20 | 21 | b = 22 | 2 23 | 24 | 25 | c = 26 | 3 27 | -------------------------------------------------------------------------------- /tests/Test.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Test.Tasty 4 | import Test.Tasty.Hspec (testSpec) 5 | 6 | import qualified Test.Property 7 | -- import qualified CommonMarkTests 8 | import qualified Integration.CliTest 9 | import qualified Integration.LiteralTest 10 | 11 | 12 | main :: IO () 13 | main = 14 | do 15 | -- markdownTests <- CommonMarkTests.construct 16 | spec <- testSpec "" Integration.CliTest.spec_spec 17 | defaultMain $ testGroup "elm-format" $ 18 | [ Test.Property.propertyTests 19 | , spec 20 | , Integration.LiteralTest.tests 21 | -- , markdownTests 22 | ] 23 | -------------------------------------------------------------------------------- /.github/actions/cache-build/action.yml: -------------------------------------------------------------------------------- 1 | runs: 2 | using: "composite" 3 | steps: 4 | - name: Cache .shake.cache 5 | uses: actions/cache@v3 6 | with: 7 | path: .shake.cache 8 | key: shake-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }} 9 | restore-keys: | 10 | shake-v1-${{ runner.os }}-${{ runner.arch }}- 11 | - name: Cache dist-newstyle 12 | uses: actions/cache@v3 13 | with: 14 | path: dist-newstyle 15 | key: cabal-dist-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }} 16 | restore-keys: | 17 | cabal-dist-v1-${{ runner.os }}-${{ runner.arch }}- 18 | -------------------------------------------------------------------------------- /tests/test-files/from-json/Elm-0.19/ModuleComments.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleName": "ModuleComments", 3 | "body": [ 4 | { 5 | "tag": "Comment", 6 | "text": " Default comment" 7 | }, 8 | { 9 | "tag": "Comment", 10 | "text": "Block comment", 11 | "display": { 12 | "commentType": "BlockComment" 13 | } 14 | }, 15 | { 16 | "tag": "Definition", 17 | "name": "f", 18 | "parameters": [], 19 | "expression": { 20 | "tag": "UnitLiteral" 21 | } 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /avh4-lib/src/Data/Either/Extra.hs: -------------------------------------------------------------------------------- 1 | module Data.Either.Extra (collectErrors) where 2 | 3 | import Prelude () 4 | import Relude 5 | 6 | 7 | collectErrors :: [Either l r] -> Either [l] [r] 8 | collectErrors list = 9 | let 10 | step acc next = 11 | case (next, acc) of 12 | (Left l, Right _) -> 13 | Left [l] 14 | 15 | (Left l, Left ls) -> 16 | Left (l : ls) 17 | 18 | (Right r, Right rs) -> 19 | Right (r : rs) 20 | 21 | (Right _, Left ls) -> 22 | Left ls 23 | in 24 | foldl' step (Right []) list 25 | -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | 2 | tasks: 3 | - before: | 4 | export GHCUP_INSTALL_BASE_PREFIX=/workspace/.ghcup 5 | export CABAL_DIR=/workspace/.cabal 6 | source "$GHCUP_INSTALL_BASE_PREFIX/.ghcup/env" || true 7 | init: | 8 | curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_MINIMAL=1 sh 9 | source "$GHCUP_INSTALL_BASE_PREFIX/.ghcup/env" 10 | ghcup install ghc 9.6.7 11 | ghcup set ghc 9.6.7 12 | ghcup install cabal 13 | cabal update 14 | ./dev/build.sh 15 | command: ./_build/elm-format 16 | 17 | vscode: 18 | extensions: 19 | - haskell.haskell 20 | -------------------------------------------------------------------------------- /.github/workflows/Touch cache.yml: -------------------------------------------------------------------------------- 1 | name: Touch cache 2 | 3 | on: 4 | schedule: 5 | - cron: "16 11 * * 3,6" 6 | 7 | defaults: 8 | run: 9 | shell: bash 10 | 11 | jobs: 12 | build: 13 | strategy: 14 | matrix: 15 | os: 16 | - ubuntu-latest 17 | - windows-latest 18 | # - macOS-latest 19 | 20 | name: touch-cache-${{ matrix.os }} 21 | runs-on: ${{ matrix.os }} 22 | 23 | steps: 24 | - name: Configure environment 25 | run: | 26 | git config --global core.autocrlf false 27 | - uses: actions/checkout@v3 28 | - uses: ./.github/actions/cache-haskell-deps 29 | - uses: ./.github/actions/cache-build 30 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/Sublists.html: -------------------------------------------------------------------------------- 1 |

Four levels:

2 |
    3 |
  • one 4 |
      5 |
    • two 6 |
        7 |
      • three 8 |
          9 |
        • four
        • 10 |
      • 11 |
    • 12 |
  • 13 |
14 |
    15 |
  1. one 16 |
      17 |
    1. two 18 |
        19 |
      1. three 20 |
          21 |
        1. four
        2. 22 |
      2. 23 |
    2. 24 |
  2. 25 |
26 |
    27 |
  1. one 28 |
      29 |
    • two 30 |
        31 |
      1. three 32 |
          33 |
        • four
        • 34 |
      2. 35 |
    • 36 |
  2. 37 |
38 |
    39 |
  • one 40 |
      41 |
    • two 42 |
        43 |
      1. three 44 |
          45 |
        1. four
        2. 46 |
      2. 47 |
    • 48 |
  • 49 |
50 | -------------------------------------------------------------------------------- /package/npm/platform-info.nix: -------------------------------------------------------------------------------- 1 | { 2 | linux-x64 = { 3 | npm = { 4 | os = "linux"; 5 | cpu = "x64"; 6 | }; 7 | binExt = ""; 8 | }; 9 | linux-aarch64 = { 10 | npm = { 11 | os = "linux"; 12 | cpu = "arm64"; 13 | }; 14 | binExt = ""; 15 | }; 16 | mac-x64 = { 17 | npm = { 18 | os = "darwin"; 19 | cpu = "x64"; 20 | }; 21 | binExt = ""; 22 | }; 23 | mac-arm64 = { 24 | npm = { 25 | os = "darwin"; 26 | cpu = "arm64"; 27 | }; 28 | binExt = ""; 29 | }; 30 | win-x64 = { 31 | npm = { 32 | os = "win32"; 33 | cpu = "x64"; 34 | }; 35 | binExt = ".exe"; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /tests/test-files/good/json/ExternalReferences.elm: -------------------------------------------------------------------------------- 1 | module ExternalReferences exposing (..) 2 | 3 | import Date exposing (Month(..)) 4 | import Foo.Bar as Bar 5 | import Foo.Baz exposing (..) 6 | import Html 7 | import Html.Attributes as Attr 8 | import Html.Events as Event exposing (onClick) 9 | 10 | 11 | token : String 12 | token = 13 | "XYZZY" 14 | 15 | 16 | theBestClass : Attr.Attribute msg 17 | theBestClass = 18 | Attr.class token 19 | 20 | 21 | text : String -> Html msg 22 | text = 23 | Html.text 24 | 25 | 26 | main : Html msg 27 | main = 28 | Html.div 29 | [ theBestClass ] 30 | [ Html.text token 31 | , Html.text <| toString -pi 32 | ] 33 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/DocCommentMarkdownSafety.formatted.elm: -------------------------------------------------------------------------------- 1 | module DocCommentMarkdownSafety exposing (x) 2 | 3 | {-| These are examples where the input markdown is unsafe (meaning it 4 | is parsed differently by some popular markdown implementations). 5 | 6 | We transform these cases to use markdown syntax that is more consistent 7 | across parsers. 8 | 9 | -} 10 | 11 | 12 | {-| Indented code after an indented list. 13 | 14 | - Item 1 15 | - Item 2 16 | 17 | ``` 18 | myValue = 19 | f 20 20 | ``` 21 | 22 | -} 23 | f x = 24 | x * x 25 | 26 | 27 | {-| Test 28 | 29 | - Item 1 30 | - Item 2 31 | 32 | ``` 33 | Code ... 34 | ``` 35 | 36 | -} 37 | x = 38 | () 39 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/Sorting.formatted.elm: -------------------------------------------------------------------------------- 1 | module Sorting exposing (x) 2 | 3 | import ConstructorTagsAreDeduplicated exposing (A(X)) 4 | import ConstructorTagsAreMerged exposing (A(C, D, X, Y), B(..), C(..)) 5 | import ConstructorTagsAreSorted exposing (A(X, XYzZY, Y, Yy, Z)) 6 | import ExposedValuesAreDeduplicated exposing ((==/==), Z(..), x) 7 | import ExposedValuesAreSorted exposing ((<>), (==/==), Y, Z(..), a, x) 8 | import ImportsAreMerged exposing (A(X, Y), b, z) 9 | import ImportsAreMerged2 exposing (..) 10 | import ImportsAreMerged3 exposing (..) 11 | import ImportsWithConflictingAs as Correct 12 | import ImportsWithConflictingAs2 as Correct 13 | 14 | 15 | x = 16 | () 17 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/BlockComments/Types.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.BlockComments.Types exposing (emptyRecord, record, recordExtension) 2 | 3 | 4 | emptyRecord : {{- M -}} -> () 5 | emptyRecord _ = 6 | () 7 | 8 | 9 | record : 10 | { {- N -} x {- O -} : {- P -} Int 11 | 12 | {- Q -} 13 | , {- R -} y {- S -} : {- T -} () 14 | 15 | {- U -} 16 | } 17 | -> () 18 | record _ = 19 | () 20 | 21 | 22 | recordExtension : 23 | { {- V -} a {- W -} 24 | | {- X -} x {- Y -} : {- Z -} Int 25 | 26 | {- AA -} 27 | , {- AB -} y {- AC -} : {- AD -} Int 28 | 29 | {- AE -} 30 | } 31 | -> () 32 | recordExtension _ = 33 | () 34 | -------------------------------------------------------------------------------- /elm-format-lib/src/Parse/Markdown.hs: -------------------------------------------------------------------------------- 1 | module Parse.Markdown (parse) where 2 | 3 | import qualified Cheapskate.Parse 4 | import qualified Cheapskate.Types as Markdown 5 | import qualified Data.Text as Text 6 | import Elm.Utils ((|>)) 7 | 8 | 9 | parse :: String -> Markdown.Blocks 10 | parse source = 11 | source 12 | |> Text.pack 13 | |> Cheapskate.Parse.markdown 14 | (Markdown.Options 15 | { Markdown.sanitize = True 16 | , Markdown.allowRawHtml = True 17 | , Markdown.preserveHardBreaks = True 18 | , Markdown.debug = False 19 | } 20 | ) 21 | |> (\(Markdown.Doc _ source) -> source) 22 | -------------------------------------------------------------------------------- /elm-format-lib/test/Parse/TestHelpersTest.hs: -------------------------------------------------------------------------------- 1 | module Parse.TestHelpersTest where 2 | 3 | import Test.Tasty 4 | import Test.Tasty.HUnit 5 | 6 | import Parse.TestHelpers 7 | 8 | 9 | 10 | test_tests :: TestTree 11 | test_tests = 12 | testGroup "TestHelpers" 13 | [ testGroup "generateReplacements" 14 | [ testCase "empty" $ 15 | assertEqual "" [] $ generateReplacements "a" "b" "" 16 | , testCase "single match" $ 17 | assertEqual "" ["1b2"] $ generateReplacements "a" "b" "1a2" 18 | , testCase "multiple matches" $ 19 | assertEqual "" ["b1a2a3a", "a1b2a3a", "a1a2b3a", "a1a2a3b"] $ generateReplacements "a" "b" "a1a2a3a" 20 | ] 21 | ] 22 | -------------------------------------------------------------------------------- /Shakefile/src/Shakefiles/ListFiles.hs: -------------------------------------------------------------------------------- 1 | module Shakefiles.ListFiles where 2 | 3 | import Development.Shake 4 | import Shakefiles.Prelude 5 | import Development.Shake.FilePath 6 | 7 | 8 | read :: FilePath -> String -> Action [FilePath] 9 | read baseDir ext = 10 | readFileLines ("_build/list-files" baseDir ext <.> "txt") 11 | 12 | 13 | rules :: Rules () 14 | rules = do 15 | "_build/list-files//*.txt" %> \out -> do 16 | alwaysRerun 17 | let baseDir = nTimes 2 dropDirectory1 $ dropFileName out 18 | let ext = dropExtension $ takeFileName out 19 | files <- getDirectoryFiles "" 20 | [ baseDir <> "//*." <> ext ] 21 | writeFileChanged out (unlines files) 22 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/README: -------------------------------------------------------------------------------- 1 | These are from John Gruber's original markdown test suite, via 2 | Michel Fortin's mdtest. 3 | 4 | The html files have been modified slightly in ways that do not affect the 5 | semantics. For example, entities are used for quotes in text, and 6 | blank lines are omitted between block-level tags. 7 | 8 | Trailing blank spaces are removed from lines in raw HTML blocks. 9 | 10 | The one (insignificant) semantic change is switching the order 11 | of emph and strong tags in the output for ***strong and emph***. 12 | 13 | We have removed Hard-wrapped_paragraphs_with_list-like_lines tests, 14 | because the new implementation no longer requires a blank line 15 | before a list. 16 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.16/AllSyntax/PatternsRequireParens.elm: -------------------------------------------------------------------------------- 1 | module Main (..) where 2 | 3 | 4 | patternWithQualifiedConstructorAsCosntructorArgument m = 5 | case m of 6 | Maybe.Just (Maybe.Nothing) -> 7 | () 8 | 9 | Maybe.Just _ -> 10 | () 11 | 12 | Maybe.Nothing -> 13 | () 14 | 15 | 16 | patternWithUnqualifiedConstructorAsCosntructorArgument m = 17 | case m of 18 | Maybe.Just Nothing -> 19 | () 20 | 21 | (Just _) as x -> 22 | () 23 | 24 | Nothing as x -> 25 | () 26 | 27 | ((Maybe.Nothing) as y) as x -> 28 | () 29 | 30 | _ -> 31 | () 32 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/TrueFalseInIdentifiers.elm: -------------------------------------------------------------------------------- 1 | module Test exposing (ExpressionType(..), expressionTypes, typename) 2 | 3 | 4 | type ExpressionType 5 | = TrueType 6 | | FalseType 7 | | NotType 8 | | AndType 9 | | OrType 10 | 11 | 12 | expressionTypes = 13 | [ TrueType, FalseType, NotType, AndType, OrType ] 14 | 15 | 16 | typename : ExpressionType -> String 17 | typename expressionType = 18 | case expressionType of 19 | TrueType -> 20 | "True" 21 | 22 | FalseType -> 23 | "False" 24 | 25 | NotType -> 26 | "Not" 27 | 28 | AndType -> 29 | "And" 30 | 31 | OrType -> 32 | "Or" 33 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Emphasis/Punctuation.html: -------------------------------------------------------------------------------- 1 |

Here is a _ that is cool.

2 |

Foo.

3 |

Foo.

4 |

Foo.

5 |

Foo.

6 |

Foo.

7 |

Foo.

8 |

Foo. Foo? Foo! Foo: Foo; (Foo)

9 |

Foo. Foo? Foo! Foo: Foo; (Foo)

10 |

Foo. Foo? Foo! Foo: Foo; (Foo)

11 | -------------------------------------------------------------------------------- /avh4-lib/src/Data/ReversedList.hs: -------------------------------------------------------------------------------- 1 | module Data.ReversedList where 2 | 3 | {-| 4 | ReversedList can be used to avoid accidentally forgetting to reverse a list 5 | (this most commonly occurs when implementing recursive algorithms that build up a 6 | list that needs to be reversed in the termination case). 7 | -} 8 | 9 | newtype Reversed a = Reversed [a] 10 | 11 | 12 | empty :: Reversed a 13 | empty = 14 | Reversed [] 15 | 16 | 17 | push :: a -> Reversed a -> Reversed a 18 | push a (Reversed list) = 19 | Reversed (a : list) 20 | 21 | 22 | isEmpty :: Reversed a -> Bool 23 | isEmpty (Reversed []) = True 24 | isEmpty _ = False 25 | 26 | 27 | toList :: Reversed a -> [a] 28 | toList (Reversed list) = 29 | reverse list 30 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Links_inline_style.markdown: -------------------------------------------------------------------------------- 1 | Just a [URL](/url/). 2 | 3 | [URL and title](/url/ "title"). 4 | 5 | [URL and title](/url/ "title preceded by two spaces"). 6 | 7 | [URL and title](/url/ "title preceded by a tab"). 8 | 9 | [URL and title](/url/ "title has spaces afterward" ). 10 | 11 | [URL wrapped in angle brackets](). 12 | 13 | [URL w/ angle brackets + title]( "Here's the title"). 14 | 15 | [Empty](). 16 | 17 | [With parens in the URL](http://en.wikipedia.org/wiki/WIMP_(computing)) 18 | 19 | (With outer parens and [parens in url](/foo(bar))) 20 | 21 | 22 | [With parens in the URL](/foo(bar) "and a title") 23 | 24 | (With outer parens and [parens in url](/foo(bar) "and a title")) 25 | -------------------------------------------------------------------------------- /tests/test-files/CommonMark/Makefile: -------------------------------------------------------------------------------- 1 | SITE=_site 2 | SPECVERSION=$(shell perl -ne 'print $$1 if /^version: *([0-9.]+)/' spec.txt) 3 | 4 | .PHONY: all clean npm 5 | 6 | all: spec.html # spec.pdf spec.md 7 | 8 | spec.md: spec.txt tools/template.commonmark 9 | lua tools/make_spec.lua commonmark < $< > $@ 10 | 11 | spec.html: spec.txt tools/template.html 12 | lua tools/make_spec.lua html < $< > $@ 13 | 14 | spec.tex: spec.txt tools/template.latex 15 | lua tools/make_spec.lua latex < $< > $@ 16 | 17 | spec.pdf: spec.tex 18 | xelatex $< 19 | 20 | npm: 21 | # Do a sanity check first on versions 22 | grep -q '"version": *"$(SPECVERSION)' package.json && \ 23 | npm publish 24 | 25 | clean: 26 | -rm spec.tex spec.md spec.html 27 | -------------------------------------------------------------------------------- /tests/test-files/from-json/Elm-0.19/Patterns.elm: -------------------------------------------------------------------------------- 1 | module Patterns exposing (alias, closedList, data, emptyList, emptyRecord, literals, openList, record, tuple, unit, variables, wildcard) 2 | 3 | 4 | wildcard _ = 5 | () 6 | 7 | 8 | literals 1 2.0 "string" 'c' = 9 | () 10 | 11 | 12 | variables x = 13 | () 14 | 15 | 16 | data (Foo _ _) (Maybe.Just _ _) = 17 | () 18 | 19 | 20 | unit () = 21 | () 22 | 23 | 24 | tuple ( _, _ ) = 25 | () 26 | 27 | 28 | emptyList [] = 29 | () 30 | 31 | 32 | closedList [ _, _ ] = 33 | () 34 | 35 | 36 | openList (_ :: _ :: _) = 37 | () 38 | 39 | 40 | emptyRecord {} = 41 | () 42 | 43 | 44 | record { x, y } = 45 | () 46 | 47 | 48 | alias (_ as x) = 49 | () 50 | -------------------------------------------------------------------------------- /Style Guide/Sections.md: -------------------------------------------------------------------------------- 1 | # Sections and grouping 2 | 3 | Comments (`--`, `{- -}`) can be used to create sections within your code. 4 | 5 | 6 | ## Top-level sections 7 | 8 | ```elm 9 | x = 10 | () 11 | 12 | 13 | 14 | -- This comment introduces a new section 15 | 16 | 17 | a = 18 | () 19 | ``` 20 | 21 | 22 | ## Data structure sections 23 | 24 | ### List expressions 25 | 26 | ```elm 27 | x = 28 | [ 1 29 | , 2 30 | 31 | -- This comment introduces a section in the list 32 | , 3 33 | , 4 34 | ] 35 | ``` 36 | 37 | ### Record expressions 38 | 39 | ```elm 40 | x = 41 | { x = 1 42 | , y = 2 43 | 44 | -- This comment introduces a section in the record 45 | , a = 3 46 | , b = 4 47 | } 48 | ``` 49 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Images.html: -------------------------------------------------------------------------------- 1 |

Alt text

2 |

Alt text

3 |

Inline within a paragraph: alt text.

4 |

alt text

5 |

alt text

6 |

alt text

7 |

alt text.

8 |

Empty

9 |

this is a stupid URL

10 |

alt text

11 |

alt text

12 | -------------------------------------------------------------------------------- /Shakefile/src/Shakefiles/NestedCheckout.hs: -------------------------------------------------------------------------------- 1 | module Shakefiles.NestedCheckout where 2 | 3 | import Development.Shake 4 | import Development.Shake.FilePath 5 | import qualified System.Directory 6 | 7 | rules :: Rules () 8 | rules = do 9 | "_build/git/checkout/*.ok" %> \out -> do 10 | let cloneDir = dropExtension out 11 | let sha = dropDirectory1 $ dropDirectory1 $ dropDirectory1 cloneDir 12 | exists <- liftIO $ System.Directory.doesDirectoryExist cloneDir 13 | if exists 14 | then return () 15 | else cmd_ "git" "clone" "--local" "." cloneDir 16 | cmd_ (Cwd cloneDir) "git" "reset" "--hard" sha 17 | cmd_ (Cwd cloneDir) "./dev/build.sh" "generated" 18 | writeFileChanged out sha 19 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/FencedCodeBlocks.markdown: -------------------------------------------------------------------------------- 1 | This is a fenced code block: 2 | ```haskell 3 | pairs :: [(Int,Char)] 4 | pairs = [(x,y) | x <- [0..10], y <- ['a'..'z']] 5 | ``` 6 | Here is one with tildes: 7 | 8 | ~~~ haskell 9 | pairs :: [(Int,Char)] 10 | pairs = [(x,y) | x <- [0..10], y <- ['a'..'z']] 11 | ~~~ 12 | 13 | More metadata: 14 | 15 | ```haskell numberLines start=50 16 | pairs :: [(Int,Char)] 17 | pairs = [(x,y) | x <- [0..10], y <- ['a'..'z']] 18 | ``` 19 | 20 | More backticks: 21 | 22 | ```````` haskell 23 | pairs :: [(Int,Char)] 24 | pairs = [(x,y) | x <- [0..10], y <- ['a'..'z']] 25 | 26 | backticks :: String 27 | backticks = "`````" 28 | ````````````` 29 | 30 | Without an end: 31 | 32 | ``` 33 | code with 34 | no end 35 | 36 | -------------------------------------------------------------------------------- /tests/test-files/from-json/Elm-0.19/Declarations.elm: -------------------------------------------------------------------------------- 1 | module Declarations exposing (MyCustomType(..), MyCustomTypeNoParameters(..), MyTypeAlias, MyTypeAliasWithParameters, noTypeAnnotation, withParametersAndTypeAnnotation, withTypeAnnotation) 2 | 3 | 4 | type alias MyTypeAlias = 5 | () 6 | 7 | 8 | type alias MyTypeAliasWithParameters x y = 9 | () 10 | 11 | 12 | type MyCustomTypeNoParameters 13 | = MyCustomTypeNoParameters 14 | 15 | 16 | type MyCustomType a b 17 | = Both a b 18 | | None 19 | 20 | 21 | noTypeAnnotation = 22 | () 23 | 24 | 25 | withTypeAnnotation : () 26 | withTypeAnnotation = 27 | () 28 | 29 | 30 | withParametersAndTypeAnnotation : Int -> String -> () 31 | withParametersAndTypeAnnotation a b = 32 | () 33 | -------------------------------------------------------------------------------- /tests/test-files/good/json/ExternalReferences.json-roundtrip: -------------------------------------------------------------------------------- 1 | module ExternalReferences exposing (main, text, theBestClass, token) 2 | 3 | import Date exposing (Month(..)) 4 | import Foo.Bar as Bar 5 | import Foo.Baz exposing (..) 6 | import Html 7 | import Html.Attributes as Attr 8 | import Html.Events as Event exposing (onClick) 9 | 10 | 11 | token : String 12 | token = 13 | "XYZZY" 14 | 15 | 16 | theBestClass : Html.Attributes.Attribute msg 17 | theBestClass = 18 | Html.Attributes.class token 19 | 20 | 21 | text : String -> Html msg 22 | text = 23 | Html.text 24 | 25 | 26 | main : Html msg 27 | main = 28 | Html.div 29 | [ theBestClass 30 | ] 31 | [ Html.text token 32 | , (<|) Html.text (toString -pi) 33 | ] 34 | -------------------------------------------------------------------------------- /tests/test-files/from-json/Elm-0.19/Types.elm: -------------------------------------------------------------------------------- 1 | module Declarations exposing (MyFunctionType, MyRecordType, MyRecordTypeExtension, MyTupleType, MyTypeReference, MyTypeReferenceWithArguments, MyTypeVariable, MyUnit) 2 | 3 | 4 | type alias MyUnit = 5 | () 6 | 7 | 8 | type alias MyTypeReference = 9 | Basics.String 10 | 11 | 12 | type alias MyTypeReferenceWithArguments = 13 | Result.Result () () 14 | 15 | 16 | type alias MyTypeVariable a = 17 | a 18 | 19 | 20 | type alias MyTupleType = 21 | ( (), () ) 22 | 23 | 24 | type alias MyRecordType = 25 | { x : () 26 | , y : () 27 | } 28 | 29 | 30 | type alias MyRecordTypeExtension r = 31 | { r 32 | | x : () 33 | , y : () 34 | } 35 | 36 | 37 | type alias MyFunctionType = 38 | () -> () -> () 39 | -------------------------------------------------------------------------------- /parser/bench/src/LargeDictionary.elm: -------------------------------------------------------------------------------- 1 | module LargeDictionary where 2 | 3 | 4 | import Dict 5 | import Random 6 | import Signal 7 | import Time 8 | import Graphics.Element 9 | 10 | 11 | maxSize = 10000000 12 | 13 | 14 | randomGen = 15 | Random.int (-1 * maxSize) (maxSize) 16 | 17 | 18 | addNToDictWithSeed 19 | : Int 20 | -> Random.Seed 21 | -> Dict.Dict Int Int 22 | -> Dict.Dict Int Int 23 | addNToDictWithSeed n seed accum = 24 | case n of 25 | 0 -> accum 26 | _ -> 27 | let 28 | (nextToAdd, newSeed) = Random.generate randomGen seed 29 | newAccum = Dict.insert nextToAdd nextToAdd accum 30 | in addNToDictWithSeed (n-1) newSeed newAccum 31 | 32 | 33 | addNToDictAndSum numToInsert = 34 | addNToDictWithSeed numToInsert (Random.initialSeed 23) Dict.empty -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/DeclaraionSpacing.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (annotationShouldBeGroupedWithItsDefinition, topLevelDestructingShouldNotGroupWithAnything, withADefinition, withAnAnnotation) 2 | 3 | {-| Module comment. 4 | -} 5 | 6 | 7 | annotationShouldBeGroupedWithItsDefinition : () 8 | annotationShouldBeGroupedWithItsDefinition = 9 | () 10 | 11 | 12 | {-| Doc comment is grouped with the next thing 13 | -} 14 | withADefinition = 15 | () 16 | 17 | 18 | {-| Doc comment is grouped with the next thing 19 | -} 20 | withAnAnnotation : () 21 | withAnAnnotation = 22 | () 23 | 24 | 25 | ( a, b ) = 26 | ( 1, 2 ) 27 | 28 | 29 | topLevelDestructingShouldNotGroupWithAnything = 30 | -- This declaration should not be grouped with the ( a, b ) declaration above 31 | 5 32 | -------------------------------------------------------------------------------- /Release Notes/0.8.3.md: -------------------------------------------------------------------------------- 1 | ## Performance improvements 2 | 3 | Thanks to @folkertdev for diagnosing and contributing the fix for a long-standing performance issue 4 | where `elm-format` would take exceptionally long (and sometimes crash) on files contianing large expressions 5 | such as long lists or many other AST nodes with many children. 6 | 7 | Other than the performance improvements, there should be no other noticable changes from `elm-format` 0.8.2. 8 | 9 | 10 | ## Install 11 | 12 | ```sh 13 | npm install -g elm-format 14 | ``` 15 | 16 | or [download from the release page](https://github.com/avh4/elm-format/releases/tag/0.8.3). 17 | 18 | 19 | ## Thanks to ... 20 | 21 | - As noted above, @folkertdev for the performance improvment 22 | - @razzeee and @andys8 for help updating the Windows release build 23 | -------------------------------------------------------------------------------- /elm-format-lib/src/Parse/Comments.hs: -------------------------------------------------------------------------------- 1 | module Parse.Comments where 2 | 3 | import Parse.Whitespace 4 | import Parse.IParser 5 | import AST.V0_16 6 | 7 | 8 | 9 | commented :: IParser a -> IParser (C2 l1 l2 a) 10 | commented inner = 11 | (\c1 a c2 -> C (c1, c2) a) <$> whitespace <*> inner <*> whitespace 12 | 13 | 14 | postCommented :: IParser a -> IParser (C1 l a) 15 | postCommented a = 16 | flip C <$> a <*> whitespace 17 | 18 | 19 | preCommented :: IParser a -> IParser (C1 l a) 20 | preCommented a = 21 | C <$> whitespace <*> a 22 | 23 | 24 | withEol :: IParser a -> IParser (C0Eol a) 25 | withEol a = 26 | do 27 | (result, multiline) <- trackNewline a 28 | case multiline of 29 | SplitAll -> return $ C Nothing result 30 | JoinAll -> flip C result <$> restOfLine 31 | -------------------------------------------------------------------------------- /parser/bench/src/TupleBench.elm: -------------------------------------------------------------------------------- 1 | module TupleBench where 2 | 3 | type alias BigTuple = 4 | ( Float 5 | , Float 6 | , Float 7 | , Float 8 | , Float 9 | , Float 10 | , Float 11 | , Float 12 | , Float 13 | ) 14 | 15 | defaultTuple = 16 | (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0) 17 | 18 | getField (x1, x2, x3, x4, x5, x6, x7, x8, x9) i = 19 | case (i % 9) of 20 | 1 -> 21 | x1 22 | 2 -> 23 | x2 24 | 3 -> 25 | x3 26 | 4 -> 27 | x4 28 | 5 -> 29 | x5 30 | 6 -> 31 | x6 32 | 7 -> 33 | x7 34 | 8 -> 35 | x8 36 | 0 -> 37 | x9 38 | 39 | 40 | sumRandomElems : List Int -> Float 41 | sumRandomElems randomInts = 42 | List.foldr (\i sumSoFar -> (getField defaultTuple i) + sumSoFar ) 0.0 randomInts -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.17/AllSyntax/LineComments/ModuleEffect.elm: -------------------------------------------------------------------------------- 1 | -- U 2 | 3 | 4 | effect 5 | --T 6 | module 7 | -- A 8 | AllSyntax.BlockComments.ModuleEffect 9 | -- B 10 | where 11 | -- C 12 | { --D 13 | command 14 | --E 15 | = 16 | -- F 17 | MyCmd 18 | -- G 19 | , -- H 20 | subscription 21 | -- I 22 | = 23 | -- J 24 | MySub 25 | -- K 26 | } 27 | -- L 28 | exposing 29 | -- M 30 | ( -- N 31 | a 32 | -- O 33 | , -- P 34 | b 35 | -- Q 36 | , -- R 37 | c 38 | -- S 39 | ) 40 | 41 | 42 | type MyCmd msg 43 | = MyCmd msg 44 | 45 | 46 | type MySub msg 47 | = MySub msg 48 | -------------------------------------------------------------------------------- /Release Notes/0.3.0-alpha-elm017rc1-rc1.md: -------------------------------------------------------------------------------- 1 | **You only want this if you are trying out the Elm-Platform-0.17 release candidate. If you are using Elm-0.16, you want [elm-format-0.2.0-alpha](https://github.com/avh4/elm-format/releases/tag/0.2.0-alpha) instead.** 2 | 3 | > 0.3.0-alpha-elm017rc1-rc1 was a pre-0.3.0-alpha release that works with Elm-0.17-rc1 and was [announced on the elm-dev mailing list](https://groups.google.com/d/msg/elm-dev/M5Bk7yVCOHg/tewWr5YYBgAJ) 4 | 5 | Regarding the new syntax for the `module` statement, this version of elm-format will automatically migrate 0.16 files to the 0.17 format. 6 | 7 | Please report any 0.17-specific elm-format issues here to elm-dev, and not to the github issue tracker. 8 | 9 | In addition, expect the next elm-format alpha release shortly after the public Elm 0.17 release. 10 | -------------------------------------------------------------------------------- /Style Guide/Lists.md: -------------------------------------------------------------------------------- 1 | # Lists 2 | 3 | 4 | ## Empty lists 5 | 6 | An empty list is formatted as: 7 | 8 | ```elm 9 | [] 10 | ``` 11 | 12 | You should avoid putting comments inside of an empty list. 13 | Instead, put explanatory comments before the empty list. 14 | 15 | ```bad-elm 16 | [ {- don't put comments here -} ] 17 | ``` 18 | 19 | ```elm 20 | foldl step 21 | -- accumulator 22 | [] 23 | items 24 | ``` 25 | 26 | 27 | ## Small lists 28 | 29 | Small lists are kept on a single line: 30 | 31 | ```elm 32 | [1, 2, 3] 33 | ``` 34 | 35 | 36 | ## Large lists 37 | 38 | Large lists put one item on each line. 39 | Commas are put at the beginning of each new line. 40 | You can separate sections within the list using comments. 41 | 42 | ```elm 43 | [ 1 44 | , 2 45 | 46 | -- new section 47 | , 3 48 | , 4 49 | ] 50 | ``` 51 | -------------------------------------------------------------------------------- /package/linux/build-in-docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | if [[ $(docker --version) == *" 19.0"[0-2]* ]]; then 6 | echo "ERROR: Docker >= 19.03 is required" 7 | docker --version 8 | exit 1 9 | fi 10 | 11 | set -x 12 | 13 | export DOCKER_BUILDKIT=1 14 | 15 | SHA="${1-}" 16 | if [ -z "$SHA" ]; then 17 | CONTEXT="." 18 | VERSION="$(git describe --abbrev=8)" 19 | DEST="_build/docker/local/linux-x64" 20 | else 21 | CONTEXT="-" 22 | VERSION="$(git describe --abbrev=8 "$SHA")" 23 | DEST="_build/docker/$SHA/linux-x64" 24 | fi 25 | 26 | rm -Rf "$DEST" 27 | git archive --format=tar.gz "$SHA" | \ 28 | docker build -t elm-format-dev-linux --build-arg "ELM_FORMAT_VERSION=$VERSION" --target artifact --output type=local,dest="$DEST/" "$CONTEXT" 29 | "$DEST/elm-format" --help 30 | -------------------------------------------------------------------------------- /avh4-lib/test/Data/Text/ExtraTest.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | module Data.Text.ExtraTest (test_tests) where 3 | 4 | import Elm.Utils ((|>)) 5 | 6 | import Test.Tasty 7 | import Test.Tasty.HUnit 8 | 9 | import Data.Text.Extra 10 | 11 | 12 | test_tests :: TestTree 13 | test_tests = 14 | testGroup "Data.Text.ExtraTest" 15 | [ testCase "when there is no span of the given character" $ 16 | longestSpanOf '*' "stars exist only where you believe" 17 | |> assertEqual "" NoSpan 18 | , testCase "when the given character is present" $ 19 | longestSpanOf '*' "it's here -> * <-" 20 | |> assertEqual "" (Span 1) 21 | , testCase "only counts the longest span" $ 22 | longestSpanOf '*' "it's here -> ** <-, not here: *" 23 | |> assertEqual "" (Span 2) 24 | ] 25 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Blockquotes/Separation.html: -------------------------------------------------------------------------------- 1 |

One blockquote, two paragraphs:

2 |
3 |

one

4 |

two

5 |
6 |

Two blockquotes:

7 |
8 |

one

9 |
10 |
11 |

two

12 |
13 |

Nested blockquote, two paragraphs:

14 |
15 |
16 |

one

17 |

two

18 |
19 |
20 |

Nested blockquote, two blockquotes:

21 |
22 |
23 |

one

24 |
25 |
26 |

two

27 |
28 |
29 |

Two nested blockquotes:

30 |
31 |
32 |

one

33 |
34 |
35 |
36 |
37 |

two

38 |
39 |
40 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/TightAndLoose.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. tight
  2. 3 |
4 |
    5 |
  • tight
  • 6 |
  • list
  • 7 |
8 |
    9 |
  • loose

  • 10 |
  • list

  • 11 |
12 |
    13 |
  1. tight
  2. 14 |
  3. list
  4. 15 |
16 |
    17 |
  1. loose

  2. 18 |
  3. list

  4. 19 |
20 |
    21 |
  1. loose

    22 |
      23 |
    • sublist
    • 24 |
  2. 25 |
26 |
    27 |
  1. tight 28 |
      29 |
    • sublist
    • 30 |
  2. 31 |
32 |
    33 |
  • tight 34 |
    35 |

    blockquote 36 | and

    37 |
    38 |
    code
    39 | 
  • 40 |
  • tight
  • 41 |
42 |
    43 |
  • loose

    44 |
      45 |
    • with loose

    • 46 |
    • sublist

    • 47 |
  • 48 |
  • loose

  • 49 |
50 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Lists/MultipleBlankLines.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. First Item

    3 |
      4 |
    • one

      5 |
        6 |
      • two
      • 7 |
    • 8 |
    • one

      9 |
        10 |
      • two
      • 11 |
    • 12 |
  2. 13 |
  3. Second Item

    14 |
      15 |
    • one 16 |
        17 |
      • two
      • 18 |
    • 19 |
  4. 20 |
21 |
    22 |
  • one 23 |
      24 |
    • two
    • 25 |
  • 26 |
27 |
    28 |
  1. Third Item

    29 |
      30 |
    • one 31 |
        32 |
      • two
      • 33 |
    • 34 |
  2. 35 |
36 |
    37 |
  • one 38 |
      39 |
    • two
    • 40 |
  • 41 |
42 |
    43 |
  1. Fourth Item

    44 |
      45 |
    • one 46 |
        47 |
      • two
      • 48 |
    • 49 |
  2. 50 |
51 |
    52 |
  • one 53 |
      54 |
    • two
    • 55 |
  • 56 |
57 | -------------------------------------------------------------------------------- /elm-format-lib/src/ElmFormat/AST/PublicAST/MaybeF.hs: -------------------------------------------------------------------------------- 1 | module ElmFormat.AST.PublicAST.MaybeF where 2 | 3 | 4 | import Data.Coapplicative 5 | data MaybeF f a 6 | = JustF (f a) 7 | | NothingF a 8 | deriving (Functor) 9 | 10 | instance Prelude.Foldable f => Prelude.Foldable (MaybeF f) where 11 | foldMap f (JustF fa) = Prelude.foldMap f fa 12 | foldMap f (NothingF a) = f a 13 | 14 | instance Traversable f => Traversable (MaybeF f) where 15 | traverse f (JustF fa) = JustF <$> traverse f fa 16 | traverse f (NothingF a) = NothingF <$> f a 17 | 18 | instance Coapplicative f => Coapplicative (MaybeF f) where 19 | extract (JustF fa) = extract fa 20 | extract (NothingF a) = a 21 | 22 | maybeF :: (a -> x) -> (f a -> x) -> MaybeF f a -> x 23 | maybeF fromA _ (NothingF a) = fromA a 24 | maybeF _ fromFa (JustF fa) = fromFa fa 25 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Emphasis/Pathological.markdown: -------------------------------------------------------------------------------- 1 | This input can take a long time to parse in some implementations. 2 | 3 | *a 4 | *a 5 | *a 6 | *a 7 | *a 8 | *a 9 | *a 10 | *a 11 | *a 12 | *a 13 | *a 14 | *a 15 | *a 16 | *a 17 | *a 18 | *a 19 | *a 20 | *a 21 | *a 22 | *a 23 | *a 24 | aaaaa 25 | 26 | *a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a** 27 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | args@{ ... }: 2 | let 3 | default = import ./. args; 4 | inherit (default) pkgs haskellPackages haskellTools; 5 | in haskellPackages.shellFor { 6 | name = "elm-format"; 7 | packages = p: 8 | with p; [ 9 | elm-format-build 10 | elm-format 11 | avh4-lib 12 | elm-format-lib 13 | elm-format-test-lib 14 | elm-format-markdown 15 | ]; 16 | buildInputs = with pkgs; [ 17 | # Tools required to build elm-format 18 | cabal-install 19 | git 20 | python3 21 | jq 22 | 23 | # Dev tools 24 | hpack 25 | haskellTools.ghcid 26 | cabal2nix 27 | niv 28 | nixfmt-rfc-style 29 | alejandra 30 | haskellTools.haskell-language-server 31 | unzip 32 | nix-prefetch 33 | nodejs 34 | minisign 35 | simple-http-server 36 | haskellTools.hpc 37 | ]; 38 | } 39 | -------------------------------------------------------------------------------- /package/npm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Install elm-format", 3 | "main": "index.js", 4 | "scripts": { 5 | "install": "node index.js", 6 | "prepublish": "npm test", 7 | "test": "eslint ." 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/avh4/elm-format.git" 12 | }, 13 | "keywords": [ 14 | "elm-format" 15 | ], 16 | "author": "Aaron VonderHaar", 17 | "license": "BSD-3-Clause", 18 | "bugs": { 19 | "url": "https://github.com/avh4/elm-format/issues" 20 | }, 21 | "files": [ 22 | "binary.js", 23 | "index.js", 24 | "bin/elm-format" 25 | ], 26 | "homepage": "https://github.com/avh4/elm-format", 27 | "bin": { 28 | "elm-format": "bin/elm-format" 29 | }, 30 | "optionalDependencies": {}, 31 | "devDependencies": { 32 | "eslint": "^7.19.0" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.16/github-avh4-elm-format-184.elm: -------------------------------------------------------------------------------- 1 | update : CotwData.Msg -> Model -> ( Model, Cmd CotwData.Msg ) 2 | update msg model = 3 | case msg of 4 | SplashMsg NewGame -> 5 | ( { model | currentPage = CharCreationPage }, Cmd.none ) 6 | 7 | SplashMsg _ -> 8 | ( { model | currentPage = NotImplementedPage }, Cmd.none ) 9 | 10 | CharCreationMsg StartGame -> 11 | ( { model | currentPage = GamePage }, Cmd.none ) 12 | 13 | CharCreationMsg msg -> 14 | ( { model | character = CharCreation.update msg model.character }, Cmd.none ) 15 | 16 | GameMsg msg -> 17 | ( { model | game = Game.update msg model.game }, Cmd.none ) 18 | 19 | Keyboard (Just a) -> (model, Cmd.none) 20 | 21 | Keyboard Maybe.Nothing -> (model, Cmd.none) 22 | 23 | -------------------------------------------------------------------------------- /Release Notes/0.8.5.md: -------------------------------------------------------------------------------- 1 | ## Binaries for Alpine Linux and Mac ARM64 2 | 3 | Feature changes: 4 | - Detailed error messages for syntax errors have been removed. Use `elm make` to see a detailed error if elm-format fails. 5 | 6 | New features: 7 | - In `module` and `import` lines, `exposing` is automatically added if missing 8 | 9 | Other changes: 10 | - The npm installer now provides a (Rosetta) binary for Mac ARM64 11 | - Linux binaries are now statically linked (should now work on alpine linux and other systems without glibc-2.27) 12 | - Removed `--upgrade` (now use elm-refactor instead) 13 | 14 | 15 | ## Install 16 | 17 | ```sh 18 | npm install -g elm-format 19 | ``` 20 | 21 | or [download from the release page](https://github.com/avh4/elm-format/releases/tag/0.8.5). 22 | 23 | 24 | ## Thanks to ... 25 | 26 | - @kutyel for improvements to lenient parsing 27 | -------------------------------------------------------------------------------- /elm-format-markdown/package.yaml: -------------------------------------------------------------------------------- 1 | name: elm-format-markdown 2 | version: 0.0.0.1 3 | 4 | synopsis: Markdown parsing for Elm documentation comments 5 | license: BSD-3-Clause 6 | license-file: LICENSE 7 | author: Aaron VonderHaar 8 | maintainer: gruen0aermel@gmail.com 9 | copyright: See https://github.com/avh4/elm-format/blob/master/LICENSE 10 | 11 | build-type: Simple 12 | 13 | language: Haskell2010 14 | 15 | default-extensions: 16 | - DeriveFunctor 17 | - LambdaCase 18 | - MultiParamTypeClasses 19 | - OverloadedStrings 20 | - ScopedTypeVariables 21 | 22 | ghc-options: 23 | - -O2 24 | - -Wall 25 | - -Werror=unused-packages 26 | - -Wno-name-shadowing 27 | 28 | dependencies: 29 | base: ">= 4.15.0.0 && < 5" 30 | containers: ">= 0.6.5.1 && < 0.7" 31 | mtl: ">= 2.2.2 && < 3" 32 | text: ">= 2.0 && < 3" 33 | 34 | library: 35 | source-dirs: 36 | - . 37 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Code/FencedCodeBlocks.html: -------------------------------------------------------------------------------- 1 |

This is a fenced code block:

2 |
pairs :: [(Int,Char)]
 3 | pairs = [(x,y) | x <- [0..10], y <- ['a'..'z']]
 4 | 
5 |

Here is one with tildes:

6 |
pairs :: [(Int,Char)]
 7 | pairs = [(x,y) | x <- [0..10], y <- ['a'..'z']]
 8 | 
9 |

More metadata:

10 |
pairs :: [(Int,Char)]
11 | pairs = [(x,y) | x <- [0..10], y <- ['a'..'z']]
12 | 
13 |

More backticks:

14 |
pairs :: [(Int,Char)]
15 | pairs = [(x,y) | x <- [0..10], y <- ['a'..'z']]
16 | 
17 | backticks :: String
18 | backticks = "`````"
19 | 
20 |

Without an end:

21 |
code with
22 | no end
23 | 
24 | 
25 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Links_inline_style.html: -------------------------------------------------------------------------------- 1 |

Just a URL.

2 |

URL and title.

3 |

URL and title.

4 |

URL and title.

5 |

URL and title.

6 |

URL wrapped in angle brackets.

7 |

URL w/ angle brackets + title.

8 |

Empty.

9 |

With parens in the URL

10 |

(With outer parens and parens in url)

11 |

With parens in the URL

12 |

(With outer parens and parens in url)

13 | -------------------------------------------------------------------------------- /elm-format-lib/src/Parse/State.hs: -------------------------------------------------------------------------------- 1 | module Parse.State where 2 | 3 | 4 | data State = State 5 | { newline :: [Bool] 6 | } 7 | 8 | 9 | init :: State 10 | init = 11 | State 12 | { newline = [False] 13 | } 14 | 15 | 16 | setNewline :: State -> State 17 | setNewline state = 18 | case newline state of 19 | [] -> state 20 | (_:rest) -> state { newline = (True:rest) } 21 | 22 | 23 | pushNewlineContext :: State -> State 24 | pushNewlineContext state = 25 | state { newline = (False:(newline state)) } 26 | 27 | 28 | popNewlineContext :: State -> State 29 | popNewlineContext state = 30 | case newline state of 31 | [] -> state 32 | (_:[]) -> state 33 | (last:next:rest) -> state { newline = (last || next):rest } 34 | 35 | 36 | sawNewline :: State -> Bool 37 | sawNewline state = 38 | case newline state of 39 | [] -> False 40 | (b:_) -> b 41 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/Sorting.elm: -------------------------------------------------------------------------------- 1 | module Sorting exposing (x) 2 | 3 | import ConstructorTagsAreDeduplicated exposing(A(X, X, X)) 4 | import ConstructorTagsAreMerged exposing (A(X, Y), B(A), B(..), A(C, D), C, C(..)) 5 | import ConstructorTagsAreSorted exposing (A(Y, Z, X, Yy, XYzZY)) 6 | import ExposedValuesAreDeduplicated exposing (x, (==/==), x, (==/==), Z, Z(..)) 7 | import ExposedValuesAreSorted exposing (x, (<>), a, (==/==), Y, Z(..)) 8 | import ImportsAreMerged exposing (A(X), b) 9 | import ImportsAreMerged exposing (A(Y), z) 10 | import ImportsAreMerged2 11 | import ImportsAreMerged2 exposing (..) 12 | import ImportsAreMerged3 exposing (x) 13 | import ImportsAreMerged3 exposing (..) 14 | import ImportsWithConflictingAs as Overridden 15 | import ImportsWithConflictingAs as Correct 16 | import ImportsWithConflictingAs2 17 | import ImportsWithConflictingAs2 as Correct 18 | 19 | 20 | x = 21 | () 22 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Emphasis/Pathological.html: -------------------------------------------------------------------------------- 1 |

This input can take a long time to parse in some implementations.

2 |

a 3 | a 4 | a 5 | a 6 | a 7 | a 8 | a 9 | a 10 | a 11 | a 12 | a 13 | a 14 | a 15 | a 16 | a 17 | a 18 | a 19 | a 20 | a 21 | a 22 | *a 23 | aaaaa

24 |

*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**

25 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.19/AllSyntax/Module.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.Module exposing (CustomType(..), a, b, c) 2 | 3 | import Dict as D 4 | exposing 5 | ( Dict 6 | , empty 7 | , fromList 8 | ) 9 | import Json.Decode as Json 10 | import Maybe exposing (Maybe(..), map) 11 | import Result exposing (Result(..)) 12 | import Signal exposing (..) 13 | import String 14 | import Task 15 | exposing 16 | ( andMap 17 | , andThen 18 | , fail 19 | , fromMaybe 20 | , fromResult 21 | , map 22 | , map2 23 | , map3 24 | , map4 25 | , map5 26 | , mapError 27 | , onError 28 | , succeed 29 | , toMaybe 30 | , toResult 31 | ) 32 | 33 | 34 | type CustomType 35 | = TagA 36 | | TagB 37 | 38 | 39 | a = 40 | 1 41 | 42 | 43 | b = 44 | 2 45 | 46 | 47 | c = 48 | 3 49 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Inline_HTML_Simple.markdown: -------------------------------------------------------------------------------- 1 | Here's a simple block: 2 | 3 |
4 | foo 5 |
6 | 7 | This should be a code block, though: 8 | 9 |
10 | foo 11 |
12 | 13 | As should this: 14 | 15 |
foo
16 | 17 | Now, nested: 18 | 19 |
20 |
21 |
22 | foo 23 |
24 |
25 |
26 | 27 | This should just be an HTML comment: 28 | 29 | 30 | 31 | Multiline: 32 | 33 | 37 | 38 | Code block: 39 | 40 | 41 | 42 | Just plain comment, with trailing spaces on the line: 43 | 44 | 45 | 46 | Code: 47 | 48 |
49 | 50 | Hr's: 51 | 52 |
53 | 54 |
55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/Module.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.Module exposing (CustomType(TagA), a, b, c) 2 | 3 | import Dict as D 4 | exposing 5 | ( Dict 6 | , empty 7 | , fromList 8 | ) 9 | import Json.Decode as Json 10 | import Maybe exposing (Maybe(Just, Nothing), map) 11 | import Result exposing (Result(..)) 12 | import Signal exposing (..) 13 | import String 14 | import Task 15 | exposing 16 | ( andMap 17 | , andThen 18 | , fail 19 | , fromMaybe 20 | , fromResult 21 | , map 22 | , map2 23 | , map3 24 | , map4 25 | , map5 26 | , mapError 27 | , onError 28 | , succeed 29 | , toMaybe 30 | , toResult 31 | ) 32 | 33 | 34 | type CustomType 35 | = TagA 36 | | TagB 37 | 38 | 39 | a = 40 | 1 41 | 42 | 43 | b = 44 | 2 45 | 46 | 47 | c = 48 | 3 49 | -------------------------------------------------------------------------------- /Release Notes/0.6.1-alpha.md: -------------------------------------------------------------------------------- 1 | Okay, I lied in the [0.6.0-alpha announcement](https://github.com/avh4/elm-format/releases/tag/0.6.0-alpha) 😄 I decided to add one more big feature before preparing for the public beta. 2 | 3 | So I'm excited to announce elm-format-0.6.1-alpha! The one change is that elm-format now formats your documentation comments, *including any Elm code examples in your documentation*. 4 | 5 | Please try it out and let me know if you run into any problems. I had to make a few choices about what the normalized markdown format should be based on the doc comments of some existing packages, so if you have a lot of familiarity with markdown parsers and have opinions about this, or if you know of other projects that have defined a normalized markdown format, please create a discussion issue on github. 6 | 7 | ### Install 8 | 9 | [Download](https://github.com/avh4/elm-format#installation-) or run `npm install -g elm-format`. 10 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.16/github-avh4-elm-format-184.formatted.elm: -------------------------------------------------------------------------------- 1 | module Main (..) where 2 | 3 | 4 | update : CotwData.Msg -> Model -> ( Model, Cmd CotwData.Msg ) 5 | update msg model = 6 | case msg of 7 | SplashMsg NewGame -> 8 | ( { model | currentPage = CharCreationPage }, Cmd.none ) 9 | 10 | SplashMsg _ -> 11 | ( { model | currentPage = NotImplementedPage }, Cmd.none ) 12 | 13 | CharCreationMsg StartGame -> 14 | ( { model | currentPage = GamePage }, Cmd.none ) 15 | 16 | CharCreationMsg msg -> 17 | ( { model | character = CharCreation.update msg model.character }, Cmd.none ) 18 | 19 | GameMsg msg -> 20 | ( { model | game = Game.update msg model.game }, Cmd.none ) 21 | 22 | Keyboard (Just a) -> 23 | ( model, Cmd.none ) 24 | 25 | Keyboard (Maybe.Nothing) -> 26 | ( model, Cmd.none ) 27 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/LineComments/Types.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.LineComments.Types exposing (emptyRecord, record, recordExtension) 2 | 3 | import Dict 4 | 5 | 6 | emptyRecord : 7 | { --M 8 | } 9 | -> () 10 | emptyRecord _ = 11 | () 12 | 13 | 14 | record : 15 | { --N 16 | x : 17 | --P 18 | Int 19 | 20 | --Q 21 | , --R 22 | y 23 | --S 24 | : 25 | --T 26 | () 27 | 28 | --U 29 | } 30 | -> () 31 | record _ = 32 | () 33 | 34 | 35 | recordExtension : 36 | { --V 37 | a 38 | --W 39 | | --X 40 | x 41 | --Y 42 | : 43 | --Z 44 | Int 45 | 46 | --AA 47 | , --AB 48 | y 49 | --AC 50 | : 51 | --AD 52 | Int 53 | 54 | --AE 55 | } 56 | -> () 57 | recordExtension _ = 58 | () 59 | -------------------------------------------------------------------------------- /hie.yaml: -------------------------------------------------------------------------------- 1 | cradle: 2 | cabal: 3 | - path: "./Shakefile/src" 4 | component: "build-elm-format:exe:build-elm-format" 5 | 6 | - path: "./avh4-lib/src/" 7 | component: "lib:avh4-lib" 8 | 9 | - path: "./avh4-lib/test/" 10 | component: "avh4-lib:test:al-tests" 11 | 12 | - path: "./elm-format-lib/src/" 13 | component: "lib:elm-format-lib" 14 | 15 | - path: "./elm-format-lib/test/" 16 | component: "elm-format-lib:test:efl-tests" 17 | 18 | - path: "./elm-format-markdown/" 19 | component: "lib:elm-format-markdown" 20 | 21 | - path: "./elm-format-test-lib/src/" 22 | component: "lib:elm-format-test-lib" 23 | 24 | - path: "./elm-format-test-lib/test/" 25 | component: "elm-format-test-lib:test:elm-format-test-lib-tests" 26 | 27 | - path: "./src/" 28 | component: "elm-format:exe:elm-format" 29 | 30 | - path: "./tests/" 31 | component: "elm-format:test:elm-format-tests" 32 | -------------------------------------------------------------------------------- /elm-format-lib/src/ElmFormat/Render/Text.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE DataKinds #-} 2 | module ElmFormat.Render.Text where 3 | 4 | import Data.Coapplicative 5 | import Elm.Utils ((|>)) 6 | import ElmVersion (ElmVersion) 7 | import AST.Structure 8 | import AST.V0_16 9 | 10 | import AST.Module (Module) 11 | import qualified Box 12 | import qualified Data.Text as Text 13 | import qualified ElmFormat.Render.Box as Render 14 | 15 | 16 | render :: Coapplicative annf => ElmVersion -> Module [UppercaseIdentifier] (ASTNS annf [UppercaseIdentifier] 'TopLevelNK) -> Text.Text 17 | render elmVersion modu = 18 | renderBox $ Render.formatModule elmVersion True 2 modu 19 | 20 | 21 | renderBox :: Box.Box -> Text.Text 22 | renderBox box = 23 | box 24 | |> Box.render 25 | 26 | 27 | -- TODO: remove this and convert the Integration test to a test fixture 28 | renderLiteral :: ElmVersion -> LiteralValue -> Text.Text 29 | renderLiteral elmVersion literal = 30 | renderBox $ Render.formatLiteral elmVersion literal 31 | -------------------------------------------------------------------------------- /package/elm-tooling/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | VERSION="$1" 5 | 6 | function print-version() { 7 | PLATFORM_ELM_TOOLING="$1" 8 | PLATFORM_ELM_FORMAT="$2" 9 | ZIP_TYPE="$3" 10 | EXT="${4-}" 11 | 12 | FILENAME="elm-format-$VERSION-$PLATFORM_ELM_FORMAT.$ZIP_TYPE" 13 | FILEPATH="../../publish/$VERSION/$FILENAME" 14 | 15 | echo " \"$PLATFORM_ELM_TOOLING\": {" 16 | echo " hash: \"$(sha256sum "$FILEPATH" | cut -d' ' -f1)\"," 17 | echo " url: \"https://github.com/avh4/elm-format/releases/download/$VERSION/$FILENAME\"," 18 | echo " fileSize: $(stat -c %s "$FILEPATH")," 19 | echo " fileName: \"elm-format$EXT\"," 20 | echo " type: \"$ZIP_TYPE\"," 21 | echo " }," 22 | } 23 | 24 | echo "\"$VERSION\": {" 25 | print-version darwin-arm64 mac-arm64 tgz 26 | print-version darwin-x64 mac-x64 tgz 27 | print-version linux-arm64 linux-aarch64 tgz 28 | print-version linux-x64 linux-x64 tgz 29 | print-version win32-x64 win-x64 zip .exe 30 | echo "}," 31 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/Expressions/BinaryOperators.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (commentedInfixOperator, infixOperator, leftPipe, lineComments, multilineInfixOperators) 2 | 3 | 4 | infixOperator = 5 | 1 + 2 * 3 / 4 <> 5 |> (+) 0 6 | 7 | 8 | multilineInfixOperators = 9 | 1 10 | + 2 11 | * 3 12 | / 4 13 | <> 5 14 | |> (+) 0 15 | 16 | 17 | commentedInfixOperator = 18 | 1 {- plus -} + 2 19 | 20 | 21 | lineComments = 22 | () 23 | |> identity 24 | |> identity 25 | --X 26 | |> identity 27 | 28 | 29 | leftPipe a = 30 | a <| 31 | a <| 32 | a <| 33 | () 34 | 35 | 36 | {-| elm-format will auto-correct `=>` to `->` when used in types and lambda introductions, 37 | but for Elm <= 0.18, it is valid as an expression and should be untouched in that usage. 38 | -} 39 | fatArrowOperator = 40 | let 41 | (=>) a b = 42 | () 43 | in 44 | 1 => 2 => 3 45 | -------------------------------------------------------------------------------- /avh4-lib/test/Data/List/ExtraTest.hs: -------------------------------------------------------------------------------- 1 | module Data.List.ExtraTest where 2 | 3 | import Test.Tasty 4 | import Test.Tasty.HUnit 5 | 6 | import Data.List.Extra 7 | 8 | 9 | tests :: TestTree 10 | tests = 11 | testGroup "Util.List" 12 | [ testGroup "pairs" 13 | [ testCase "" $ assertEqual "" [(1,2), (2,3)] $ pairs [1, 2, 3] 14 | , testCase "empty" $ assertEqual "" [] $ pairs ([] :: [Int]) 15 | , testCase "single" $ assertEqual "" [] $ pairs [1] 16 | ] 17 | , testGroup "intersperseMap" 18 | [ testCase "" $ assertEqual "" [ 21, 20050, 51, 50070, 71 ] $ intersperseMap (\a b -> [1000*a+b]) (\a -> a + 1) [ 20, 50, 70] 19 | , testCase "empty" $ assertEqual "" [] $ intersperseMap (\a b -> []) id ([] :: [Int]) 20 | ] 21 | , testGroup "shift" 22 | [ testCase "" $ assertEqual "" ([("a",1), ("b",2)], "c") $ shift "a" [(1,"b"), (2,"c")] 23 | , testCase "" $ assertEqual "empty" ([],"x") $ shift "x" ([] :: [(Int,String)]) 24 | ] 25 | ] 26 | -------------------------------------------------------------------------------- /tests/test-files/from-json/Elm-0.19/ModuleImports.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleName": "ModuleImports", 3 | "imports": { 4 | "SingleWordNoAlias": {}, 5 | "Multi.Word.NoAlias": {}, 6 | "SingleWordAlias": { "as": "S" }, 7 | "Multi.Word.Alias": { "as": "WordAlias" }, 8 | "Exposing.Everything": { "exposing": "Everything" }, 9 | "Exposing.Values": { 10 | "exposing": { 11 | "values": ["a", "b"] 12 | } 13 | }, 14 | "Exposing.Types": { 15 | "exposing": { 16 | "types": { 17 | "ExposeAllTags": "AllTags", 18 | "ExposeNoTags": "NoTags" 19 | } 20 | } 21 | } 22 | }, 23 | "body": [ 24 | { 25 | "tag": "Definition", 26 | "name": "f", 27 | "parameters": [], 28 | "expression": { 29 | "tag": "UnitLiteral" 30 | } 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Inline_HTML_Simple.html: -------------------------------------------------------------------------------- 1 |

Here's a simple block:

2 |
3 | foo 4 |
5 |

This should be a code block, though:

6 |
<div>
 7 |     foo
 8 | </div>
 9 | 
10 |

As should this:

11 |
<div>foo</div>
12 | 
13 |

Now, nested:

14 |
15 |
16 |
17 | foo 18 |
19 |
20 |
21 |

This should just be an HTML comment:

22 | 23 |

Multiline:

24 | 28 |

Code block:

29 |
<!-- Comment -->
30 | 
31 |

Just plain comment, with trailing spaces on the line:

32 | 33 |

Code:

34 |
<hr />
35 | 
36 |

Hr's:

37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | -------------------------------------------------------------------------------- /elm-format-lib/src/ElmFormat/KnownContents.hs: -------------------------------------------------------------------------------- 1 | module ElmFormat.KnownContents 2 | ( KnownContents 3 | , fromFunction 4 | , isKnown, get 5 | ) 6 | where 7 | 8 | import AST.V0_16 9 | 10 | newtype KnownContents = 11 | KnownContents ([UppercaseIdentifier] -> Maybe [LocalName]) -- return Nothing if the contents are unknown 12 | 13 | instance Semigroup KnownContents where 14 | (KnownContents a) <> (KnownContents b) = KnownContents (\ns -> a ns <> b ns) 15 | 16 | instance Monoid KnownContents where 17 | mempty = fromFunction (const Nothing) 18 | 19 | 20 | fromFunction :: ([UppercaseIdentifier] -> Maybe [LocalName]) -> KnownContents 21 | {-# INLINE fromFunction #-} 22 | fromFunction = KnownContents 23 | 24 | 25 | isKnown :: KnownContents -> [UppercaseIdentifier] -> Bool 26 | isKnown (KnownContents lookup) = 27 | maybe False (const True) . lookup 28 | 29 | 30 | get :: [UppercaseIdentifier] -> KnownContents -> Maybe [LocalName] 31 | {-# INLINE get #-} 32 | get ns (KnownContents lookup) = 33 | lookup ns 34 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/ModuleWithDocs.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.ModuleWithDocs exposing 2 | ( CustomType(TagA), a 3 | , b, c 4 | ) 5 | 6 | {-| 7 | 8 | @docs CustomType, a 9 | 10 | -} 11 | 12 | import Dict as D 13 | exposing 14 | ( Dict 15 | , empty 16 | , fromList 17 | ) 18 | import Json.Decode as Json 19 | import Maybe exposing (Maybe(Just, Nothing), map) 20 | import Result exposing (Result(..)) 21 | import Signal exposing (..) 22 | import String 23 | import Task 24 | exposing 25 | ( andMap 26 | , andThen 27 | , fail 28 | , fromMaybe 29 | , fromResult 30 | , map 31 | , map2 32 | , map3 33 | , map4 34 | , map5 35 | , mapError 36 | , onError 37 | , succeed 38 | , toMaybe 39 | , toResult 40 | ) 41 | 42 | 43 | type CustomType 44 | = TagA 45 | | TagB 46 | 47 | 48 | a = 49 | 1 50 | 51 | 52 | b = 53 | 2 54 | 55 | 56 | c = 57 | 3 58 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/BlockComments/Module.elm: -------------------------------------------------------------------------------- 1 | {- AD -} 2 | 3 | 4 | module {- A -} AllSyntax.BlockComments.Module {- B -} {- I -} exposing ({- C -} a {- D -}, {- E -} b {- F -}, {- G -} c {- H -}) 5 | 6 | {- J -} {- K -} 7 | 8 | import {- P -} Json.Decode {- Q -} as {- R -} Json 9 | import {- M -} Maybe {- N -} exposing {- O -} ({- S -} Maybe {- W -} ({- X -} Just {- Y -}, {- Z -} Nothing {- AA -}) {- T -}, {- U -} map {- V -}) 10 | import Signal exposing ({- AB -} .. {- AC -}) 11 | import {- L -} String 12 | import Task 13 | exposing 14 | ( andMap 15 | , andThen 16 | , fail {- AE -} 17 | , fromMaybe 18 | , fromResult 19 | , map 20 | , map2 21 | , map3 22 | , map4 23 | , map5 24 | , mapError 25 | , onError 26 | , succeed {- AD -} 27 | , toMaybe 28 | , toResult 29 | ) 30 | 31 | 32 | 33 | {- AF -} 34 | 35 | 36 | a = 37 | 1 38 | 39 | 40 | b = 41 | 2 42 | 43 | 44 | c = 45 | 3 46 | -------------------------------------------------------------------------------- /.github/workflows/Build release.yml: -------------------------------------------------------------------------------- 1 | name: Build release 2 | 3 | on: 4 | push: 5 | tags: '*' 6 | branches: 'release/*' 7 | 8 | defaults: 9 | run: 10 | shell: bash 11 | 12 | jobs: 13 | build: 14 | strategy: 15 | fail-fast: false 16 | matrix: 17 | build: 18 | - name: windows 19 | runner: windows-latest 20 | archive-label: Windows 21 | - name: macOS-x86 22 | runner: macOS-latest 23 | archive-label: macOS-x86 24 | 25 | name: release-${{ matrix.build.name }} 26 | runs-on: ${{ matrix.build.runner }} 27 | 28 | steps: 29 | - name: Configure environment 30 | run: | 31 | git config --global core.autocrlf false 32 | - uses: actions/checkout@v3 33 | - uses: ./.github/actions/git-tags 34 | - uses: ./.github/actions/haskell 35 | - run: ./dev/build.sh -- dist-dependencies 36 | - run: ./dev/build.sh -- dist 37 | - uses: ./.github/actions/release-artifact 38 | with: 39 | minisign-key: ${{ secrets.MINISIGN_PRIVATE_KEY }} 40 | -------------------------------------------------------------------------------- /package/win/setup.md: -------------------------------------------------------------------------------- 1 | ## First time setup 2 | 3 | ```bash 4 | brew install caskroom/cask/brew-cask 5 | brew cask install vagrant 6 | brew cask install virtualbox 7 | #vagrant init opentable/win-2012r2-standard-amd64-nocm 8 | vagrant up 9 | vagrant plugin install vagrant-winrm 10 | vagrant winrm -c "dir" 11 | ``` 12 | 13 | ## Start Windows VM 14 | 15 | - `(cd package/win && vagrant up)` 16 | - Open VirtualBox and show the runnning Windows VM 17 | - Start Git Bash (Right click on Windows Desktop -> "Git Bash Here") 18 | 19 | 20 | ## Build Windows binary 21 | 22 | From the host computer: 23 | 24 | - `cd package/win/elm-format` 25 | - `git fetch` 26 | 27 | From the Windows VM: 28 | 29 | - `cd /c/vagrant/elm-format` 30 | - `git checkout ` 31 | - ## !! Make sure you are on the Windows VM !! 32 | `git clean -dfx` 33 | ## !! Make sure you are on the Windows VM !! 34 | - `/c/vagrant/build-package.sh` 35 | 36 | 37 | ## back to host computer 38 | # cd ./package/win/ 39 | # vagrant halt 40 | # cp elm-format/elm-format-0.0.0-win-i386.zip ../.. 41 | -------------------------------------------------------------------------------- /tests/test-files/good/Elm-0.18/AllSyntax/BlockComments/Patterns.elm: -------------------------------------------------------------------------------- 1 | module AllSyntax.BlockComments.Patterns exposing (Foo(..), asAlias, complexCons, consList, data, emptyList, list, literal, parens, record, tuple, unit, variable, wildcard) 2 | 3 | 4 | type Foo 5 | = Foo () () 6 | 7 | 8 | wildcard _ = 9 | () 10 | 11 | 12 | literal 1 2.0 "string" 'c' = 13 | () 14 | 15 | 16 | variable v = 17 | () 18 | 19 | 20 | data (Foo {- Q -} x {- R -} y) = 21 | () 22 | 23 | 24 | unit ({- A -}) = 25 | () 26 | 27 | 28 | parens ({- W -} v {- X -}) = 29 | () 30 | 31 | 32 | tuple ( {- B -} a {- C -}, {- D -} b {- E -} ) = 33 | () 34 | 35 | 36 | emptyList [{- F -}] = 37 | () 38 | 39 | 40 | list [ {- G -} a {- H -}, {- I -} b {- J -} ] = 41 | () 42 | 43 | 44 | consList (a {- S -} :: {- T -} b {- U -} :: {- V -} c) = 45 | () 46 | 47 | 48 | record { {- K -} a {- L -}, {- M -} b {- N -} } = 49 | () 50 | 51 | 52 | asAlias (() {- O -} as {- P -} x) = 53 | () 54 | 55 | 56 | complexCons (a :: (x :: []) :: ((b :: _) as blah)) = 57 | () 58 | -------------------------------------------------------------------------------- /tests/usage.stdout/golden: -------------------------------------------------------------------------------- 1 | elm-format x.x.x 2 | 3 | Usage: elm-format [INPUT] [--output FILE] [--yes] [--validate] [--stdin] 4 | [--elm-version VERSION] 5 | 6 | Format Elm source files. 7 | 8 | Available options: 9 | -h,--help Show this help text 10 | --output FILE Write output to FILE instead of overwriting the given 11 | source file. 12 | --yes Reply 'yes' to all automated prompts. 13 | --validate Check if files are formatted without changing them. 14 | --stdin Read from stdin, output to stdout. 15 | --elm-version VERSION The Elm version of the source files being formatted. 16 | Valid values: 0.18, 0.19. Default: auto 17 | 18 | Examples: 19 | elm-format Main.elm # formats Main.elm 20 | elm-format Main.elm --output Main2.elm # formats Main.elm as Main2.elm 21 | elm-format src/ # format all *.elm files in the src directory 22 | 23 | Full guide to using elm-format at 24 | -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | defaults: 12 | run: 13 | shell: bash 14 | 15 | jobs: 16 | build: 17 | strategy: 18 | matrix: 19 | os: 20 | - ubuntu-latest 21 | - windows-latest 22 | # - macOS-latest 23 | 24 | name: ci-${{ matrix.os }} 25 | runs-on: ${{ matrix.os }} 26 | 27 | steps: 28 | - name: Configure environment 29 | run: | 30 | git config --global core.autocrlf false 31 | - uses: actions/checkout@v3 32 | - uses: ./.github/actions/haskell 33 | - uses: ./.github/actions/cache-build 34 | - run: ./dev/build.sh -- dependencies 35 | - run: ./dev/build.sh -- build 36 | - name: Tests 37 | if: runner.os != 'Windows' 38 | run: | 39 | ./dev/build.sh -- test 40 | - name: Tests (for Windows) 41 | if: runner.os == 'Windows' 42 | run: | 43 | ./dev/build.sh -- unit-tests 44 | echo "##[warning]integration tests are currently disabled on Windows CI" 45 | - run: ./dev/build.sh -- docs 46 | -------------------------------------------------------------------------------- /Shakefile/build-elm-format.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: 1.12 2 | 3 | -- This file has been generated from package.yaml by hpack version 0.35.1. 4 | -- 5 | -- see: https://github.com/sol/hpack 6 | 7 | name: build-elm-format 8 | version: 0.0.0 9 | build-type: Simple 10 | 11 | executable build-elm-format 12 | main-is: Main.hs 13 | other-modules: 14 | Shakefiles.Dependencies 15 | Shakefiles.ElmFormat.IntegrationTests 16 | Shakefiles.Extra 17 | Shakefiles.Haskell 18 | Shakefiles.Haskell.Hpc 19 | Shakefiles.ListFiles 20 | Shakefiles.NestedCheckout 21 | Shakefiles.NixBuild 22 | Shakefiles.Platform 23 | Shakefiles.Prelude 24 | Shakefiles.Shellcheck 25 | Shakefiles.Signature 26 | Paths_build_elm_format 27 | hs-source-dirs: 28 | src 29 | default-extensions: 30 | LambdaCase 31 | ghc-options: -rtsopts -threaded -with-rtsopts=-I0 -Werror=unused-packages 32 | build-depends: 33 | aeson >=2.0.0.0 34 | , base >=4.16.2.0 35 | , directory >=1.3.6.2 36 | , relude 37 | , shake >=0.19.6 && <0.20 38 | , yaml 39 | default-language: Haskell2010 40 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Links_reference_style.markdown: -------------------------------------------------------------------------------- 1 | Foo [bar] [1]. 2 | 3 | Foo [bar][1]. 4 | 5 | Foo [bar] 6 | [1]. 7 | 8 | [1]: /url/ "Title" 9 | 10 | 11 | With [embedded [brackets]] [b]. 12 | 13 | 14 | Indented [once][]. 15 | 16 | Indented [twice][]. 17 | 18 | Indented [thrice][]. 19 | 20 | Indented [four][] times. 21 | 22 | [once]: /url 23 | 24 | [twice]: /url 25 | 26 | [thrice]: /url 27 | 28 | [four]: /url 29 | 30 | 31 | [b]: /url/ 32 | 33 | * * * 34 | 35 | [this] [this] should work 36 | 37 | So should [this][this]. 38 | 39 | And [this] []. 40 | 41 | And [this][]. 42 | 43 | And [this]. 44 | 45 | But not [that] []. 46 | 47 | Nor [that][]. 48 | 49 | Nor [that]. 50 | 51 | [Something in brackets like [this][] should work] 52 | 53 | [Same with [this].] 54 | 55 | In this case, [this](/somethingelse/) points to something else. 56 | 57 | Backslashing should suppress \[this] and [this\]. 58 | 59 | [this]: foo 60 | 61 | 62 | * * * 63 | 64 | Here's one where the [link 65 | breaks] across lines. 66 | 67 | Here's another where the [link 68 | breaks] across lines, but with a line-ending space. 69 | 70 | 71 | [link breaks]: /url/ 72 | -------------------------------------------------------------------------------- /avh4-lib/src/Data/List/Extra.hs: -------------------------------------------------------------------------------- 1 | module Data.List.Extra where 2 | 3 | import Elm.Utils ((|>)) 4 | import qualified Data.List as List 5 | 6 | 7 | pairs :: [a] -> [(a,a)] 8 | pairs input = 9 | let 10 | step next ( prev, acc ) = 11 | case prev of 12 | Nothing -> 13 | ( Just next, acc ) 14 | Just prev' -> 15 | ( Just next, ( next, prev' ) : acc ) 16 | in 17 | List.foldr step (Nothing, []) input 18 | |> snd 19 | 20 | 21 | intersperseMap :: (a -> a -> [b]) -> (a -> b) -> [a] -> [b] 22 | intersperseMap spacer fn list = 23 | case list of 24 | [] -> [] 25 | (first:_) -> 26 | fn first 27 | : (pairs list 28 | |> concatMap (\(a,b) -> spacer a b ++ [fn b])) 29 | 30 | 31 | shift :: a -> [(b,a)] -> ([(a,b)], a) 32 | shift a list = 33 | let 34 | init = (a, []) 35 | step (holdA, acc) (nextB, nextA) = 36 | (nextA, (holdA, nextB) : acc) 37 | done (holdA, acc) = 38 | (List.reverse acc, holdA) 39 | in 40 | List.foldl step init list 41 | |> done 42 | -------------------------------------------------------------------------------- /Release Notes/0.8.4.md: -------------------------------------------------------------------------------- 1 | ## Bug fixes and small improvements 2 | 3 | New features: 4 | - newlines in tuple types are now preserved 5 | - newlines in type constructor application are now preserved 6 | 7 | Bug fixes: 8 | - negative hex int literals are now handled correctly 9 | - in doc comments, special characters in link text are now handled more correctly 10 | - in doc comments, non-Elm code blocks are no longer elm-formatted 11 | - in doc comments, inline code containing backticks is now escaped correctly 12 | - in doc comments, relative links with text matching the relative URL are now handled correctly 13 | 14 | Other changes: 15 | - dropped support for 32-bit Windows (Windows CI platforms are no longer supporting it) 16 | 17 | 18 | ## Install 19 | 20 | ```sh 21 | npm install -g elm-format 22 | ``` 23 | 24 | or [download from the release page](https://github.com/avh4/elm-format/releases/tag/0.8.4). 25 | 26 | 27 | ## Thanks to ... 28 | 29 | - @rlefevre for the autolinks fix 30 | - @jasoncarr0, @woochica, and @mcnuttandrew for fixes to the installation instructions 31 | - @chshersh for his ["GitHub Actions for Haskell" template](https://kodimensional.dev/github-actions) 32 | -------------------------------------------------------------------------------- /parser/bench/src/SmallRecordBench.elm: -------------------------------------------------------------------------------- 1 | module SmallRecordBench where 2 | 3 | type alias SmallRecord = 4 | { myLargeNamedField1 : Float 5 | , myLargeNamedField2 : Float 6 | , myLargeNamedField3 : Float 7 | , myLargeNamedField4 : Float 8 | , myLargeNamedField5 : Float 9 | , myLargeNamedField6 : Float 10 | , myLargeNamedField7 : Float 11 | , myLargeNamedField8 : Float 12 | , myLargeNamedField9 : Float 13 | } 14 | 15 | defaultRec = 16 | SmallRecord 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 17 | 18 | getField i = 19 | case (i % 9) of 20 | 1 -> 21 | defaultRec.myLargeNamedField1 22 | 2 -> 23 | defaultRec.myLargeNamedField2 24 | 3 -> 25 | defaultRec.myLargeNamedField3 26 | 4 -> 27 | defaultRec.myLargeNamedField4 28 | 5 -> 29 | defaultRec.myLargeNamedField5 30 | 6 -> 31 | defaultRec.myLargeNamedField6 32 | 7 -> 33 | defaultRec.myLargeNamedField7 34 | 8 -> 35 | defaultRec.myLargeNamedField8 36 | 0 -> 37 | defaultRec.myLargeNamedField9 38 | 39 | 40 | sumRandomElems : List Int -> Float 41 | sumRandomElems randomInts = 42 | List.foldr (\i sumSoFar -> (getField i) + sumSoFar ) 0.0 randomInts -------------------------------------------------------------------------------- /Release Notes/0.8.1.md: -------------------------------------------------------------------------------- 1 | ## Autodetecting your Elm version 2 | 3 | Starting in `elm-format` 0.8.1, there is now only one official binary for each platform 4 | (previously there was a seperate binary for Elm 0.18 and Elm 0.19). 5 | `elm-format` now will auto-detect your Elm version using the following rules: 6 | 7 | - if `elm-package.json` exists in the current directory, format in Elm 0.18 mode 8 | - if `elm.json` exists in the current directory, format in Elm 0.19 mode 9 | 10 | If you need to run `elm-format` from a working directory that does not contain such a file 11 | (or if you need to use `elm-format` in Elm 0.17 mode), 12 | use the `--elm-version=...` command line argument to disable the autodetection. 13 | 14 | 15 | ## Other changes 16 | 17 | `elm-format` 0.8.1 also contains several bug fixes for `elm-format` 0.8.0. 18 | See the [CHANGELOG](https://github.com/avh4/elm-format/blob/0.8.1/CHANGELOG.md) for details. 19 | 20 | 21 | ## Install 22 | 23 | ```sh 24 | npm install -g elm-format 25 | ``` 26 | 27 | or [download from the release page](https://github.com/avh4/elm-format/releases/tag/0.8.1). 28 | 29 | 30 | ## Thanks to ... 31 | 32 | - @andys8 for contributing the lenient import line parser 33 | -------------------------------------------------------------------------------- /avh4-lib/src/Data/Text/Extra.hs: -------------------------------------------------------------------------------- 1 | module Data.Text.Extra (longestSpanOf, LongestSpanResult(..)) where 2 | 3 | import Elm.Utils ((|>)) 4 | 5 | import qualified Data.Text as Text 6 | import Data.Text (Text) 7 | import qualified Data.Maybe as Maybe 8 | 9 | 10 | data LongestSpanResult 11 | = NoSpan 12 | | Span Int {- >= 1 -} 13 | deriving (Eq, Show) 14 | 15 | 16 | longestSpanOf :: Char -> Text -> LongestSpanResult 17 | longestSpanOf char input = 18 | case Text.foldl' step (Nothing, 0) input |> endCurrentSpan of 19 | 0 -> NoSpan 20 | positive -> Span positive 21 | where 22 | step (currentSpan, longest) c = 23 | if c == char 24 | then 25 | ( Just (1 + Maybe.fromMaybe 0 currentSpan) 26 | , longest 27 | ) 28 | else 29 | ( -- clear the current span 30 | Nothing 31 | , -- and update the longest 32 | endCurrentSpan (currentSpan, longest) 33 | ) 34 | 35 | endCurrentSpan (Nothing, longest) = longest 36 | endCurrentSpan (Just current, longest) = max current longest 37 | -------------------------------------------------------------------------------- /package/elm-tooling/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euxo pipefail 3 | 4 | ELM_FORMAT_VERSION="$(git describe --abbrev=8)" 5 | BRANCH="elm-format-$ELM_FORMAT_VERSION" 6 | 7 | if [ ! -d elm-tooling ]; then 8 | git clone https://github.com/elm-tooling/elm-tooling-cli.git elm-tooling 9 | fi 10 | 11 | pushd elm-tooling 12 | git fetch origin main 13 | git reset --hard 14 | if git branch | grep " ${BRANCH}$"; then 15 | git checkout "$BRANCH" 16 | git reset --hard origin/main 17 | else 18 | git checkout -b "$BRANCH" origin/main 19 | git reset --hard 20 | fi 21 | popd 22 | 23 | 24 | ( 25 | sed -e '/^ "elm-format":/,$d' elm-tooling/src/KnownTools.ts 26 | sed -e '/^ "elm-format":/,/^ }/p;d' elm-tooling/src/KnownTools.ts | head -n-1 27 | ./generate.sh "$ELM_FORMAT_VERSION" | sed -e 's/^/ /' 28 | echo " }," 29 | sed -e '1,/^ "elm-format":/d;1,/^ }/d' elm-tooling/src/KnownTools.ts 30 | ) > tmp 31 | mv tmp elm-tooling/src/KnownTools.ts 32 | 33 | pushd elm-tooling 34 | npm ci 35 | # See https://elm-tooling.github.io/elm-tooling-cli/contributing/#adding-a-new-version 36 | ./node_modules/.bin/jest --updateSnapshot 37 | ./node_modules/.bin/ts-node scripts/TestAllDownloads.ts update 38 | npm test 39 | popd 40 | -------------------------------------------------------------------------------- /.github/workflows/Check published packages (nixpkgs).yml: -------------------------------------------------------------------------------- 1 | name: Check nixkpgs packages 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | nixpkgsChannel: 7 | required: true 8 | default: 'nixpkgs-unstable' 9 | package: 10 | required: true 11 | default: 'elmPackages.elm-format' 12 | 13 | jobs: 14 | build: 15 | strategy: 16 | matrix: 17 | os: 18 | - ubuntu-latest 19 | - macOS-latest 20 | 21 | name: ${{ matrix.os }} ${{ github.event.inputs.nixpkgsChannel }} 22 | runs-on: ${{ matrix.os }} 23 | 24 | steps: 25 | - uses: cachix/install-nix-action@v19 26 | with: 27 | nix_path: nixpkgs=channel:${{ github.event.inputs.nixpkgsChannel }} 28 | - name: Environment info 29 | run: | 30 | echo -n 'nixpkgs '; nix-instantiate --eval -E '(import {}).lib.version' 31 | nix --version 32 | - name: Fetch packages 33 | run: | 34 | nix-shell -p "${{ github.event.inputs.package }}" --run true 35 | - name: Check elm-format 36 | run: | 37 | nix-shell -p "${{ github.event.inputs.package }}" --run 'elm-format && file $(which elm-format)' 38 | -------------------------------------------------------------------------------- /.github/workflows/Check published packages (npm).yml: -------------------------------------------------------------------------------- 1 | name: Check npm packages 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | npmPackage: 7 | required: true 8 | default: 'elm-format@latest' 9 | 10 | jobs: 11 | build: 12 | strategy: 13 | matrix: 14 | os: 15 | - ubuntu-latest 16 | - windows-latest 17 | - macOS-latest 18 | 19 | name: ${{ matrix.os }} ${{ github.event.inputs.npmPackage }} 20 | runs-on: ${{ matrix.os }} 21 | 22 | steps: 23 | - name: Environment info 24 | run: | 25 | echo -n 'node: '; node --version 26 | echo -n 'npm: '; npm --version 27 | - name: Set up workspace 28 | run: | 29 | echo '{}' > package.json 30 | - name: Install ${{ github.event.inputs.npmPackage }} 31 | run: | 32 | npm install --save-dev "${{ github.event.inputs.npmPackage }}" 33 | - name: Check elm-format 34 | shell: bash # workaround for https://github.com/MicrosoftDocs/PowerShell-Docs/issues/2361 35 | run: | 36 | npm list -a 37 | ./node_modules/.bin/elm-format 38 | find . -type f -name 'elm-format*' -print0 | xargs -0 file 39 | -------------------------------------------------------------------------------- /nix/sources.json: -------------------------------------------------------------------------------- 1 | { 2 | "gitignore.nix": { 3 | "branch": "master", 4 | "description": "Nix functions for filtering local git sources", 5 | "homepage": "", 6 | "owner": "hercules-ci", 7 | "repo": "gitignore.nix", 8 | "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", 9 | "sha256": "02wxkdpbhlm3yk5mhkhsp3kwakc16xpmsf2baw57nz1dg459qv8w", 10 | "type": "tarball", 11 | "url": "https://github.com/hercules-ci/gitignore.nix/archive/637db329424fd7e46cf4185293b9cc8c88c95394.tar.gz", 12 | "url_template": "https://github.com///archive/.tar.gz" 13 | }, 14 | "nixpkgs": { 15 | "branch": "nixpkgs-unstable", 16 | "description": "Nix Packages collection", 17 | "homepage": "", 18 | "owner": "NixOS", 19 | "repo": "nixpkgs", 20 | "rev": "fe51d34885f7b5e3e7b59572796e1bcb427eccb1", 21 | "sha256": "0pg3ibyagan1y57l1q1rwyrygrwg02p59p0fbgl23hf1nw58asda", 22 | "type": "tarball", 23 | "url": "https://github.com/NixOS/nixpkgs/archive/fe51d34885f7b5e3e7b59572796e1bcb427eccb1.tar.gz", 24 | "url_template": "https://github.com///archive/.tar.gz" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /dev/Documentation/Signatures.md: -------------------------------------------------------------------------------- 1 | Cryptographic signatures are used to give some minimal validation that files have not changed unexpectedly. 2 | 3 | # Binaries from CI builds 4 | 5 | All CI runners have access to a private key 6 | that is used to sign all Release Build workflow artifacts. 7 | The set of runners currently includes GitHub hosted runners, 8 | and private runners provisioned by Lamdera. 9 | The public key is stored in `keys/gpg-actions.pub` 10 | and is used by `dev/build.sh publish-*` 11 | to verify the downloaded binaries before publishing. 12 | 13 | ## How to generate a new key 14 | 15 | 1. Remove the old key: 16 | - `rm ./keys/github-actions.pub` 17 | 1. Create the new key: 18 | - `minisign -G -W -s ./XXX_NEW_PRIVATE_KEY -p ./keys/github-actions.pub` 19 | 1. Get the private key: 20 | - `cat ./XXX_NEW_PRIVATE_KEY | base64` 21 | - Copy the result as the value of `MINISIGN_PRIVATE_KEY` at 22 | 1. Securely delete the private key: 23 | - `shred -uvz XXX_NEW_PRIVATE_KEY` 24 | 1. Check in the changes to `./keys/github-actions.pub` 25 | 1. Push to a branch whose name starts with "release/" to trigger the Build Release workflows, and make sure they succeed. 26 | -------------------------------------------------------------------------------- /tests/test-files/CommonMark/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var fs = require('fs'); 4 | var path = require('path'); 5 | 6 | var extractSpecTests = function(data) { 7 | var examples = []; 8 | var current_section = ""; 9 | var example_number = 0; 10 | var tests = data 11 | .replace(/\r\n?/g, "\n") // Normalize newlines for platform independence 12 | .replace(/^(.|[\n])*/m, ''); 13 | 14 | tests.replace(/^`{32} example\n([\s\S]*?)^\.\n([\s\S]*?)^`{32}$|^#{1,6} *(.*)$/gm, 15 | function(_, markdownSubmatch, htmlSubmatch, sectionSubmatch){ 16 | if (sectionSubmatch) { 17 | current_section = sectionSubmatch; 18 | } else { 19 | example_number++; 20 | examples.push({markdown: markdownSubmatch, 21 | html: htmlSubmatch, 22 | section: current_section, 23 | number: example_number}); 24 | } 25 | }); 26 | return examples; 27 | }; 28 | 29 | exports.text = fs.readFileSync(path.join(__dirname, 'spec.txt'), 'utf8'); 30 | exports.tests = extractSpecTests(exports.text); 31 | -------------------------------------------------------------------------------- /package/npm/elm-format-0.8.5-test.nix: -------------------------------------------------------------------------------- 1 | { 2 | name = "elm-format-test"; 3 | version = "0.8.5"; 4 | prerelease = "rc.3"; 5 | scope = "avh4"; 6 | binaryPackageScope = "avh4"; 7 | experimental = false; 8 | elmVersions = [ 9 | "0.18.0" 10 | "0.19.0" 11 | "0.19.1" 12 | ]; 13 | 14 | binaries = { 15 | linux-x64 = { 16 | v = "1"; 17 | url = "https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-linux-x64.tgz"; 18 | sha256 = "sha256-ZpUft1sRM5gJGDmAyrayIGmYRazoCJ/JFUtjWs/TKCU="; 19 | }; 20 | mac-x64 = { 21 | v = "1"; 22 | url = "https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-mac-x64.tgz"; 23 | sha256 = "sha256-gz1XExjxAwyHz+SxUzxxfXroxHUR/0Hp7l5jf7L2B44="; 24 | }; 25 | mac-arm64 = { 26 | v = "1"; 27 | url = "https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-mac-x64.tgz"; 28 | sha256 = "sha256-gz1XExjxAwyHz+SxUzxxfXroxHUR/0Hp7l5jf7L2B44="; 29 | }; 30 | win-x64 = { 31 | v = "1"; 32 | url = "https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-win-x64.zip"; 33 | sha256 = "sha256-caZuv5qoPaPSDcvjDEpwXz1b+77Us7jzfhIWoVvPOrE="; 34 | }; 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /Release Notes/0.8.7.md: -------------------------------------------------------------------------------- 1 | ## Small improvements and fixed npm installer for Windows 2 | 3 | Version 0.8.6 was not widely announced because of an issue with the npm installer on Windows, 4 | so check the [0.8.6 release notes](https://github.com/avh4/elm-format/releases/tag/0.8.6) as well. 5 | Below are the additional changes in 0.8.7. 6 | 7 | New features: 8 | - `case ... then` is now auto-corrected to `case ... of` 9 | - `=>` is now auto-corrected to `->` 10 | 11 | Bug fixes: 12 | - Top-level declarations named "infix" no longer make files unprocessable 13 | - The npm installer should now work correctly on Windows (was broken for 0.8.6) 14 | 15 | 16 | ## Install 17 | 18 | ```sh 19 | npm install -g elm-format 20 | ``` 21 | 22 | or [download from the release page](https://github.com/avh4/elm-format/releases/tag/0.8.7). 23 | 24 | 25 | ## Thanks to ... 26 | 27 | - @kutyel for lenient parsing additions 28 | - @emmabastas for the initial draft of test coverage scripts 29 | - @jfmengels for continued thoughtful issue discussion across the Elm devtools community (only partially related to elm-format, but thank you!) 30 | - @8n8 for code cleanup help 31 | - [Lamdera](https://www.lamdera.com/) for providing CI runners to build the MacOS ARM64 release binaries 32 | -------------------------------------------------------------------------------- /elm-format-markdown/tests/Original/Links_reference_style.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 |

Foo bar.

3 |

Foo bar.

4 |

With embedded [brackets].

5 |

Indented once.

6 |

Indented twice.

7 |

Indented thrice.

8 |

Indented [four][] times.

9 |
[four]: /url
10 | 
11 |
12 |

this should work

13 |

So should this.

14 |

And this.

15 |

And this.

16 |

And this.

17 |

But not [that] [].

18 |

Nor [that][].

19 |

Nor [that].

20 |

[Something in brackets like this should work]

21 |

[Same with this.]

22 |

In this case, this points to something else.

23 |

Backslashing should suppress [this] and [this].

24 |
25 |

Here's one where the link 26 | breaks across lines.

27 |

Here's another where the link 28 | breaks across lines, but with a line-ending space.

29 | -------------------------------------------------------------------------------- /tests/test-files/transform/Elm-0.18/UnnecessaryParens.formatted.elm: -------------------------------------------------------------------------------- 1 | module UnnecessaryParens exposing (unnecessaryParens) 2 | 3 | 4 | unnecessaryParens = 5 | ( "a" ++ f x y ++ "b" 6 | , f x y 7 | , x 8 | , [ 1, 2 ] 9 | , 1 + (x + 1) 10 | , { blah = foo << bar 11 | , stuff = 12 | if conditional then 13 | something 14 | 15 | else 16 | somethingElse 17 | , thing = doSomething (func arg) 18 | } 19 | , if x then 20 | something 21 | 22 | else 23 | somethingElse 24 | , case foo of 25 | () -> 26 | () 27 | , r.f1.f2.f3.f4 28 | , test "test" <| 29 | \() -> 30 | 1 |> Expect.equal 1 31 | ) 32 | 33 | 34 | allowedParens = 35 | ( (x + 1) + (y - 1) 36 | , () 37 | ) 38 | 39 | 40 | requiredParens = 41 | ( (maybeF |> Maybe.withDefault identity) 1 42 | , Ok <| ([ 1, 2, 3 ] |> List.tail) 43 | , () 44 | ) 45 | 46 | 47 | requiredParensForTrailingCommentsInBinopsContext = 48 | () 49 | |> (\() -> 50 | () 51 | -- comment stay here 52 | ) 53 | 54 | 55 | requiredParensForTrailingCommentsInDefBodyContext = 56 | (8 57 | -- comment stay here 58 | ) 59 | --------------------------------------------------------------------------------