示例#1
0
文件: eff_spec.py 项目: tek/tryp.py
 def eff_flat_task(self):
     a, b = self._r
     t = Task.now(List(Right(Just(Right(a)))))
     target = List(Right(Just(Right(a + b))))
     res = (t.effs(4, List, Either, Maybe, Either)
            .flat_map(lambda x: Task.now(List(Right(Just(Right(x + b)))))))
     res.value.run().should.equal(target)
示例#2
0
文件: optional.py 项目: tek/tryp.py
 def task(self, fa: F, err: str=''):
     from tryp.task import Task
     return Task.from_either(self.to_either(fa, err))
示例#3
0
文件: machine.py 项目: tek/tryp-nvim
 def message_data_task(self, data: Data, msg):
     return either_msg(msg.cons(Task.now(data)).unsafe_perform_sync())
示例#4
0
文件: task_spec.py 项目: tek/tryp.py
 def sequence(self):
     f = lambda: 3
     t = List(Task.now(1), Task.now(2), Task(f)).sequence(Task)
     t.unsafe_perform_sync().should.equal(Right(List(1, 2, 3)))
示例#5
0
文件: task_spec.py 项目: tek/tryp.py
 def zip(self):
     t = Task.now(1) & Task.now(2)
     t.unsafe_perform_sync().should.equal(Right((1, 2)))
示例#6
0
文件: eff_spec.py 项目: tek/tryp.py
 def eff_flat_task_left(self):
     a, b = self._r
     t = Task.now(Left(Just(a)))
     target = Left(Just(a))
     res = t.effs(1, Either, Maybe) // (lambda x: Task.now(Right(Just(b))))
     res.value.run().should.equal(target)
示例#7
0
文件: eff_spec.py 项目: tek/tryp.py
 def eff_flat_task_empty(self):
     t = Task.now(List(Right(Empty())))
     target = List(Right(Empty()))
     res = (t.effs(4, List, Either, Maybe, Either)
            .flat_map(lambda x: Task.now(List(Right(Just(Right(1)))))))
     res.value.run().should.equal(target)
示例#8
0
文件: eff_spec.py 项目: tek/tryp.py
 def eff_map_task(self):
     a, b = self._r
     t = Task.now(List(Just(a), Just(b), Empty()))
     target = List(Just(a + b), Just(b + b), Empty())
     res = t.effs(2).map(_ + b)
     res.value.run().should.equal(target)