From 1d108f250755c893e93db97b2d1f3f21ba700a96 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Thu, 29 May 2025 22:43:36 +0300 Subject: [PATCH 1/2] Don't check for Haskell's "curly braces" indentation PureScript doesn't support "curly braces" mode as Haskell does, so the only thing the code did was introducing some bug where mixing let-in and case-of statements were breaking indentation. Credits to @purefunctor for the solution. Fixes: https://github.com/purescript-emacs/purescript-mode/issues/12 --- purescript-indentation.el | 4 +--- tests/purescript-indentation-tests.el | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/purescript-indentation.el b/purescript-indentation.el index ddfef9e..f972bff 100644 --- a/purescript-indentation.el +++ b/purescript-indentation.el @@ -762,9 +762,7 @@ indent the current line. This has to be fixed elsewhere." (throw 'parse-end nil))))) (defun purescript-indentation-layout (parser) - (if (string= current-token "{") - (purescript-indentation-list parser "}" ";" nil) - (purescript-indentation-implicit-layout-list parser))) + (purescript-indentation-implicit-layout-list parser)) (defun purescript-indentation-expression-token (token) (member token '("if" "let" "do" "case" "\\" "(" "[" "{" "::" diff --git a/tests/purescript-indentation-tests.el b/tests/purescript-indentation-tests.el index f2dac73..0cc77b0 100644 --- a/tests/purescript-indentation-tests.el +++ b/tests/purescript-indentation-tests.el @@ -237,3 +237,29 @@ foo = do identifier :: Array String <- function call _ <- another call pure unit")) + +(ert-deftest let-in-separate-lines () + "Tests bug #12" + (purescript-test-indentation " +test1 a += let { x } = a +in x" + +" +test1 a + = let { x } = a + in x")) + +(ert-deftest case-of-separate-lines () + "Tests bug #12" + (purescript-test-indentation " +test3 a += case a of +{ x: y } +-> y" + + " +test3 a + = case a of + { x: y } + -> y")) From 6ef23e7586ebc1d3ab3c07c1664adf3190ddf8b5 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Tue, 3 Jun 2025 20:10:14 +0300 Subject: [PATCH 2/2] Test another broken behavior about case-of followed by a list --- tests/purescript-indentation-tests.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/purescript-indentation-tests.el b/tests/purescript-indentation-tests.el index 0cc77b0..c3fd10f 100644 --- a/tests/purescript-indentation-tests.el +++ b/tests/purescript-indentation-tests.el @@ -263,3 +263,18 @@ test3 a = case a of { x: y } -> y")) + +(ert-deftest comma-first-list-after-case-of () + "A comma-first list was getting misindented if goes after case-of" + :expected-result :failed + (purescript-test-indentation " +fun = case _ of + [ a + , b ] +" + +" +fun = case _ of + [ a + , b ] +"))