Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Free Divisible functor #43

Open
paf31 opened this issue Jan 24, 2018 · 0 comments
Open

Add Free Divisible functor #43

paf31 opened this issue Jan 24, 2018 · 0 comments

Comments

@paf31
Copy link
Contributor

paf31 commented Jan 24, 2018

You can construct the free Divisible functor (free relative to the forgetful functor which only remembers the Contravariant instance) using contravariant Day convolution, just like you can construct the free Applicative using covariant Day convolution:

-- Free f ~ Coproduct Proxy (Day f (Free f))
data Free f a
  = Conquer
  | forall b c. Divide (a -> (b, c)) (f b) (Free f c)

So you can list out the primitive ways you would like to be able to consume values using some Contravariant functor, and then construct a Divisible functor from that. To consume an a using Free f a, you split a into a big tuple, and for each component of that tuple, either consume it using an f, or simply use conquer.

Maybe it's worth adding here?

I have a prototype implementation in PureScript here for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant