Skip to content

Commit 45b817d

Browse files
committed
Pre-release v0.0.3
1 parent b0a86ad commit 45b817d

File tree

2 files changed

+2
-45
lines changed

2 files changed

+2
-45
lines changed

raffiot/io.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ def map_panic(self, f: Callable[[E], E2]) -> IO[R, E2, A]:
6262
def recover(self, handler: Callable[[Exception], IO[R, E, A]]) -> IO[R, E, A]:
6363
return IORecover(self, handler)
6464

65-
@final
66-
def _naive_run(self, context: R) -> Result[E, A]:
67-
return _naive_run(context, self)
68-
6965
@final
7066
def run(self, context: R) -> Result[E, A]:
7167
return run(context, self)
@@ -201,46 +197,6 @@ def from_result(r: Result[E, A]) -> IO[R, E, A]:
201197
return r.fold(pure, error, panic)
202198

203199

204-
@result.safe
205-
def _naive_run(context: R, io: IO[R, E, A]) -> Result[E, A]:
206-
if isinstance(io, IOPure):
207-
return result.Ok(io.value)
208-
if isinstance(io, IOAp):
209-
return _naive_run(context, io.fun).ap(_naive_run(context, io.arg))
210-
if isinstance(io, IOFlatten):
211-
return _naive_run(context, io.tower).flat_map(lambda x: _naive_run(context, x))
212-
# Defer
213-
if isinstance(io, IODefer):
214-
try:
215-
return result.Ok(io.deferred())
216-
except Exception as exception:
217-
return result.Panic(exception)
218-
# Read
219-
if isinstance(io, IORead):
220-
return result.Ok(context)
221-
if isinstance(io, IOMapRead):
222-
return _naive_run(io.fun(context), io.main)
223-
# Error
224-
if isinstance(io, IORaise):
225-
return result.Error(io.error)
226-
if isinstance(io, IOCatch):
227-
return _naive_run(context, io.main).catch(
228-
lambda err: _naive_run(context, io.handler(err))
229-
)
230-
if isinstance(io, IOMapError):
231-
return _naive_run(context, io.main).map_error(io.fun)
232-
# Panic
233-
if isinstance(io, IOPanic):
234-
return result.Error(io.error)
235-
if isinstance(io, IORecover):
236-
return _naive_run(context, io.main).recover(
237-
lambda err: _naive_run(context, io.handler(err))
238-
)
239-
if isinstance(io, IOMapPanic):
240-
return _naive_run(context, io.main).map_panic(io.fun)
241-
raise MatchError(f"{io} should be an IO")
242-
243-
244200
class _Cont:
245201
pass
246202

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import setup
22

3-
version = "0.0.2"
3+
version = "0.0.3"
44

55
setup(
66
name="raffiot",
@@ -22,4 +22,5 @@
2222
"Programming Language :: Python :: 3.8",
2323
"Programming Language :: Python :: 3.9",
2424
],
25+
install_requires=['typing-extensions']
2526
)

0 commit comments

Comments
 (0)