From 1e1d28c2464dea05861170b8b70e01c27ac30df2 Mon Sep 17 00:00:00 2001 From: Jens Nolte Date: Sat, 27 Apr 2024 22:12:53 +0200 Subject: [PATCH] quasar: Move `undefined` warning to hlint to fix stack trace Also removes warning for `error` and `errorWithoutStackTrace`. Co-authored-by: Jan Beinke --- .hlint.yaml | 6 ++++++ quasar/src/Quasar/Prelude.hs | 20 +------------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index 4c76a6d..a8da724 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -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" diff --git a/quasar/src/Quasar/Prelude.hs b/quasar/src/Quasar/Prelude.hs index 20552be..66d3688 100644 --- a/quasar/src/Quasar/Prelude.hs +++ b/quasar/src/Quasar/Prelude.hs @@ -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, @@ -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 @@ -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