Esempio n. 1
0
 def test_split_with_state_monad(self):
     value = 7
     arrow = kleisli_split(state_return)
     state = KleisliArrow.runKleisli(arrow, value)
     result = State.runState(state, list())
     target = ((value, value), list())
     self.assertEquals(target, result)
Esempio n. 2
0
    def test_unsplit_with_maybe_monad(self):
        value = 8

        k1 = kleisli_split(just_return)

        f = lambda x, y: x * y
        k2 = kleisli_unsplit(just_return, f)

        arrow = k1 >> k2
        
        result = KleisliArrow.runKleisli(arrow, value)
        target = Just(f(value, value))
        self.assertEquals(target, result)
Esempio n. 3
0
    def test_unsplit_with_state_monad(self):
        value = 7

        k1 = kleisli_split(state_return)

        f = lambda x, y: x * y
        k2 = kleisli_unsplit(state_return, f)

        arrow = k1 >> k2

        state = KleisliArrow.runKleisli(arrow, value)
        result = State.runState(state, list())
        target = (f(value, value), list())
        self.assertEquals(target, result)
Esempio n. 4
0
 def test_split_with_maybe_monad(self):
     value = 7
     arrow = kleisli_split(just_return)
     result = KleisliArrow.runKleisli(arrow, value)
     target = Just((value, value))
     self.assertEquals(target, result)