emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/haskell-tng-mode 60d8c20 149/385: indent "case of"


From: ELPA Syncer
Subject: [nongnu] elpa/haskell-tng-mode 60d8c20 149/385: indent "case of"
Date: Tue, 5 Oct 2021 23:59:20 -0400 (EDT)

branch: elpa/haskell-tng-mode
commit 60d8c20085f640d58be70d0546fee41e58952994
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>

    indent "case of"
---
 haskell-tng-smie.el                   |  5 +++--
 test/haskell-tng-indent-test.el       |  2 +-
 test/src/indentation.hs               |  8 ++++++++
 test/src/indentation.hs.append.indent | 18 +++++++++++++++++-
 test/src/indentation.hs.insert.indent | 18 +++++++++++++++++-
 test/src/indentation.hs.layout        |  8 ++++++++
 test/src/indentation.hs.lexer         |  8 ++++++++
 test/src/indentation.hs.reindent      | 18 +++++++++++++++++-
 test/src/indentation.hs.sexps         | 10 +++++++++-
 9 files changed, 88 insertions(+), 7 deletions(-)

diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index 1eaae2d..931283e 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -162,13 +162,14 @@ information, to aid in the creation of new rules."
 
     (:after
      (pcase arg
-       ((or "let" "do" "=" "in") 2)
+       ((or "let" "do" "of" "=" "in") 2)
        ("where" (if (smie-rule-parent-p "module") 0 2))
        ))
 
     (:before
      (pcase arg
-       ((or "{" "where" "do") (smie-rule-parent))
+       ;; encourages WLDOs to move to the left
+       ((or "{" "where" "do" "case") (smie-rule-parent))
        ))
 
     ))
diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el
index e230359..609423d 100644
--- a/test/haskell-tng-indent-test.el
+++ b/test/haskell-tng-indent-test.el
@@ -12,11 +12,11 @@
 (require 'haskell-tng-testutils
          "test/haskell-tng-testutils.el")
 
-;; TODO case statements
 ;; TODO LambdaCase
 ;; TODO coproduct definitions, the | should align with =
 ;; TODO lists, records, tuples
 ;; TODO long type signatures vs definitions
+;; TODO if/then/else
 
 ;; Three indentation regression tests are possible:
 ;;
diff --git a/test/src/indentation.hs b/test/src/indentation.hs
index 4b1e52a..556ec8c 100644
--- a/test/src/indentation.hs
+++ b/test/src/indentation.hs
@@ -45,3 +45,11 @@ let_in a b = let blah = bloo
                  wobble _ = fish
              in
                flibble blah
+
+case_of wibble = case wibble of
+  Nothing   -> ""
+  Just fish -> fish
+
+lambda_case = \case
+  Nothing   -> ""
+  Just fish -> fish
diff --git a/test/src/indentation.hs.append.indent 
b/test/src/indentation.hs.append.indent
index fdc3540..7f0072e 100644
--- a/test/src/indentation.hs.append.indent
+++ b/test/src/indentation.hs.append.indent
@@ -93,4 +93,20 @@ let_in a b = let blah = bloo
                flibble blah
 v            2 1 3
 
-v            1 2 3
\ No newline at end of file
+v            1 2 3
+case_of wibble = case wibble of
+1 v
+  Nothing   -> ""
+1 v
+  Just fish -> fish
+1 v
+
+1 v
+lambda_case = \case
+1             v
+  Nothing   -> ""
+v 1
+  Just fish -> fish
+v 1
+
+v 1
\ No newline at end of file
diff --git a/test/src/indentation.hs.insert.indent 
b/test/src/indentation.hs.insert.indent
index a834e52..c1bd0e3 100644
--- a/test/src/indentation.hs.insert.indent
+++ b/test/src/indentation.hs.insert.indent
@@ -91,4 +91,20 @@ let_in a b = let blah = bloo
              in
 2            1 v 3
                flibble blah
-v            2 1 3
\ No newline at end of file
+v            2 1 3
+
+v            1 2 3
+case_of wibble = case wibble of
+1 v
+  Nothing   -> ""
+1 v
+  Just fish -> fish
+1 v
+
+1 v
+lambda_case = \case
+1 2           v
+  Nothing   -> ""
+2 1            v
+  Just fish -> fish
+v 1
\ No newline at end of file
diff --git a/test/src/indentation.hs.layout b/test/src/indentation.hs.layout
index 6d190ec..79a7f3c 100644
--- a/test/src/indentation.hs.layout
+++ b/test/src/indentation.hs.layout
@@ -45,4 +45,12 @@ module Indentation where
                  ;wobble _ = fish
              }in
                flibble blah
+
+;case_of wibble = case wibble of
+  {Nothing   -> ""
+  ;Just fish -> fish
+
+};lambda_case = \case
+  Nothing   -> ""
+  Just fish -> fish
 }
\ No newline at end of file
diff --git a/test/src/indentation.hs.lexer b/test/src/indentation.hs.lexer
index 1fc5ad9..98e2525 100644
--- a/test/src/indentation.hs.lexer
+++ b/test/src/indentation.hs.lexer
@@ -45,4 +45,12 @@ where
 ; VARID _ = VARID
 } in
 VARID VARID
+
+; VARID VARID = case VARID of
+{ CONID -> §
+; CONID VARID -> VARID
+
+} ; VARID = \ case
+CONID -> §
+CONID VARID -> VARID
 }
diff --git a/test/src/indentation.hs.reindent b/test/src/indentation.hs.reindent
index e9b782c..a46a957 100644
--- a/test/src/indentation.hs.reindent
+++ b/test/src/indentation.hs.reindent
@@ -91,4 +91,20 @@ v            2   1
 v              2 1
              in
 2            1 v 3
-               flibble blah
\ No newline at end of file
+               flibble blah
+v            2 1 3
+
+v 1          2 3 4
+case_of wibble = case wibble of
+1 v
+  Nothing   -> ""
+v 1
+  Just fish -> fish
+1 v
+
+v 1
+lambda_case = \case
+1 2           v
+  Nothing   -> ""
+2 1            v
+  Just fish -> fish
\ No newline at end of file
diff --git a/test/src/indentation.hs.sexps b/test/src/indentation.hs.sexps
index e9fc86d..005753d 100644
--- a/test/src/indentation.hs.sexps
+++ b/test/src/indentation.hs.sexps
@@ -44,5 +44,13 @@
 )))(let_in) (a) (b) = (let ((blah) = (bloo)
                  ((wobble) (_) = (fish))
              )in)
-               (flibble) (blah)))))
+               (flibble) (blah)
+
+((case_of) (wibble) = ((case (wibble) (of)
+  ((Nothing)   -> ("")
+  ((Just) (fish) -> (fish))
+
+)(lambda_case) = (\)(case
+  (Nothing)   -> ("")
+  (Just) (fish) -> (fish)))))))))
 )))
\ No newline at end of file



reply via email to

[Prev in Thread] Current Thread [Next in Thread]