<commit_before>from pymonet.utils import identity


class ApplicativeLawTester:

    def __init__(self, applicative, value, mapper1, mapper2):
        self.applicative = applicative
        self.value = value
        self.mapper1 = mapper1
        self.mapper2 = mapper2

    def get_identity_test(self):
        assert self.applicative(identity).ap(self.applicative(self.value)) == self.applicative(self.value)

    def get_composition_test(self):

        def lambda_fn(f):
            lambda g: lambda x: f(g(x))

        x = self.applicative(lambda_fn)\
            .ap(self.applicative(self.mapper1))\
            .ap(self.applicative(self.mapper2))\
            .ap(self.applicative(lambda: self.applicative))
        y = self.applicative(self.mapper1).ap(
            self.applicative(self.mapper2).ap(self.applicative(lambda: self.applicative))
        )

        assert x == y

        # x = (A.of (f) -> (g) -> (x) -> f (g x)).ap(A.of g).ap(A.of h).ap(A.of a)
        # y = (A.of g).ap((A.of h).ap(A.of a))

    def get_homomorphism_test():
        x = self.applicative(self.mapper1).ap(self.applicative(self.value))
        y = self.applicative(
            self.mapper1(self.value)
        )
        assert x == y

    def get_interchange_test(self):
        x = self.applicative(self.mapper1)).ap(self.monad(self.value))
        y = self.applicative(lambda fn: fn(self.value).ap(self.applicative(self.mapper1)
        assert x == y
<commit_msg>fix applicaitve law tester syntax<commit_after>from pymonet.utils import identity


class ApplicativeLawTester:

    def __init__(self, applicative, value, mapper1, mapper2):
        self.applicative = applicative
        self.value = value
        self.mapper1 = mapper1
        self.mapper2 = mapper2

    def get_identity_test(self):
        assert self.applicative(identity).ap(self.applicative(self.value)) == self.applicative(self.value)

    def get_composition_test(self):

        def lambda_fn(f):
            lambda g: lambda x: f(g(x))

        x = self.applicative(lambda_fn)\
            .ap(self.applicative(self.mapper1))\
            .ap(self.applicative(self.mapper2))\
            .ap(self.applicative(lambda: self.applicative))
        y = self.applicative(self.mapper1).ap(
            self.applicative(self.mapper2).ap(self.applicative(lambda: self.applicative))
        )

        assert x == y

    def get_homomorphism_test(self):
        x = self.applicative(self.mapper1).ap(self.applicative(self.value))
        y = self.applicative(
            self.mapper1(self.value)
        )
        assert x == y

    def get_interchange_test(self):
        x = self.applicative(self.mapper1).ap(self.applicative(self.value))
        y = self.applicative(
            lambda fn: fn(self.value).ap(self.applicative(self.mapper1))
        )
        assert x == y
{'fraction_non_alphanumeric': 0.12804232804232804, 'fraction_numerical': 0.009876543209876543, 'mean_word_length': 2.4375757575757575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7566221', 'n_tokens_mistral': 990, 'n_tokens_neox': 918, 'n_words': 157}