@hackage th-lock0.0.4
Serialize compilation of modules with TH code modifing shared state
Categories
License
BSD-3-Clause
Maintainer
Daniil Iaitskov <dyaitskov@gmail.com>
Links
Versions
- 0.0.4 Fri, 14 Mar 2025
Installation
Tested Compilers
Dependencies (2)
- base <5
- template-haskell <2.24.0.0 Show all…
Dependents (1)
@hackage/trace-embrace
Recent GHC versions with option -j<N>
where N
greater than 1 can
build modules concurrently. Usually it is cool thing, because build time
drops, but there is a drawback in form of problems with TH code
maintaining a shared state.
I encountered such issue while running tests for trace-embrace package. Package TH code has a shared state (immutable configuration file loaded once), which is not supposed to change after loading, but tests require to cover all cases/branches and achieving this in the scope of a single cabal test-suit leads to inconsistencies.
Spreading tests among multiple test suits cause code duplication and looks less elegant.
Compilation of conflicting modules can be serialized with ensureSerialCompilationVerbose.
{-# LANGUAGE TemplateHaskell #-} module ModuleA where import Language.Haskell.TH.Lock ensureSerialCompilationVerbose
________________________________________________________________________
{-# LANGUAGE TemplateHaskell #-} module ModuleB where import Language.Haskell.TH.Lock ensureSerialCompilationVerbose