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

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

[nongnu] elpa/haskell-tng-mode 0d5e020 151/385: support LambdaCase


From: ELPA Syncer
Subject: [nongnu] elpa/haskell-tng-mode 0d5e020 151/385: support LambdaCase
Date: Tue, 5 Oct 2021 23:59:20 -0400 (EDT)

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

    support LambdaCase
---
 haskell-tng-layout.el                 | 6 ++++--
 haskell-tng-rx.el                     | 1 +
 haskell-tng-smie.el                   | 7 ++++++-
 test/haskell-tng-indent-test.el       | 1 -
 test/src/indentation.hs.append.indent | 8 ++++----
 test/src/indentation.hs.insert.indent | 6 +++---
 test/src/indentation.hs.layout        | 6 +++---
 test/src/indentation.hs.lexer         | 8 ++++----
 test/src/indentation.hs.reindent      | 4 ++--
 test/src/indentation.hs.sexps         | 8 ++++----
 test/src/medley.hs                    | 4 ++++
 test/src/medley.hs.faceup             | 4 ++++
 test/src/medley.hs.layout             | 4 ++++
 test/src/medley.hs.lexer              | 4 ++++
 test/src/medley.hs.syntax             | 4 ++++
 15 files changed, 51 insertions(+), 24 deletions(-)

diff --git a/haskell-tng-layout.el b/haskell-tng-layout.el
index 9d2cd7f..106bccd 100644
--- a/haskell-tng-layout.el
+++ b/haskell-tng-layout.el
@@ -50,7 +50,6 @@ the layout engine."
 ;; TODO a visual debugging option would be great, showing virtuals as overlays
 
 ;; EXT:NonDecreasingIndentation
-;; EXT:LambdaCase
 
 (defun haskell-tng-layout:virtuals-at-point ()
   "List of virtual `{' `}' and `;' at point, according to the
@@ -99,7 +98,10 @@ Designed to be called repeatedly, managing its own caching."
     (while (not (eobp))
       (forward-comment (point-max))
       (cond
-       ((looking-at (rx word-start (| "where" "let" "do" "of") word-end))
+       ((looking-at (rx symbol-start
+                        (| "\\case" ;; LambdaCase
+                           "where" "let" "do" "of")
+                        word-end))
         (goto-char (match-end 0))
         (forward-comment (point-max))
         (when (not (looking-at "{"))
diff --git a/haskell-tng-rx.el b/haskell-tng-rx.el
index eb4ab74..a5135a7 100644
--- a/haskell-tng-rx.el
+++ b/haskell-tng-rx.el
@@ -39,6 +39,7 @@ give false positives." `(|
           "infixr" "instance" "let" "module" "newtype" "of"
           "then" "type" "where" "_")
        word-end)
+    (: symbol-start "\\case" word-end) ;; LambdaCase
     (: "{..}") ;; RecordWildCards
     (: word-start "':" symbol-end) ;; DataKinds (consider foo':bar)
     (: ,(if hack
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index 1ed75d7..476e837 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -76,7 +76,9 @@
        ("let" blk "in")
        ("let" blk)
        ("do" blk)
-       ("case" id "of" blk))
+       ("case" id "of" blk)
+       ("\\case" blk) ;; LambdaCase
+       )
       (blk
        ("{" blk "}")
        (blk ";" blk)
@@ -163,6 +165,7 @@ information, to aid in the creation of new rules."
     (:after
      (pcase arg
        ((or "let" "do" "of" "=" "in") 2)
+       ("\\case" 2) ;; LambdaCase
        ("where" (if (smie-rule-parent-p "module") 0 2))
        ))
 
@@ -180,6 +183,8 @@ information, to aid in the creation of new rules."
        ;;               bloo = blu
        ((or "{" "where" "let" "do" "case")
         (smie-rule-parent))
+       ("\\case" ;; LambdaCase
+        (smie-rule-parent))
        ))
 
     ))
diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el
index 609423d..3ed324b 100644
--- a/test/haskell-tng-indent-test.el
+++ b/test/haskell-tng-indent-test.el
@@ -12,7 +12,6 @@
 (require 'haskell-tng-testutils
          "test/haskell-tng-testutils.el")
 
-;; TODO LambdaCase
 ;; TODO coproduct definitions, the | should align with =
 ;; TODO lists, records, tuples
 ;; TODO long type signatures vs definitions
diff --git a/test/src/indentation.hs.append.indent 
b/test/src/indentation.hs.append.indent
index d5af495..e671bed 100644
--- a/test/src/indentation.hs.append.indent
+++ b/test/src/indentation.hs.append.indent
@@ -105,10 +105,10 @@ case_of wibble = case wibble of
 
 1 v
 lambda_case = \case
-1             v
+1 v
   Nothing   -> ""
-v 1
+1 v
   Just fish -> fish
-v 1
+1 v
 
-v 1
\ No newline at end of file
+1 v
\ No newline at end of file
diff --git a/test/src/indentation.hs.insert.indent 
b/test/src/indentation.hs.insert.indent
index 1f01887..7d32101 100644
--- a/test/src/indentation.hs.insert.indent
+++ b/test/src/indentation.hs.insert.indent
@@ -105,8 +105,8 @@ case_of wibble = case wibble of
 
 1 v
 lambda_case = \case
-1 2           v
+1 v
   Nothing   -> ""
-2 1            v
+1 v
   Just fish -> fish
-v 1
\ No newline at end of file
+1 v
\ No newline at end of file
diff --git a/test/src/indentation.hs.layout b/test/src/indentation.hs.layout
index f4b88aa..a142e23 100644
--- a/test/src/indentation.hs.layout
+++ b/test/src/indentation.hs.layout
@@ -52,6 +52,6 @@ module Indentation where
   ;Just fish -> fish
 
 };lambda_case = \case
-  Nothing   -> ""
-  Just fish -> fish
-}
\ No newline at end of file
+  {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 e08c25a..00f4e22 100644
--- a/test/src/indentation.hs.lexer
+++ b/test/src/indentation.hs.lexer
@@ -51,7 +51,7 @@ VARID VARID
 { CONID -> §
 ; CONID VARID -> VARID
 
-} ; VARID = \ case
-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 37a2177..8695185 100644
--- a/test/src/indentation.hs.reindent
+++ b/test/src/indentation.hs.reindent
@@ -106,7 +106,7 @@ v 1
 
 v 1
 lambda_case = \case
-1 2           v
+1 v
   Nothing   -> ""
-2 1            v
+v 1
   Just fish -> fish
\ No newline at end of file
diff --git a/test/src/indentation.hs.sexps b/test/src/indentation.hs.sexps
index fa270e1..e503f2e 100644
--- a/test/src/indentation.hs.sexps
+++ b/test/src/indentation.hs.sexps
@@ -51,7 +51,7 @@
   ((Nothing)   -> ("")
   ((Just) (fish) -> (fish))
 
-)(lambda_case) = (\)(case
-  (Nothing)   -> ("")
-  (Just) (fish) -> (fish)))))))))
-)))
\ No newline at end of file
+)(lambda_case) = (\(case
+  ((Nothing)   -> ("")
+  ((Just) (fish) -> (fish))
+)))))))))))))
\ No newline at end of file
diff --git a/test/src/medley.hs b/test/src/medley.hs
index 7e91619..7c76ec4 100644
--- a/test/src/medley.hs
+++ b/test/src/medley.hs
@@ -145,4 +145,8 @@ foo = do
 
 test = 1 `shouldBe` 1
 
+cases = \case
+  Nothing -> "no"
+  Just _  -> "yes"
+
 bar = do -- an incomplete do block
diff --git a/test/src/medley.hs.faceup b/test/src/medley.hs.faceup
index 31e7b83..ec46a15 100644
--- a/test/src/medley.hs.faceup
+++ b/test/src/medley.hs.faceup
@@ -145,5 +145,9 @@
 
 «:haskell-tng:toplevel:test» «:haskell-tng:keyword:=» 1 `shouldBe` 1
 
+«:haskell-tng:toplevel:cases» «:haskell-tng:keyword:=» 
«:haskell-tng:keyword:\case»
+  «:haskell-tng:constructor:Nothing» «:haskell-tng:keyword:->» «s:"no"»
+  «:haskell-tng:constructor:Just» «:haskell-tng:keyword:_»  
«:haskell-tng:keyword:->» «s:"yes"»
+
 «:haskell-tng:toplevel:bar» «:haskell-tng:keyword:=» «:haskell-tng:keyword:do» 
«m:-- »«x:an incomplete do block
 »
\ No newline at end of file
diff --git a/test/src/medley.hs.layout b/test/src/medley.hs.layout
index e87c3c5..c5ad093 100644
--- a/test/src/medley.hs.layout
+++ b/test/src/medley.hs.layout
@@ -145,5 +145,9 @@ module Foo.Bar.Main
 
 }};test = 1 `shouldBe` 1
 
+;cases = \case
+  Nothing -> "no"
+  Just _  -> "yes"
+
 ;bar = do -- an incomplete do block
 {}}
\ No newline at end of file
diff --git a/test/src/medley.hs.lexer b/test/src/medley.hs.lexer
index dfbc55a..53f2eba 100644
--- a/test/src/medley.hs.lexer
+++ b/test/src/medley.hs.lexer
@@ -145,5 +145,9 @@ CONSYM CONID « CONID » « CONID CONID »
 
 } } ; VARID = 1 SYMID 1
 
+; VARID = \case
+CONID -> §
+CONID _ -> §
+
 ; VARID = do
 { } }
diff --git a/test/src/medley.hs.syntax b/test/src/medley.hs.syntax
index 614e97c..496dba9 100644
--- a/test/src/medley.hs.syntax
+++ b/test/src/medley.hs.syntax
@@ -145,4 +145,8 @@ www _ ww>
 >
 wwww _ w $wwwwwwww$ w>
 >
+wwwww _ _wwww>
+  wwwwwww __ "ww">
+  wwww w  __ "www">
+>
 www _ ww __ ww wwwwwwwwww ww wwwww>



reply via email to

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