{- | This module provides a drop-in replacement for Cabal's 'defaultMain', to be used inside 'Setup.hs'
     modules of packages that wants to use the \"dev mode\". For more information, visit the documentation,
     especially the \"Developers' guide\".
-}

{-# LANGUAGE LambdaCase #-}
module Language.Haskell.Liquid.Cabal (liquidHaskellMain) where

import Distribution.Simple
import System.Environment

liquidHaskellMain :: IO ()
liquidHaskellMain :: IO ()
liquidHaskellMain = do
  Maybe String
mbDevMode <- String -> IO (Maybe String)
lookupEnv String
"LIQUID_DEV_MODE"
  UserHooks -> IO ()
defaultMainWithHooks (Maybe String -> UserHooks
devModeHooks Maybe String
mbDevMode)

devModeHooks :: Maybe String -> UserHooks
devModeHooks :: Maybe String -> UserHooks
devModeHooks = \case
  Maybe String
Nothing               -> UserHooks
simpleUserHooks
  Just String
x | String
x forall a. Eq a => a -> a -> Bool
== String
"false" -> UserHooks
simpleUserHooks
  Just String
_                -> UserHooks
simpleUserHooks { buildHook :: PackageDescription
-> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()
buildHook = \PackageDescription
_ LocalBuildInfo
_ UserHooks
_ BuildFlags
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return () }