Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify handleBenchmarkException #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@
},
"dependencies": {
"purescript-arrays": "^4.0.1",
"purescript-exceptions": "matthewleon/purescript-exceptions#rethrow",
"purescript-exists": "^3.0.0",
"purescript-identity": "^3.0.0",
"purescript-profunctor": "^3.0.0",
"purescript-strings": "^3.0.0",
"purescript-quickcheck": "^4.0.0",
"purescript-transformers": "^3.1.0",
"purescript-foldable-traversable": "^3.0.0",
"purescript-exceptions": "^3.0.0",
"purescript-node-fs": "^4.0.0",
"purescript-node-buffer": "^3.0.0",
"purescript-node-readline": "^3.0.0",
"purescript-datetime": "^3.0.0",
"purescript-now": "^3.0.0"
},
"resolutions": {
"purescript-exceptions": "rethrow"
}
}
19 changes: 0 additions & 19 deletions src/Benchotron/Core.js

This file was deleted.

12 changes: 7 additions & 5 deletions src/Benchotron/Core.purs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Control.Monad.State.Trans (StateT, evalStateT)
import Control.Monad.State.Class (get, put)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Exception (EXCEPTION)
import Control.Monad.Eff.Exception (EXCEPTION, rethrowException, error)
import Control.Monad.Eff.Exception.Unsafe (unsafeThrow)
import Control.Monad.Eff.Now (NOW)
import Node.FS (FS)
Expand Down Expand Up @@ -170,10 +170,12 @@ runBenchmarkF benchmark onChange = do
where
withIndices arr = zip (1..(length arr)) arr

-- TODO: use purescript-exceptions instead. This appears to be blocked on:
-- https://github.com/purescript/purescript-exceptions/issues/5
foreign import handleBenchmarkException ::
forall e a. String -> Int -> Eff (BenchEffects e) a -> Eff (BenchEffects e) a
handleBenchmarkException :: forall e. String -> Int -> Eff (exception :: EXCEPTION | e) ~> Eff (exception :: EXCEPTION | e)
handleBenchmarkException name size =
rethrowException \innerError -> error $
"While running Benchotron benchmark function: " <> name <> " " <>
"at n=" <> show size <> ":\n" <>
show innerError

runBenchmarkFunction :: forall e a. Array a -> BenchmarkFunction a -> Eff (BenchEffects e) Stats
runBenchmarkFunction inputs (BenchmarkFunction function') =
Expand Down