Skip to content

Commit

Permalink
quasar: Move undefined warning to hlint to fix stack trace
Browse files Browse the repository at this point in the history
Also removes warning for `error` and `errorWithoutStackTrace`.

Co-authored-by: Jan Beinke <[email protected]>
  • Loading branch information
queezle42 and thelegy committed Apr 27, 2024
1 parent e2ea6a0 commit 1e1d28c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
6 changes: 6 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
- traceShowIO
- traceShowIdIO

- functions:
- message: "undefined is not allowed in production code"
within: []
name:
- undefined

# Add custom hints for this project
#
# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
Expand Down
20 changes: 1 addition & 19 deletions quasar/src/Quasar/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ module Quasar.Prelude
Data.Word.Word32,
Data.Word.Word64,
GHC.Stack.HasCallStack,
error,
errorWithoutStackTrace,
Debug.Trace.trace,
Debug.Trace.traceId,
Debug.Trace.traceShow,
Expand All @@ -74,21 +72,17 @@ module Quasar.Prelude
traceIO,
traceShowIO,
traceShowIdIO,
undefined,
)
where

import Prelude hiding
( error,
errorWithoutStackTrace,
head,
( head,
last,
read,
-- Due to the accepted "monad of no return" proposal, return becomes an
-- alias for pure. Return can be a pitfall for newcomers, so we decided to
-- use pure instead.
return,
undefined,
)
import Prelude qualified as P

Expand Down Expand Up @@ -126,18 +120,6 @@ import GHC.Stack qualified
import GHC.Types qualified
import Quasar.PreludeExtras

{-# WARNING error "Undefined." #-}
error :: forall (r :: GHC.Types.RuntimeRep). forall (a :: GHC.Types.TYPE r). GHC.Stack.HasCallStack => String -> a
error = P.error

{-# WARNING errorWithoutStackTrace "Undefined." #-}
errorWithoutStackTrace :: String -> a
errorWithoutStackTrace = P.errorWithoutStackTrace

{-# WARNING undefined "Undefined." #-}
undefined :: forall (r :: GHC.Types.RuntimeRep). forall (a :: GHC.Types.TYPE r). GHC.Stack.HasCallStack => a
undefined = P.undefined

traceIO :: Control.Monad.IO.Class.MonadIO m => String -> m ()
traceIO = Control.Monad.IO.Class.liftIO . Debug.Trace.traceIO

Expand Down

0 comments on commit 1e1d28c

Please sign in to comment.