scala-hamsters / hamsters

A mini Scala utility library
Apache License 2.0
291 stars 23 forks source link

Monad definition and use in Monad transformers (Fixes #17) #84

Closed loicdescotte closed 6 years ago

loicdescotte commented 6 years ago

Fixes https://github.com/scala-hamsters/hamsters/issues/17

Still to do :

loicdescotte commented 6 years ago

Work in progress, not ready to merge

dgouyette commented 6 years ago

You should check if monad laws are validated : https://github.com/DanielaSfregola/tutorial-cat/blob/master/src/test/scala/com/danielasfregola/tutorial/cat/monad/MonadSpec.scala

loicdescotte commented 6 years ago

Not working currently on scala.js :

java.lang.IllegalStateException: Queue is empty while future is not completed, this means you're probably using a wrong ExecutionContext for your task, please double check your Future.
at $c_jl_IllegalStateException.$c_jl_Throwable.fillInStackTrace__jl_Throwable(/mnt/c/Users/loicd/dev/hamsters/js/target/scala-2.11/hamsters-test-fastopt.js:30145:14)
at $c_jl_IllegalStateException.$c_jl_Throwable.init___T__jl_Throwable(/mnt/c/Users/loicd/dev/hamsters/js/target/scala-2.11/hamsters-test-fastopt.js:30167:8)
at java.lang.IllegalStateException.<init>(/mnt/c/Users/loicd/dev/hamsters/js/target/scala-2.11/hamsters-test-fastopt.js:53065:52)
at org.scalatest.concurrent.SerialExecutionContext.recRunNow(/mnt/c/Users/loicd/dev/hamsters/js/target/scala-2.11/hamsters-test-fastopt.js:28329:49)
at org.scalatest.AsyncFlatSpecLike$class.runTest(/mnt/c/Users/loicd/dev/hamsters/js/target/scala-2.11/hamsters-test-fastopt.js:1728:10)
at {anonymous}()(/mnt/c/Users/loicd/dev/hamsters/js/target/scala-2.11/hamsters-test-fastopt.js:1483:14)
at scala.scalajs.runtime.AnonFunction2.apply(/mnt/c/Users/loicd/dev/hamsters/js/target/scala-2.11/hamsters-test-fastopt.js:38898:23)
at {anonymous}()(/mnt/c/Users/loicd/dev/hamsters/js/target/scala-2.11/hamsters-test-fastopt.js:50632:72)
at scala.scalajs.runtime.AnonFunction0.apply(/mnt/c/Users/loicd/dev/hamsters/js/target/scala-2.11/hamsters-test-fastopt.js:38838:23)
at org.scalatest.Status$$anonfun$thenRun$1.apply(/mnt/c/Users/loicd/dev/hamsters/js/target/scala-2.11/hamsters-test-fastopt.js:51187:60)
loicdescotte commented 6 years ago

The issue on js may be due to the fact that the execution context is not overridable in the Monad[Future] instance.

loicdescotte commented 6 years ago

Fixed, problem was due to hardcoded execution context in future monad instance + scalatest default ec

loicdescotte commented 6 years ago

EitherT and FutureEither done We just need to make the scalacheck tests work