functional-php / fantasy-land

Specification for interoperability of common algebraic structures in PHP
BSD 3-Clause "New" or "Revised" License
34 stars 10 forks source link

PHPStan fails to compile #22

Open AlexanderAllen opened 4 months ago

AlexanderAllen commented 4 months ago

I've been asserting the functor laws locally for fun and I am observing that PHPStan fails to compile on some generics.

For example, FunctionalPHP\FantasyLand\Functor: https://phpstan.org/r/fef7dc4c-8448-4c36-9e25-92f78145b7fe

I haven't tested all functors or laws yet (in the process of doing so), but thought I would make a note of it.

If I manage to assert laws and generic accuracy for all the objects listed by this spec, I'll issue a PR.

I really want to use this spec as opposed to reinventing the wheel (who wants to do that), but I do not want to implement this until the generics are rock solid.

AlexanderAllen commented 4 months ago

Another example that will fail to compile (maybe that particular callable syntax is no longer supported) is in #16.

krtek4 commented 4 months ago

Hi,

First of all, thank you for your interest in this repository :)

PHPStan is not a "compiler" so it doesn't "compile" anything. Secondly, the errors are in the doc block, so it's more of a documentation issue.

The last real commit on this project is 4 years ago, there's been a lot of new version of PHP since then and also a lot of advance.

As far as I remember, the doc block has been written like that because there was no better way to express things at the time. I don't know if we could do better now, I have written a single line of PHP in the last 5 years.

I also doubt the types defined here could be of used in any recent PHP project. I would recommend you find a more recent library implementing functional primitives l. Sadly I can't point you in any direction.

This being said, if you're willing to change the doc block to make PHPStan happy I'll happily merge the PR.

Cheers

AlexanderAllen commented 1 month ago

Sorry @krtek4 for my late response. I took a lil' break from coding for a few weeks while I focused on putting bread on the table due to the horrible US tech market. I'm happy to report I'm back at coding, with an old friend of 15 years no less! I know it feels unrelated but now I can afford to sink time into passion projects like this. Looking forward to giving some love to fantasy-land again.

As far as other projects are concerned, I looked long and hard at other functional libraries here in Github and most seemed to be relics of the previous decade. So if anyone is interested in the intersection between PHPStan, generics, and functional patterns, just pick one and give it some love!

Leaving open for my future self if that's OK with you.

Thank you for the knowledge you shared with your code @krtek4, even if it's ancient by today's standards I think the original motivations and ideas behind this project still stand!