-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSetup.hs
30 lines (25 loc) · 1.16 KB
/
Setup.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- Adapted from https://github.com/achirkin/easytensor/blob/4cc9a381ad09c7a013a121cc02231f0ac2de649d/dimensions/Setup.hs.
-- This is necessary in case users install Axel through Cabal, and fixes a Haddock bug raised by `polysemy-plugin`.
-- This module disables some errors and warnings during the Haddock pass (caused by compiler plugins and hs-boot).
module Main where
import Distribution.Simple
import Distribution.Simple.Setup
main :: IO ()
main =
defaultMainWithHooks
simpleUserHooks {confHook = \a -> confHook simpleUserHooks a . tweakFlags}
tweakFlags :: ConfigFlags -> ConfigFlags
tweakFlags flags =
flags {configProgramArgs = addHaddockArgs (configProgramArgs flags)}
addHaddockArgs :: [(String, [String])] -> [(String, [String])]
addHaddockArgs [] = [("haddock", newHaddockGhcArgs)]
addHaddockArgs (("haddock", args):otherProgsArgs) =
("haddock", args <> newHaddockGhcArgs) : otherProgsArgs
addHaddockArgs (progArgs:otherProgsArgs) =
progArgs : addHaddockArgs otherProgsArgs
newHaddockGhcArgs :: [String]
newHaddockGhcArgs =
[ "--optghc=-fdefer-type-errors"
, "--optghc=-fno-warn-deferred-type-errors"
, "--optghc=-fno-warn-missing-home-modules"
]