Skip to content

Commit

Permalink
Eliminate -Wno-...
Browse files Browse the repository at this point in the history
Hack around orphan instance; don't turn warning on and off again.
  • Loading branch information
fisx committed Nov 21, 2024
1 parent df24967 commit 34e5646
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ldap-scim-bridge.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ common common-options
-O2 -Wall -Wcompat -Widentities -Wincomplete-uni-patterns
-Wincomplete-record-updates -Wpartial-fields -fwarn-tabs
-optP-Wno-nonportable-include-path -Wredundant-constraints
-fhide-source-paths -Wmissing-export-lists -Wpartial-fields
-fhide-source-paths -Wpartial-fields
-Wmissing-deriving-strategies

default-language: Haskell2010
Expand Down
26 changes: 15 additions & 11 deletions src/LdapScimBridge.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -Wno-orphans -Wno-missing-export-lists #-}

module LdapScimBridge where

Expand Down Expand Up @@ -151,18 +150,23 @@ data BridgeConf = BridgeConf
{ ldapSource :: LdapConf,
scimTarget :: ScimConf,
mapping :: Mapping,
logLevel :: Level
logLevel :: PhantomParent Level
}
deriving stock (Show, Generic)

instance Aeson.FromJSON Level where
parseJSON "Trace" = pure Trace
parseJSON "Debug" = pure Debug
parseJSON "Info" = pure Info
parseJSON "Warn" = pure Warn
parseJSON "Error" = pure Error
parseJSON "Fatal" = pure Fatal
parseJSON bad = fail $ "unknown Level: " <> show bad
newtype PhantomParent a = PhantomParent {unPhantomParent :: a}
deriving stock (Eq, Ord, Bounded, Show, Generic)

instance Aeson.FromJSON (PhantomParent Level) where
parseJSON =
fmap PhantomParent . \case
"Trace" -> pure Trace
"Debug" -> pure Debug
"Info" -> pure Info
"Warn" -> pure Warn
"Error" -> pure Error
"Fatal" -> pure Fatal
bad -> fail $ "unknown Level: " <> show bad

instance Aeson.FromJSON BridgeConf

Expand Down Expand Up @@ -521,7 +525,7 @@ mkLogger lvl = do
main :: IO ()
main = do
myconf :: BridgeConf <- parseCli
lgr :: Logger <- mkLogger (logLevel myconf)
lgr :: Logger <- mkLogger (unPhantomParent $ logLevel myconf)
lgr Debug $ show (mapping myconf)
updateScimPeer lgr myconf `catch` logErrors lgr
where
Expand Down

0 comments on commit 34e5646

Please sign in to comment.