Skip to content

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

Merged
Haleshot merged 2 commits intomainfrom
unknown repository
Mar 17, 2025
Merged

refactor(fp): v0.1.1 of notebook 05_functors.py#68
Haleshot merged 2 commits intomainfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost 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
Contributor

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
Contributor

@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.

1 participant