mauke / Function-Parameters

Function::Parameters - define functions and methods with parameter lists ("subroutine signatures")
https://metacpan.org/pod/Function::Parameters
18 stars 19 forks source link

Possible to support coercion for function type constraints? #34

Closed iynehz closed 1 year ago

iynehz commented 6 years ago

I use this Function::Parameters with Type::Tiny. I know it does not support coercion now. But I wonder if that is possible to implement. Thanks.

mauke commented 1 year ago

I have implemented automatic type coercion in the last commits. Compared to your implementation, there are a few differences:

But I think the general gist is the same and it addresses this issue.

tobyink commented 1 year ago

If the type constraint object says it supports coercion, we always use it.

If people really want to disable coercion for a particular parameter, they can do:

fun foo ( (MyType->no_coercions) $bar ) {
   ...;
}