{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeFamilies #-}
module Development.Shake.Cabal.Oracles ( hsOracle
, cabalOracle
, HsCompiler (..)
, CabalVersion (..)
) where
import Control.DeepSeq (NFData)
import Data.Binary (Binary)
import Data.Hashable (Hashable)
import Data.Typeable (Typeable)
import Development.Shake
import GHC.Generics (Generic)
hsOracle :: (RuleResult q ~ a, q ~ a, ShakeValue q) => Rules (q -> Action a)
hsOracle = addOracle pure
cabalOracle :: Rules (CabalVersion -> Action String)
cabalOracle = addOracle $ \CabalVersion -> do
(Stdout out) <- command [] "cabal" [ "--numeric-version"]
pure out
data HsCompiler = GHC { _pref :: Maybe String
, _suff :: Maybe String
}
| GHCJS { _suff :: Maybe String
}
deriving (Generic, Show, Eq, NFData, Hashable, Binary, Typeable)
data CabalVersion = CabalVersion
deriving (Generic, Show, Typeable, Eq, Hashable, Binary, NFData)
type instance RuleResult HsCompiler = HsCompiler
type instance RuleResult CabalVersion = String