Skip to content

Commit

Permalink
Rewrite versionFromFile using maybe
Browse files Browse the repository at this point in the history
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 :)
  • Loading branch information
infinisil committed Aug 7, 2024
1 parent 47b9dc2 commit c37f999
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions main/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit c37f999

Please sign in to comment.