From c37f999b60b1c04113996120a49217a0c0351d38 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Wed, 7 Aug 2024 23:29:31 +0200 Subject: [PATCH] Rewrite versionFromFile using maybe To avoid this warning: main/Main.hs:54:3: warning: [-Woverlapping-patterns] Pattern match is redundant In a case alternative: Just ver -> ... | 54 | Just ver -> unpack ver | ^^^^^^^^^^^^^^^^^^^^^^ Which happens because to the compiler, the Template Haskell expression looks like a constant, always making one pattern redundant. It won't dig into that if we use a function on it though :) --- main/Main.hs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/main/Main.hs b/main/Main.hs index d7348a6e..3f26a470 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -50,9 +50,7 @@ data Nixfmt = Nixfmt deriving (Show, Data, Typeable) versionFromFile :: String -versionFromFile = case $(embedFileIfExists ".version") of - Just ver -> unpack ver - _ -> showVersion version +versionFromFile = maybe (showVersion version) unpack $(embedFileIfExists ".version") options :: Nixfmt options =