chs-cabal-1.0.0.0: src/Distribution/C2Hs.hs
{-# LANGUAGE DataKinds #-}
module Distribution.C2Hs ( defaultMainC2Hs
-- * User hooks
, c2hsUserHooks
, c2hsSuffixHandler
) where
import Control.Applicative (pure)
import Data.Traversable (traverse)
import Distribution.C2Hs.TopSort
import Distribution.Simple (UserHooks (hookedPreProcessors),
defaultMainWithHooks,
simpleUserHooks)
import Distribution.Simple.PreProcess (PPSuffixHandler,
PreProcessor (ppOrdering),
Suffix (Suffix), ppC2hs)
defaultMainC2Hs :: IO ()
defaultMainC2Hs = defaultMainWithHooks c2hsUserHooks
-- | @since 0.1.1.0
c2hsUserHooks :: UserHooks
c2hsUserHooks = simpleUserHooks { hookedPreProcessors = [c2hsSuffixHandler] }
-- | 'PPSuffixHandler' for @.chs@ files that reorders based on imports
--
-- @since 1.0.0.0
c2hsSuffixHandler :: PPSuffixHandler
c2hsSuffixHandler = (Suffix ".chs", \bi lbi cbi -> (ppC2hs bi lbi cbi) { ppOrdering = reorderC2Hs })