FourmoluCPP - fourmolu wrapper to handle CPP directives
FourmoluCPP is a lightweight wrapper around the Fourmolu Haskell code formatter that adds support for C preprocessor directives.
Fourmolu
Fourmolu is a formatter for Haskell source code. It is a fork of Ormolu, with upstream improvements continually merged.
FourmoluCPP: CPP Support for Haskell Formatting
FourmoluCPP is a lightweight wrapper around the Fourmolu Haskell code formatter that adds support for C preprocessor directives (#if, #ifdef, #ifndef, #else, #elif, #endif).
What It Does
- CPP Directive Handling: Temporarily comments out preprocessor directives during formatting to prevent parsing errors
- Seamless Integration: Passes all options through to Fourmolu while preserving directive positioning
- Project Awareness: Leverages
.cabalfiles for enhanced formatting when available
Why You Need It
Standard Haskell formatters can't handle CPP directives. FourmoluCPP enables consistent formatting for projects using conditional compilation, ensuring your code stays beautiful regardless of platform-specific code blocks.
1fourmolu-cpp -i MyModule.hs
A simple solution for a common Haskell formatting challenge.
The project is on Codeberg: photonsphere/fourmolucpp.
Disclaimer
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.