@@ -38,6 +38,8 @@ class IO(Generic[R, E, A]):
3838 Have a look to the documentation and examples to learn how to use it.
3939 """
4040
41+ __slots__ = "__tag" , "__fields"
42+
4143 @final
4244 def __init__ (self , __tag , __fields ):
4345 self .__tag = __tag
@@ -49,8 +51,6 @@ def map(self, f: Callable[[A], A2]) -> IO[R, E, A2]:
4951 Transform the computed value with f if the computation is successful.
5052 Do nothing otherwise.
5153 """
52- if self .__tag in [9 , 12 ]:
53- return self
5454 return IO (1 , (self , f ))
5555
5656 @final
@@ -78,8 +78,6 @@ def ap(self: IO[R, E, Callable[[X], A]], arg: IO[R, E, X]) -> IO[R, E, A]:
7878 and arg computes a value `x: X`
7979 then self.ap(arg) computes `f(x): A`
8080 """
81- if self .__tag == 0 and arg .__tag == 0 :
82- return IO (5 , lambda : self .__fields (arg .__fields ))
8381 return IO (3 , (self , arg ))
8482
8583 @final
@@ -99,8 +97,6 @@ def contra_map_read(self, f: Callable[[R2], R]) -> IO[R2, E, A]:
9997 Transform the context with f.
10098 Note that f is not from R to R2 but from R2 to R!
10199 """
102- if self .__tag in [0 , 5 , 9 , 12 ]:
103- return self
104100 return IO (8 , (f , self ))
105101
106102 # Error API
@@ -112,8 +108,6 @@ def catch(self, handler: Callable[[E], IO[R, E, A]]) -> IO[R, E, A]:
112108
113109 On error, call the handler with the error.
114110 """
115- if self .__tag in [0 , 5 , 7 , 12 ]:
116- return self
117111 return IO (10 , (self , handler ))
118112
119113 @final
@@ -122,8 +116,6 @@ def map_error(self, f: Callable[[E], E2]) -> IO[R, E2, A]:
122116 Transform the stored error if the computation fails on an error.
123117 Do nothing otherwise.
124118 """
125- if self .__tag in [0 , 5 , 7 , 12 ]:
126- return self
127119 return IO (11 , (self , f ))
128120
129121 # Panic
@@ -135,8 +127,6 @@ def recover(self, handler: Callable[[Exception], IO[R, E, A]]) -> IO[R, E, A]:
135127
136128 On panic, call the handler with the exception.
137129 """
138- if self .__tag in [0 , 7 , 9 ]:
139- return self
140130 return IO (13 , (self , handler ))
141131
142132 @final
@@ -145,8 +135,6 @@ def map_panic(self, f: Callable[[E], E2]) -> IO[R, E2, A]:
145135 Transform the exception stored if the computation fails on a panic.
146136 Do nothing otherwise.
147137 """
148- if self .__tag in [0 , 7 , 9 ]:
149- return self
150138 return IO (14 , (self , f ))
151139
152140 @final
0 commit comments