{-# OPTIONS_GHC -Wno-orphans #-}

module Data.Record.Plugin.WithRDP (
    -- * Annotations
    WithoutRDP.LargeRecordOptions(..)
  , WithoutRDP.largeRecord
    -- * For use by ghc
  , plugin
  ) where

import Control.Monad

import qualified RecordDotPreprocessor as RDP

import Data.Record.Internal.GHC.Shim

import qualified Data.Record.Plugin as WithoutRDP

plugin :: Plugin
plugin :: Plugin
plugin = Plugin
WithoutRDP.plugin Plugin -> Plugin -> Plugin
forall a. Semigroup a => a -> a -> a
<> Plugin
RDP.plugin

-- | Limited 'Semigroup' instance that defines just enough to combine
-- @large-records@ and @record-dot-preprocessor@
instance Semigroup Plugin where
  Plugin
p <> :: Plugin -> Plugin -> Plugin
<> Plugin
q = Plugin
defaultPlugin {
      parsedResultAction = \[CommandLineOption]
args ModSummary
summary ->
            Plugin
-> [CommandLineOption]
-> ModSummary
-> ParsedResult
-> Hsc ParsedResult
parsedResultAction Plugin
p [CommandLineOption]
args ModSummary
summary
        (ParsedResult -> Hsc ParsedResult)
-> (ParsedResult -> Hsc ParsedResult)
-> ParsedResult
-> Hsc ParsedResult
forall (m :: Type -> Type) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> Plugin
-> [CommandLineOption]
-> ModSummary
-> ParsedResult
-> Hsc ParsedResult
parsedResultAction Plugin
q [CommandLineOption]
args ModSummary
summary
    , pluginRecompile = \[CommandLineOption]
args ->
            PluginRecompile -> PluginRecompile -> PluginRecompile
forall a. Semigroup a => a -> a -> a
(<>)
        (PluginRecompile -> PluginRecompile -> PluginRecompile)
-> IO PluginRecompile -> IO (PluginRecompile -> PluginRecompile)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Plugin -> [CommandLineOption] -> IO PluginRecompile
pluginRecompile Plugin
p [CommandLineOption]
args
        IO (PluginRecompile -> PluginRecompile)
-> IO PluginRecompile -> IO PluginRecompile
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Plugin -> [CommandLineOption] -> IO PluginRecompile
pluginRecompile Plugin
q [CommandLineOption]
args
    }