From 8eb1633dd886cbaae36cdf9487d2b4ce4fdbb6d1 Mon Sep 17 00:00:00 2001 From: Timothy Date: Wed, 25 Oct 2017 00:27:18 +1100 Subject: [PATCH] Add warnings for partial functions (#70) --- src/Debug.hs | 3 +++ src/Protolude/Error.hs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/Debug.hs b/src/Debug.hs index b4c5bc71f..b0d760380 100644 --- a/src/Debug.hs +++ b/src/Debug.hs @@ -1,5 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} +{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-} module Debug ( undefined, @@ -55,8 +56,10 @@ traceM s = trace (unpack s) (return ()) traceId :: Text -> Text traceId s = trace s s +{-# WARNING notImplemented "'notImplemented' remains in code" #-} notImplemented :: a notImplemented = error "Not implemented" +{-# WARNING undefined "'undefined' remains in code" #-} undefined :: a undefined = error "Prelude.undefined" diff --git a/src/Protolude/Error.hs b/src/Protolude/Error.hs index d8e3d1fe8..194b5c153 100644 --- a/src/Protolude/Error.hs +++ b/src/Protolude/Error.hs @@ -25,6 +25,7 @@ import GHC.Types (RuntimeRep) import Protolude.CallStack (HasCallStack) import GHC.Exception (errorCallWithCallStackException) +{-# WARNING error "'error' remains in code" #-} error :: forall (r :: RuntimeRep) . forall (a :: TYPE r) . HasCallStack => Text -> a error s = raise# (errorCallWithCallStackException (unpack s) ?callstack) @@ -33,6 +34,7 @@ error s = raise# (errorCallWithCallStackException (unpack s) ?callstack) import GHC.Exception (errorCallException) +{-# WARNING error "'error' remains in code" #-} error :: Text -> a error s = raise# (errorCallException (unpack s)) @@ -42,6 +44,7 @@ error s = raise# (errorCallException (unpack s)) import GHC.Types import GHC.Exception +{-# WARNING error "'error' remains in code" #-} error :: Text -> a error s = throw (ErrorCall (unpack s))