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 Cofree #617

Closed truizlop closed 3 years ago

truizlop commented 3 years ago

Related issues

Closes #297

Goal

Clean up the Cofree implementation and provide a nicer way of working with it.

Implementation details

Cofree is a type to obtain a Comonad from any Functor. It is represented by a pair (A, F<Cofree<F, A>>), which, given the Swift type system, can yield to an eager unfold of the second part of the pair. Therefore, to avoid this, this implementation wraps the tail part on an Eval to make the unfolding lazy.