Skip to content

Releases: AlexanderAllen/panettone

0.2.3

26 Jul 17:20
bde226f

Choose a tag to compare

0.2.3 Pre-release
Pre-release

July 2024

This month's effort was focused on implementing all category objects from Chapter 5: Functors, Applicatives, Monads of Gilles Cretterand's book. Implementing these meant updating the book's 10 years old code for more modern PHP, adding static typing via PHPStan, and identifying intersections between the reference FantasyLand implementation and the book.

None of the code done exists yet in src, instead it is all being created inside unit tests.

PHPStan

I spent a good chunk of this month diving into generics with PHPStan, then understanding the intersection between generics and functional objects.

The work to fully, accurately type all the category objects implemented so far is still ongoing.

Some type information is coming from upstream in FantasyLand itself, however some of those upstream types currently do not compile in PHPStan and I am working to either fix those locally in Panettone or on a fork of Fantasy Land itself.

Initial category objects

The objects implemented include the functor, applicative functor, monoid, and monad.

I have independently written and asserted all the laws mentioned in chapter 5, even though the FantasyLand spec comes with it's own set of assertions for the laws.

It's interesting that's there slight but still significant differences between Cretterand's book and Habryn's reference implementation. Initially I've implemented Cretterand's objects as faithfully as possible even if they differ from Habryn because it made more sense for asserting category laws as they appear in Cretteran's book. However because I'm integrating Fantasy Land where possible, there might be some mapping and aliasing included between Cretterand's and Habryn's implementations.

Fantasy Land

Fantasy Land is a completely separate, independent specification for algebraic (category) objects. This consists mostly of interfaces that you can implement in your objects to make sure they are compliant with the specification.

I deferred implementing Fantasy Land to after I asserted all the functional laws for the initial tranche of category objects (completed), and as such integration of the interfaces listed by the spec is still in progress.

Completed

  • Implement all objects from Ch. 05 in Cretterand's book.
  • Use unit tests to assert all functional laws for implemented objects.

In progress

  • Fix PHPStan compilation for upstream Fantasy Land interfaces.
  • Types for objects or methods that currently lack types.
  • Aliases that bridge Cretterand's and Habryn (Fantasy Land) implementations.

Testing

As the build in Github is currently broken, here is a list of tests tagged by this release:

Applicatives test
✔ Full applicatives

Assert functor laws for:
✔ What is an applicative functor
✔ Applicative functor returns closure
✔ Applicative functor hints correctly
✔ Native constructs
✔ Custom class
✔ Maybe monad
✔ Identity functor

Collection Applicative
✔ Simple applicative
✔ Image gallery applicative

Functional tests
✔ Use literal book example
✔ Change to string state

Functors using generics
✔ Check the dumped hints

Isolate generic return type
✔ Generic hint using constructor
✔ Generics using static

Laws for Applicatives
✔ Map
✔ Identity
✔ Homomorphism
✔ Interchange
✔ Composition

Laws for Monads
✔ Left identity
✔ Right identity
✔ Associativity

Laws for Monoids
✔ Identity
✔ Associativity
✔ Non associative check
✔ Monoids as int foldables
✔ Monoids as array foldables
✔ Monoids as callables

Medianoche: Fwuffy Cuban sandwich bread
✔ Functional

OK (30 tests, 74 assertions)

Generating code coverage report in Cobertura XML format ... done [00:00.007]

Code Coverage Report:
2024-07-25 20:33:49

Backed enum support

05 May 04:26
96f05ed

Choose a tag to compare

What's Changed

Full Changelog: 0.2.1...0.2.2

0.2.1

05 May 03:31
679a812

Choose a tag to compare

What's Changed

Full Changelog: 0.2.0...0.2.1

Emit enums harvested from OAS sources

05 May 01:01
f739589

Choose a tag to compare

Pre-release

This release adds support for enum properties in OAS sources.
Properties containing enum are emitted as discreet enum type files, in addition to being represented as object properties.

See #42 for more information.

Courtesy screenshot:

image

Initial development release

01 May 10:51
f1d23fd

Choose a tag to compare

Pre-release

With all the initial objectives I envisioned for this project complete, I feel that it has earned it's first tag (and release).

What's Changed

Full Changelog: https://github.com/AlexanderAllen/panettone/commits/0.1.0

TODO

  • Support for enums in Open Api sources.
  • Arguments and help output in the "bin" executable. It's not mission critical for me as the app's settings are set via .ini files at the moment.