Skip to content

Commit

Permalink
[#92] Switch to fourmolu formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
vaclavsvejcar committed Jun 3, 2022
1 parent 9f0fe38 commit 38d5b15
Show file tree
Hide file tree
Showing 121 changed files with 9,126 additions and 9,054 deletions.
4 changes: 2 additions & 2 deletions .headroom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ license-headers:
put-after: ["^{-#"]
put-before: ["^module"]
margin-top-code: 1
margin-bottom-code: 1
margin-bottom-file: 1
line-comment:
prefixed-by: ^--

post-process:
update-copyright:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
- [#87] FIXED: Misleading error message when YAML syntax of .headroom.yaml is invalid
- [#88] Add support for _Python_
- [#89] Support GHC 9.2
- [#92] Switch to fourmolu source code formatter
- [#93] FIXED: Haddock module header detection is faulty
- Bump _LTS Haskell_ to `19.9`

Expand Down
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ microsite:

.PHONY: pretty
pretty:
find ./app -name '*.hs' | xargs stylish-haskell -i -v
find ./src -name '*.hs' | xargs stylish-haskell -i -v
find ./test -name '*.hs' | xargs stylish-haskell -i -v
find ./app -name '*.hs' | xargs brittany --write-mode=inplace
find ./src -name '*.hs' | xargs brittany --write-mode=inplace
find ./test -name '*.hs' | xargs brittany --write-mode=inplace
find ./app -name '*.hs' | xargs fourmolu -i
find ./src -name '*.hs' | xargs fourmolu -i
find ./test -name '*.hs' | xargs fourmolu -i

.PHONY: fresh
fresh: clean build
Expand Down
89 changes: 44 additions & 45 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}

{-|
Module : Main
Description : Main application launcher
Copyright : (c) 2019-2022 Vaclav Svejcar
License : BSD-3-Clause
Maintainer : [email protected]
Stability : experimental
Portability : POSIX
Code responsible for booting up the application and parsing command line
arguments.
-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NoImplicitPrelude #-}

-- |
-- Module : Main
-- Description : Main application launcher
-- Copyright : (c) 2019-2022 Vaclav Svejcar
-- License : BSD-3-Clause
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : POSIX
--
-- Code responsible for booting up the application and parsing command line
-- arguments.
module Main where

import Headroom.Command ( commandParser )
import Headroom.Command.Gen ( commandGen
, parseGenMode
)
import Headroom.Command.Init ( commandInit )
import Headroom.Command.Run ( commandRun )
import Headroom.Command.Types ( Command(..)
, CommandGenOptions(..)
, CommandInitOptions(..)
, CommandRunOptions(..)
)
import Headroom.Types ( HeadroomError(..) )
import Options.Applicative ( execParser )
import RIO
import System.IO ( hPutStrLn )

import Headroom.Command (commandParser)
import Headroom.Command.Gen (
commandGen
, parseGenMode
)
import Headroom.Command.Init (commandInit)
import Headroom.Command.Run (commandRun)
import Headroom.Command.Types (
Command (..)
, CommandGenOptions (..)
, CommandInitOptions (..)
, CommandRunOptions (..)
)
import Headroom.Types (HeadroomError (..))
import Options.Applicative (execParser)
import RIO
import System.IO (hPutStrLn)

main :: IO ()
main = do
command' <- execParser commandParser
catch
(bootstrap command')
(\ex -> do
hPutStrLn stderr $ "ERROR: " <> displayException (ex :: HeadroomError)
exitWith $ ExitFailure 1
)
command' <- execParser commandParser
catch
(bootstrap command')
( \ex -> do
hPutStrLn stderr $ "ERROR: " <> displayException (ex :: HeadroomError)
exitWith $ ExitFailure 1
)

bootstrap :: Command -> IO ()
bootstrap = \case
c@(Gen _ _) -> do
cgoGenMode <- parseGenMode c
commandGen CommandGenOptions { .. }
Init cioLicenseType cioSourcePaths -> commandInit CommandInitOptions { .. }
Run croSourcePaths croExcludedPaths croExcludeIgnoredPaths croBuiltInTemplates croTemplateRefs croVariables croRunMode croDebug croDryRun
-> commandRun CommandRunOptions { .. }
c@(Gen _ _) -> do
cgoGenMode <- parseGenMode c
commandGen CommandGenOptions{..}
Init cioLicenseType cioSourcePaths -> commandInit CommandInitOptions{..}
Run croSourcePaths croExcludedPaths croExcludeIgnoredPaths croBuiltInTemplates croTemplateRefs croVariables croRunMode croDebug croDryRun ->
commandRun CommandRunOptions{..}
21 changes: 10 additions & 11 deletions doc/templates/haskell.mustache
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{-|
Module : {{{ _haskell_module_name }}}
Description : {{{ _haskell_module_shortdesc }}}
Copyright : (c) {{ year }} {{ author }}
License : {{ license }}
Maintainer : {{ email }}
Stability : experimental
Portability : POSIX

{{{ _haskell_module_longdesc }}}
-}
-- |
-- Module : {{{ _haskell_module_name }}}
-- Description : {{{ _haskell_module_shortdesc }}}
-- Copyright : (c) {{ year }} {{ author }}
-- License : {{ license }}
-- Maintainer : {{ email }}
-- Stability : experimental
-- Portability : POSIX
--
-- {{{ _haskell_module_longdesc }}}
3 changes: 3 additions & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
comma-style: leading
haddock-style: single-line
import-export-comma-style: leading
Loading

0 comments on commit 38d5b15

Please sign in to comment.