graphql-engine/server/src-lib/GHC/AssertNF/CPP.hs
Robert 11a454c2d6 server, pro: actually reformat the code-base using ormolu
This commit applies ormolu to the whole Haskell code base by running `make format`.

For in-flight branches, simply merging changes from `main` will result in merge conflicts.
To avoid this, update your branch using the following instructions. Replace `<format-commit>`
by the hash of *this* commit.

$ git checkout my-feature-branch
$ git merge <format-commit>^    # and resolve conflicts normally
$ make format
$ git commit -a -m "reformat with ormolu"
$ git merge -s ours post-ormolu

https://github.com/hasura/graphql-engine-mono/pull/2404

GitOrigin-RevId: 75049f5c12f430c615eafb4c6b8e83e371e01c8e
2021-09-23 22:57:37 +00:00

43 lines
1.2 KiB
Haskell

{-# LANGUAGE CPP #-}
-- | GHC.AssertNF.CPP localizes our use of CPP around calls
-- to 'assertNFHere', primarily to give tooling (e.g. ormolu)
-- an easier time.
module GHC.AssertNF.CPP
( assertNFHere,
disableAssertNF,
GHC.AssertNF.assertNFNamed,
)
where
import GHC.AssertNF qualified
import Hasura.Prelude
import Language.Haskell.TH
#ifndef PROFILING
import Text.Printf (printf)
#endif
assertNFHere :: Q Exp
#ifdef PROFILING
assertNFHere = [| const (return ()) |]
#else
-- This is a copy of 'GHC.AssertNF.assertNFHere'. We can't easily
-- use the original because that relies on an import of "GHC.AssertNF".
-- Instead, we rewrite it to use the re-exported 'assertNFNamed'.
assertNFHere = do
locStr <- formatLoc <$> location
return $ AppE (VarE (mkName "GHC.AssertNF.CPP.assertNFNamed"))
(LitE (StringL locStr))
where formatLoc :: Loc -> String
formatLoc loc = let file = loc_filename loc
(line, col) = loc_start loc
in printf "parameter at %s:%d:%d" file line col
#endif
disableAssertNF :: IO ()
#ifdef PROFILING
disableAssertNF = return ()
#else
disableAssertNF = GHC.AssertNF.disableAssertNF
#endif