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

refactor(fp): v0.1.1 of notebook 05_functors.py #68

Merged
merged 2 commits into from
Mar 17, 2025

Conversation

metaboulie
Copy link
Contributor

@metaboulie metaboulie commented Mar 16, 2025

📝 Summary

  • Use uppercased letters for Generic types, e.g. A = TypeVar("A")

  • Refactor the Functor class, changing fmap and utility methods to classmethod

    For example:

    @dataclass
    class Wrapper(Functor, Generic[A]):
        value: A
    
        @classmethod
        def fmap(cls, f: Callable[[A], B], a: "Wrapper[A]") -> "Wrapper[B]":
            return Wrapper(f(a.value))
    
    >>> Wrapper.fmap(lambda x: x + 1, wrapper)
    Wrapper(value=2)
  • Move the check_functor_law method from Functor class to a standard function

  • Rename ListWrapper to List for simplicity
  • Remove the Just class
  • Rewrite proofs

📋 Checklist

  • I have included package dependencies in the notebook file using --sandbox
  • If adding a course, include a README.md
  • Keep language direct and simple.

@Haleshot
Copy link
Collaborator

Haleshot commented Mar 17, 2025

Unchecked the package dependencies and README boxes from the above desc as it was already included in the previous PR when you added the notebook. The checklist should be specific to a PR's changes.

Copy link
Collaborator

@Haleshot Haleshot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great; just went through the changes 🎉

@Haleshot Haleshot merged commit d9d5845 into marimo-team:main Mar 17, 2025
1 check passed
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.

2 participants