Add fourmolu + hlint with scripts and git hooks (Atlas-style)

- Create scripts/build, scripts/test, scripts/run, scripts/install-hooks
- Create git-hooks/pre-commit (auto-format staged .hs files)
- Create git-hooks/pre-push (check formatting + hlint before push)
- Handle git worktrees correctly in hook installation
- Run fourmolu on all source files to fix existing formatting
This commit is contained in:
2026-05-18 22:24:59 -04:00
parent 235adce596
commit 9759a4c3a3
10 changed files with 278 additions and 148 deletions
+48 -44
View File
@@ -12,62 +12,66 @@ spec =
it "parses a single step of plain text" $ do
let input = "Hello, world."
expected =
Right Recipe
{ recipeMetadata = emptyMetadata
, recipeSections =
Section
{ sectionName = Nothing
, sectionSteps =
Step
{ unStep = [StepText "Hello, world."]
}
:| []
}
:| []
}
Right
Recipe
{ recipeMetadata = emptyMetadata
, recipeSections =
Section
{ sectionName = Nothing
, sectionSteps =
Step
{ unStep = [StepText "Hello, world."]
}
:| []
}
:| []
}
parseCookFile input `shouldBe` expected
it "parses multiple steps separated by a blank line" $ do
let input = "Wash the potatoes.\n\nPeel and dice them."
expected =
Right Recipe
{ recipeMetadata = emptyMetadata
, recipeSections =
Section
{ sectionName = Nothing
, sectionSteps =
Step {unStep = [StepText "Wash the potatoes."]}
:| [ Step {unStep = [StepText "Peel and dice them."]}
]
}
:| []
}
Right
Recipe
{ recipeMetadata = emptyMetadata
, recipeSections =
Section
{ sectionName = Nothing
, sectionSteps =
Step{unStep = [StepText "Wash the potatoes."]}
:| [ Step{unStep = [StepText "Peel and dice them."]}
]
}
:| []
}
parseCookFile input `shouldBe` expected
it "handles empty input by returning an empty recipe" $ do
let expected =
Right Recipe
{ recipeMetadata = emptyMetadata
, recipeSections =
Section
{ sectionName = Nothing
, sectionSteps = Step {unStep = []} :| []
}
:| []
}
Right
Recipe
{ recipeMetadata = emptyMetadata
, recipeSections =
Section
{ sectionName = Nothing
, sectionSteps = Step{unStep = []} :| []
}
:| []
}
parseCookFile "" `shouldBe` expected
it "trims leading and trailing whitespace from each step" $ do
let input = "\n\n Mix well. \n\n"
expected =
Right Recipe
{ recipeMetadata = emptyMetadata
, recipeSections =
Section
{ sectionName = Nothing
, sectionSteps =
Step {unStep = [StepText "Mix well."]} :| []
}
:| []
}
Right
Recipe
{ recipeMetadata = emptyMetadata
, recipeSections =
Section
{ sectionName = Nothing
, sectionSteps =
Step{unStep = [StepText "Mix well."]} :| []
}
:| []
}
parseCookFile input `shouldBe` expected