From 5a1e31b42dd07ed8609207a76a7054d403e522cf Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 12 Dec 2011 10:42:46 +0100
Subject: [PATCH] Add infrastructure for, and two extra hlint rules

This will allow us to easily use add new lint rules that we
standardise on, if any.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 Makefile.am          | 6 ++++--
 htools/lint-hints.hs | 6 ++++++
 2 files changed, 10 insertions(+), 2 deletions(-)
 create mode 100644 htools/lint-hints.hs

diff --git a/Makefile.am b/Makefile.am
index 1c91d4005..89f5bf33f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -595,7 +595,8 @@ EXTRA_DIST = \
 	qa/qa-sample.json \
 	$(qa_scripts) \
 	$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
-	$(HS_PROG_SRCS)
+	$(HS_PROG_SRCS) \
+	htools/lint-hints.hs
 
 man_MANS = \
 	man/ganeti.7 \
@@ -1168,7 +1169,7 @@ lint: $(BUILT_SOURCES)
 	  --rcfile  ../pylintrc $(patsubst qa/%.py,%,$(qa_scripts))
 
 .PHONY: hlint
-hlint: $(HS_BUILT_SRCS)
+hlint: $(HS_BUILT_SRCS) htools/lint-hints.hs
 	if tty -s; then C="-c"; else C=""; fi; \
 	hlint --report=doc/hs-lint.html --cross $$C \
 	  --ignore "Use first" \
@@ -1176,6 +1177,7 @@ hlint: $(HS_BUILT_SRCS)
 	  --ignore "Use on" \
 	  --ignore "Use Control.Exception.catch" \
 	  --ignore "Reduce duplication" \
+	  --hint htools/lint-hints \
 	  $(filter-out htools/Ganeti/THH.hs,$(HS_LIB_SRCS))
 
 # a dist hook rule for updating the vcs-version file; this is
diff --git a/htools/lint-hints.hs b/htools/lint-hints.hs
new file mode 100644
index 000000000..fd110f87d
--- /dev/null
+++ b/htools/lint-hints.hs
@@ -0,0 +1,6 @@
+-- The following two hints warn to simplify e.g. "map (\v -> (v,
+-- True)) lst" to "zip lst (repeat True)", which is more abstract
+warn = map (\v -> (v, x)) y ==> zip y (repeat x)
+  where _ = notIn v x
+warn = map (\v -> (x, v)) ==> zip (repeat x)
+  where _ = notIn v x
-- 
GitLab