pawaclawczyk / scalp

Some Scala useful classes ported to PHP.
18 stars 1 forks source link

Callable type restrictions #7

Open pawaclawczyk opened 7 years ago

pawaclawczyk commented 7 years ago

At this moment Success::flatMap and Failure::recoverWith functions use function restrictCallableReturnType to check whether callable passed as argument has defined return type to TryCatch. It rises TypeError in case when return type is not defined or it is different than expected.

The proposal is to add checks enforcing also callable arguments types, ie example check input argument of callable passed to TryCatch::map or TryCatch::filter or similar functions. Type checks could be also used for checking consistency of functions passed to methods like TryCatch::transform.

Instead of using functions that throws TypeError directly we can introduce checkers returning boolean type and use them in combination with assert.

pawaclawczyk commented 7 years ago

See bug in #19