Skip to content

Free Monads - #185

Merged
gusty merged 32 commits into
masterfrom
gusty-free
Dec 31, 2019
Merged

gusty merged 32 commits into
masterfrom
gusty-free

Conversation

@gusty

@gusty gusty commented Aug 18, 2019 •

Copy link
Copy Markdown
Member

This PR will introduce generic Free Monads !

We need to discuss the names (Pure, Roll, Free, Join), create tests and add sample code.
And of course some docs would be ideal but these last years there were many posts about Free Monads in the context of dependency injection.

I tried coding this sample and works up to the definition of exF2, I still haven't found a workaround but realized that if we use Map.InvokeOnInstance and restrict the Free Monads to the user defined types (excluding primitive functor types) it works fully. So that's a B plan.

gusty added 8 commits August 18, 2019 23:45
Now the ambiguity problem is gone, but we run into unsolved type variables.

Using the specific bind for Free instead of the generic one, should work fine. But that doesn't seem to be a good compromise.
gusty added 11 commits August 20, 2019 23:54
This uses the technique of prioritizing overload resolution but in the user defined class.
I adds internal complexity but makes primitive functor types usable to some extent.
The support for primitive functor types will be limited, as shown on this test, type annotations are needed or type inference needs to be driven to the right order of resolution. It's still better than no support at all for primitive functor types.
@gusty

gusty commented Sep 16, 2019 •

Copy link
Copy Markdown
Member Author

I'm willing to merge this.

It worths noting that finally I found a good compromise to the issue with the primitive types, which makes them usable to some extent.

I think the only open question at this point is the naming we're using.
I just picked, without thinking too much: Free for the type, Pure and Roll for the DU.

Any thoughts?

@cannorin

Copy link
Copy Markdown
Member

I think that naming is fine.

@wallymathieu

Copy link
Copy Markdown
Member

I haven't grokked the free monad things, so I can't offer an opinion on the names.

@gusty gusty changed the title [WIP] Free Monads Free Monads Dec 31, 2019
@gusty
gusty merged commit c17698e into master Dec 31, 2019
@gusty
gusty deleted the gusty-free branch September 20, 2022 06:48
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

Successfully merging this pull request may close these issues.

3 participants