bow-swift / bow

🏹 Bow is a cross-platform library for Typed Functional Programming in Swift
https://bow-swift.io
Other
643 stars 32 forks source link

Revamp Free #616

Closed truizlop closed 3 years ago

truizlop commented 3 years ago

Related issues

Closes #286

Goal

Provide a better, more robust implementation for Free.

Implementation details

Free is a type that, given any Functor, it is able to provide a Monad for it. This Monad can be later interpreted into different, less restrictive Monads. Free is modeled as a sum type where the two cases roughly correspond to the pure and flatten methods in Monad. From there, instances of Functor, Applicative, Selective, and Monad are able to be provided.

This PR also includes some utilities in terms of natural transformations (extensions to FunctionK) that will help in the interpretation of Free Monads.

Testing details

Type class laws and general behavior of the Free implementation are tested.

truizlop commented 3 years ago

CI fails until #615 gets merged, fixing the type inference timeouts.