diff --git a/bower.json b/bower.json index 39e9ff3..8a0687e 100644 --- a/bower.json +++ b/bower.json @@ -19,6 +19,7 @@ "purescript-prelude": "^4.0.0" }, "devDependencies": { - "purescript-effect": "^2.0.0" + "purescript-effect": "^2.0.0", + "purescript-exceptions": "^4.0.0" } } diff --git a/src/Debug/Todo.js b/src/Debug/Todo.js new file mode 100644 index 0000000..65a2a01 --- /dev/null +++ b/src/Debug/Todo.js @@ -0,0 +1,9 @@ +"use strict"; + +// module Todo + +exports.crashWith = function () { + return function (msg) { + throw new Error(msg); + }; +}; diff --git a/src/Debug/Todo.purs b/src/Debug/Todo.purs new file mode 100644 index 0000000..7c13d9d --- /dev/null +++ b/src/Debug/Todo.purs @@ -0,0 +1,18 @@ +module Debug.Todo +( notImplementedYet +, (???) +, todo +) where + +import Data.Symbol (class IsSymbol, SProxy, reflectSymbol) +import Prim.TypeError (class Warn, Beside, Text) + +notImplementedYet :: forall a. Warn (Text "not implemented yet") => a +notImplementedYet = crashWith "not implemented yet" + +infix 5 notImplementedYet as ??? + +todo :: forall a s. IsSymbol s => Warn (Beside (Text "TODO: ") (Text s)) => SProxy s -> a +todo s = crashWith (reflectSymbol s) + +foreign import crashWith :: forall a. String -> a diff --git a/test/Main.purs b/test/Main.purs index b2562d7..bec260f 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -1,8 +1,11 @@ module Test.Main where +import Debug.Todo import Prelude + import Debug.Trace (spy, trace, traceM) import Effect (Effect) +import Effect.Exception (try) main :: Effect Unit main = do @@ -25,6 +28,9 @@ main = do let dummy = spy "dummy" { foo: 1, bar: [1, 2] } traceM dummy + result :: _ String <- try (pure unit >>= \_ -> (???)) + traceM (show result) + where effInt :: Effect Int effInt = pure 0