branch: elpa/haskell-tng-mode commit 1cceb641101a41ee6187ea3997f36afc39ede379 Author: Tseen She <ts33n....@gmail.com> Commit: Tseen She <ts33n....@gmail.com>
cleaner tests --- README.md | 2 +- haskell-tng-compile.el | 6 ++--- haskell-tng-rx.el | 1 + haskell-tng-smie.el | 11 +++++--- test/haskell-tng-compile-test.el | 2 ++ test/haskell-tng-indent-test.el | 1 + test/src/indentation-options.hs | 20 ++------------ test/src/indentation-options.hs.append.indent | 38 +++------------------------ test/src/indentation-options.hs.insert.indent | 38 +++------------------------ test/src/indentation.hs | 16 ++--------- test/src/indentation.hs.append.indent | 32 +++------------------- test/src/indentation.hs.insert.indent | 30 +++------------------ test/src/indentation.hs.layout | 16 ++--------- test/src/indentation.hs.lexer | 12 --------- test/src/indentation.hs.sexps | 16 ++--------- test/src/indentation.hs.syntax | 12 --------- 16 files changed, 36 insertions(+), 217 deletions(-) diff --git a/README.md b/README.md index e55658c..0d69112 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Some blue sky features are being considered but may be best as independent proje - is there a solution to thinking "right to left" vs writing "left to right"? - identify trivial / helper functions and forward their `edit-definition` to another location. - Code gen - - `instance` boilerplate + - `instance` boilerplate (populate `where` with functions that are needed) - record of functions boilerplate - Refactoring - be compatible with [`apply-refact`](https://github.com/mpickering/apply-refact) / [`hlint-refactor-mode`](https://github.com/mpickering/hlint-refactor-mode) diff --git a/haskell-tng-compile.el b/haskell-tng-compile.el index b1147c0..b468553 100644 --- a/haskell-tng-compile.el +++ b/haskell-tng-compile.el @@ -35,12 +35,12 @@ (,(rx-to-string `(: bol ,file ":(" ,num "," ,num ")-(" ,num "," ,num ")" ,war)) 1 (2 . 4) (3 . 5) 1 1 (6 'compilation-warning)) - ;; tasty / hspec + ;; tasty / hspec and miscellaneous ghc extra info (,(rx-to-string - `(: bol (? (+ space) "error, called at") (+ space) ,file ":" ,num ":" ,num (? "-" ,num ":"))) + `(: bol (? (+ space) "error, called at") (+ space) (? "(") ,file ":" ,num ":" ,num (? "-" ,num ":"))) 1 2 (3 . 4) 2 1) (,(rx-to-string - `(: bol (? (+ space) "error, called at") (+ space) ,file ":(" ,num "," ,num ")-(" ,num "," ,num ")")) + `(: bol (? (+ space) "error, called at") (+ space) (? "(") ,file ":(" ,num "," ,num ")-(" ,num "," ,num ")")) 1 (2 . 4) (3 . 5) 2 1) ;; ghc information. diff --git a/haskell-tng-rx.el b/haskell-tng-rx.el index 1943ac1..b745715 100644 --- a/haskell-tng-rx.el +++ b/haskell-tng-rx.el @@ -80,6 +80,7 @@ give false positives." `(| (rx-to-string `(: word-start ,haskell-tng:rx:conid))) (defconst haskell-tng:regexp:varid (rx-to-string `(| (: word-start ,haskell-tng:rx:varid) + ;; TODO symids in brackets (==) (: symbol-start (char ??) ,haskell-tng:rx:varid) ;; ImplicitParams ))) (defconst haskell-tng:regexp:symid diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el index bdc4885..3bbdec4 100644 --- a/haskell-tng-smie.el +++ b/haskell-tng-smie.el @@ -30,7 +30,7 @@ (require 'haskell-tng-font-lock) (require 'haskell-tng-lexer) -;; TODO implement +;; TODO maybe autodetect? Then delete this user variable (defcustom haskell-tng-indent-aligntypes nil "Whether to align arrows to their parent :: declaration. @@ -44,7 +44,7 @@ foobar :: Monad m :type 'booleanp :group 'haskell-tng) -;; TODO implement +;; TODO maybe autodetect? Then delete this user variable (defcustom haskell-tng-indent-typelead 3 "Leading spaces in a trailing type signature, relative to type arrows. For example 3 and 1 are respectively: @@ -94,8 +94,11 @@ foobar1 :: (record (id "::" type) + ;; (id "=" id) precedence cycle: .| < ., < =. < .| + ;; TODO copy syntax { foo = ... }, maybe it needs a disambiguator ("{" record "}") - (record "," record)) + (record "," record) + ) ;; operators all have the same precedence (infixexp @@ -379,7 +382,7 @@ BEFORE is t if the line appears before the indentation." (while (< (point) bound) (when (not (looking-at - (rx (* space) (| "where" "let" "do") word-end))) + (rx (* space) (| "where" "do") word-end))) (push (current-indentation) relevant)) (when (and diff --git a/test/haskell-tng-compile-test.el b/test/haskell-tng-compile-test.el index 6f5d4c6..2208441 100644 --- a/test/haskell-tng-compile-test.el +++ b/test/haskell-tng-compile-test.el @@ -51,6 +51,8 @@ (should (have-expected-errors (testdata "compile/ghc-8.4.4-error.compile"))) (should (have-expected-errors (testdata "compile/ghc-8.4.4-errorspan.compile")))) +;; TODO test with multiline error info, e.g. toplevels with different param lengths + (ert-deftest haskell-tng-compile-warnings-file-tests () (should (have-expected-errors (testdata "compile/ghc-8.4.4-warning.compile"))) (should (have-expected-errors (testdata "compile/ghc-8.4.4-warningspan.compile")))) diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el index 907ba0f..a7909d4 100644 --- a/test/haskell-tng-indent-test.el +++ b/test/haskell-tng-indent-test.el @@ -15,6 +15,7 @@ ;; FIXME implement more indentation rules ;; ;; TODO multiline type signatures +;; TODO records of functions tests ;; TODO user config for typesig preference (incompatible versions) ;; TODO ImplicitParams in type signatures (without parens) ;; TODO if/then/else diff --git a/test/src/indentation-options.hs b/test/src/indentation-options.hs index 843e2c5..5b764fd 100644 --- a/test/src/indentation-options.hs +++ b/test/src/indentation-options.hs @@ -1,31 +1,15 @@ -- | Indentation scenarios to test indentation options. module Indentation where -typesig :: a -> b -> c - -types1 :: - Monad m - => a - -> b - -> c - -types2 :: +types4 :: ( Monad m ) => a -> b -> c -types3 :: (Monad m, MemberLogger m) - => a - -> b - -> c - -types4 :: Monad m +types5 :: Monad m => (?log :: HasLogger m) => a -> b -> c -types5 :: (Monad m, MonadReader Foo m) => - (?log :: HasLogger m) => - a -> b -> c diff --git a/test/src/indentation-options.hs.append.indent b/test/src/indentation-options.hs.append.indent index 552f7ad..6f0976c 100644 --- a/test/src/indentation-options.hs.append.indent +++ b/test/src/indentation-options.hs.append.indent @@ -4,23 +4,7 @@ module Indentation where v v -typesig :: a -> b -> c -1 v - -1 v -types1 :: -1 v - Monad m -2 v 1 - => a -1 v 2 - -> b -1 v 2 - -> c -1 v 2 - -1 v 2 -types2 :: +types4 :: 1 v ( Monad m ) 2 v1 @@ -32,17 +16,7 @@ types2 :: 1 v2 1 v2 -types3 :: (Monad m, MemberLogger m) -1 v - => a -1 v - -> b -1 v - -> c -1 v - -1 v -types4 :: Monad m +types5 :: Monad m 1 v => (?log :: HasLogger m) 1 v @@ -54,11 +28,5 @@ types4 :: Monad m 1 v 1 v -types5 :: (Monad m, MonadReader Foo m) => -1 v - (?log :: HasLogger m) => -1 v - a -> b -> c -1 v -1 v \ No newline at end of file +1 v \ No newline at end of file diff --git a/test/src/indentation-options.hs.insert.indent b/test/src/indentation-options.hs.insert.indent index e81ccd9..f119ceb 100644 --- a/test/src/indentation-options.hs.insert.indent +++ b/test/src/indentation-options.hs.insert.indent @@ -4,23 +4,7 @@ module Indentation where v v -typesig :: a -> b -> c -1 v - -v -types1 :: -1 v - Monad m -2 v 1 - => a -1 v 2 - -> b -1 v 2 - -> c -1 v 2 - -v 1 2 -types2 :: +types4 :: 2 1 v ( Monad m ) 2 v1 @@ -32,17 +16,7 @@ types2 :: 1 v2 v 12 -types3 :: (Monad m, MemberLogger m) -2 1 v - => a -1 v - -> b -1 v - -> c -1 v - -v 1 -types4 :: Monad m +types5 :: Monad m 2 1 v => (?log :: HasLogger m) 1 v @@ -53,10 +27,4 @@ types4 :: Monad m -> c 1 v -v 1 -types5 :: (Monad m, MonadReader Foo m) => -2 v1 - (?log :: HasLogger m) => -1 v - a -> b -> c -v 1 \ No newline at end of file +v 1 \ No newline at end of file diff --git a/test/src/indentation.hs b/test/src/indentation.hs index 18a7ee3..c9865cd 100644 --- a/test/src/indentation.hs +++ b/test/src/indentation.hs @@ -130,23 +130,11 @@ types1 :: -> b -> c -types2 :: - ( Monad m ) +types2 :: (Monad m, MemberLogger m) => a -> b -> c -types3 :: (Monad m, MemberLogger m) - => a - -> b - -> c - -types4 :: Monad m - => (?log :: HasLogger m) - => a - -> b - -> c - -types5 :: (Monad m, MonadReader Foo m) => +types3 :: (Monad m, MonadReader Foo m) => (?log :: HasLogger m) => a -> b -> c diff --git a/test/src/indentation.hs.append.indent b/test/src/indentation.hs.append.indent index 48bdce9..9eaada9 100644 --- a/test/src/indentation.hs.append.indent +++ b/test/src/indentation.hs.append.indent @@ -99,9 +99,9 @@ let_in a b = let implicit_let foo bar = 1 v let ?foo = foo -1 v +2 1 v ?bar = bar -1 v +1 2 v in rar v 1 2 @@ -262,19 +262,7 @@ types1 :: 1 v 2 1 v 2 -types2 :: -1 v - ( Monad m ) -2 v1 - => a -1 v2 - -> b -1 v2 - -> c -1 v2 - -1 v2 -types3 :: (Monad m, MemberLogger m) +types2 :: (Monad m, MemberLogger m) 1 v => a 1 v @@ -284,19 +272,7 @@ types3 :: (Monad m, MemberLogger m) 1 v 1 v -types4 :: Monad m -1 v - => (?log :: HasLogger m) -1 v - => a -1 v - -> b -1 v - -> c -1 v - -1 v -types5 :: (Monad m, MonadReader Foo m) => +types3 :: (Monad m, MonadReader Foo m) => 1 v (?log :: HasLogger m) => 1 v diff --git a/test/src/indentation.hs.insert.indent b/test/src/indentation.hs.insert.indent index 2fee7d3..9b29da9 100644 --- a/test/src/indentation.hs.insert.indent +++ b/test/src/indentation.hs.insert.indent @@ -99,7 +99,7 @@ let_in a b = let implicit_let foo bar = 2 v 1 let ?foo = foo -1 v +2 1 v ?bar = bar 2 1 v in rar @@ -262,19 +262,7 @@ types1 :: 1 v 2 v 1 2 -types2 :: -2 1 v - ( Monad m ) -2 v1 - => a -1 v2 - -> b -1 v2 - -> c -1 v2 - -v 12 -types3 :: (Monad m, MemberLogger m) +types2 :: (Monad m, MemberLogger m) 2 1 v => a 1 v @@ -284,19 +272,7 @@ types3 :: (Monad m, MemberLogger m) 1 v v 1 -types4 :: Monad m -2 1 v - => (?log :: HasLogger m) -1 v - => a -1 v - -> b -1 v - -> c -1 v - -v 1 -types5 :: (Monad m, MonadReader Foo m) => +types3 :: (Monad m, MonadReader Foo m) => 2 v1 (?log :: HasLogger m) => 1 v diff --git a/test/src/indentation.hs.layout b/test/src/indentation.hs.layout index 25f1b7b..e9c5438 100644 --- a/test/src/indentation.hs.layout +++ b/test/src/indentation.hs.layout @@ -130,24 +130,12 @@ module Indentation where -> b -> c -;types2 :: - ( Monad m ) +;types2 :: (Monad m, MemberLogger m) => a -> b -> c -;types3 :: (Monad m, MemberLogger m) - => a - -> b - -> c - -;types4 :: Monad m - => (?log :: HasLogger m) - => a - -> b - -> c - -;types5 :: (Monad m, MonadReader Foo m) => +;types3 :: (Monad m, MonadReader Foo m) => (?log :: HasLogger m) => a -> b -> c } \ No newline at end of file diff --git a/test/src/indentation.hs.lexer b/test/src/indentation.hs.lexer index a584362..0836754 100644 --- a/test/src/indentation.hs.lexer +++ b/test/src/indentation.hs.lexer @@ -130,23 +130,11 @@ CONID VARID => VARID => VARID -; VARID :: -« CONID VARID » -=> VARID -=> VARID -=> VARID - ; VARID :: « CONID VARID , CONID VARID » => VARID => VARID => VARID -; VARID :: CONID VARID -=> « VARID :: CONID VARID » -=> VARID -=> VARID -=> VARID - ; VARID :: « CONID VARID , CONID CONID VARID » => « VARID :: CONID VARID » => VARID => VARID => VARID diff --git a/test/src/indentation.hs.sexps b/test/src/indentation.hs.sexps index 0df94ee..3679272 100644 --- a/test/src/indentation.hs.sexps +++ b/test/src/indentation.hs.sexps @@ -130,24 +130,12 @@ -> (b) -> (c)) -((types2) :: - ( (Monad) (m) ) +((types2) :: ((Monad) (m), (MemberLogger) (m)) => (a) -> (b) -> (c)) -((types3) :: ((Monad) (m), (MemberLogger) (m)) - => (a) - -> (b) - -> (c)) - -((types4) :: (Monad) (m) - => ((?log) :: (HasLogger) (m)) - => (a) - -> (b) - -> (c)) - -((types5) :: ((Monad) (m), (MonadReader) (Foo) (m)) => +((types3) :: ((Monad) (m), (MonadReader) (Foo) (m)) => ((?log) :: (HasLogger) (m)) => (a) -> (b) -> (c)))))))))))))) ))) \ No newline at end of file diff --git a/test/src/indentation.hs.syntax b/test/src/indentation.hs.syntax index 40e2ef0..8a59b88 100644 --- a/test/src/indentation.hs.syntax +++ b/test/src/indentation.hs.syntax @@ -130,23 +130,11 @@ wwwwww __> __ w> __ w> > -wwwwww __> - ( wwwww w )> - __ w> - __ w> - __ w> -> wwwwww __ (wwwww w. wwwwwwwwwwww w)> __ w> __ w> __ w> > -wwwwww __ wwwww w> - __ (_www __ wwwwwwwww w)> - __ w> - __ w> - __ w> -> wwwwww __ (wwwww w. wwwwwwwwwww www w) __> (_www __ wwwwwwwww w) __> w __ w __ w>