[Haskell-cafe] Re: How to customize dyre recompile?

Andy Stewart lazycat.manatee at gmail.com
Sun Sep 6 13:17:57 EDT 2009


Will Donnelly <will.donnelly at gmail.com> writes:

Hi Will,
> Hi Andy,
>
> I feel that I should offer a disclaimer here: You are misusing Dyre
> somewhat by attempting to make it handle whole-program recompilation.
> It is designed to recompile a single configuration file, generally
> against an installed library form of the application. Some of its
> code, specifically the part that decides when to recompile, is based
> almost entirely on this assumption.
I use dyre for develop dynamic gtk application, so i hope dyre do
whole-program recompilaton and just recompile necessary files.
Just recompile single file or force recompile all modules is not my desire.

It's better if dyre's support single file recompliation and whole-program
recompilation, isn't? :)

>
> That aside, you should be able to accomplish your goals like this:
>
> 1. Set the 'forceRecomp' parameter (just added in Dyre 0.7.3) to
> 'False'. This will remove the '-fforce-recomp' flag from GHC's
> options.
> 2. Run your executable with the '--force-reconf' flag, which will
> cause Dyre to always enter the recompilation code.
Now i use below code finish work:
------------------------------> code start <------------------------------
rebootParams :: Params Config
rebootParams = defaultParams
    {projectName = "Main"
    ,realMain    = manatee
    ,showError   = rebootShowError
    ,cacheDir    = Just $ return "/test/Download/cache/"
    ,configDir   = Just getCurrentDirectory
    ,forceRecomp = False        -- don't recompile all modules, steup for recompile whole-program
    }

rebootOptions :: Maybe [String]
rebootOptions = Just ["--force-reconf"]

rebootShowError :: Config -> String -> Config
rebootShowError cfg msg = cfg {errorMsg = Just msg}

reboot :: IORefObject -> IO ()
reboot ioRefObject = do
  rs <- rebootGetState ioRefObject
  relaunchWithBinaryState rs rebootOptions
------------------------------> code end   <------------------------------

BTW, looks dyre don't recommand user use function `customCompile`, when
it will call in function `wrapMain' always.

If i just use relaunch function, i just got simple error information: "Error occurred while
loading configuration file." when recompile failed.

How to display detail information when recompile failed?

I missing something?

Thanks!

  -- Andy

>
> In a test project I just created, this seems to do what you desire.
>
> Hope this helps clear things up
> - Will Donnelly
>
> On Sun, Sep 6 2009 at 1:41 PM, Andy Stewart <lazycat.manatee at gmail.com> wrote:
>>
>> Hi all,
>>
>> I use below params for configure dyre:
>>
>> rebootParams :: Params Config
>> rebootParams = defaultParams
>>    {projectName = "Main"
>>    ,realMain    = manatee
>>    ,showError   = rebootShowError
>>    ,cacheDir    = Just $ return "/test/Download/cache/"
>>    ,configDir   = Just getCurrentDirectory
>>    }
>>
>> There have two version of function `reboot` to reboot Master binary:
>>
>> reboot :: IORefObject -> IO ()
>> reboot ioRefObject = do
>>  rs <- rebootGetState ioRefObject
>>  relaunchWithBinaryState rs Nothing
>>
>> reboot :: IORefObject -> IO ()
>> reboot ioRefObject = do
>>  output <- customCompile rebootParams
>>  case output of
>>    Just o -> putStrLn o   -- output recompile error
>>    Nothing -> do          -- otherwise relaunch
>>      rs <- rebootGetState ioRefObject
>>      relaunchWithBinaryState rs Nothing
>>
>> Becuase i setup `projectName` with `Main`, so i want `dyre` recompile
>> NECESSARY module when i change any module in my project.
>>
>> In first version of function `reboot`, i just use
>> `relauncheWithBinaryState`, i found `dyre` just recompile all project when i
>> modified Main.hs, if i modified any others module in project, `dyre`
>> won't recompile those modified modules.
>>
>> In second version, i use `customCompile` for recompile, but this have
>> another problem, `customComiple` use `-fforce-recomp` flags to remove
>> all object files, so function `customComiple` will recompile all modules
>> in project, and not just recompile NECESSARY modules.
>>
>> So how to make `dyre` just recompile NECCESSARY modules whatever i
>> change any modules in project?
>>
>> Maybe add new option "--dyre-reconf-necessary" in `dyre`?
>>
>> Thanks!
>>
>>  -- Andy



More information about the Haskell-Cafe mailing list