effectful 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -440,9 +440,10 @@ def _(typ: type | abc.ABCMeta):
440
440
  return typ
441
441
  elif types.get_original_bases(typ):
442
442
  for base in types.get_original_bases(typ):
443
- cbase = canonicalize(base)
444
- if cbase != object:
445
- return cbase
443
+ if typing.get_origin(base) is not typing.Generic:
444
+ cbase = canonicalize(base)
445
+ if cbase != object:
446
+ return cbase
446
447
  return typ
447
448
  else:
448
449
  raise TypeError(f"Cannot canonicalize type {typ}.")
@@ -250,6 +250,14 @@ def evaluate[T](expr: Expr[T], *, intp: Interpretation | None = None) -> Expr[T]
250
250
  elif isinstance(expr, collections.abc.Sequence):
251
251
  if isinstance(expr, str | bytes):
252
252
  return typing.cast(T, expr) # mypy doesnt like ignore here, so we use cast
253
+ elif (
254
+ isinstance(expr, tuple)
255
+ and hasattr(expr, "_fields")
256
+ and all(hasattr(expr, field) for field in getattr(expr, "_fields"))
257
+ ): # namedtuple
258
+ return type(expr)(
259
+ **{field: evaluate(getattr(expr, field)) for field in expr._fields}
260
+ )
253
261
  else:
254
262
  return type(expr)(evaluate(item) for item in expr) # type: ignore
255
263
  elif isinstance(expr, collections.abc.Set):
effectful/ops/syntax.py CHANGED
@@ -1161,11 +1161,20 @@ def _(x: collections.abc.Mapping, other) -> bool:
1161
1161
 
1162
1162
  @syntactic_eq.register
1163
1163
  def _(x: collections.abc.Sequence, other) -> bool:
1164
- return (
1165
- isinstance(other, collections.abc.Sequence)
1166
- and len(x) == len(other)
1167
- and all(syntactic_eq(a, b) for a, b in zip(x, other))
1168
- )
1164
+ if (
1165
+ isinstance(x, tuple)
1166
+ and hasattr(x, "_fields")
1167
+ and all(hasattr(x, f) for f in x._fields)
1168
+ ):
1169
+ return type(other) == type(x) and all(
1170
+ syntactic_eq(getattr(x, f), getattr(other, f)) for f in x._fields
1171
+ )
1172
+ else:
1173
+ return (
1174
+ isinstance(other, collections.abc.Sequence)
1175
+ and len(x) == len(other)
1176
+ and all(syntactic_eq(a, b) for a, b in zip(x, other))
1177
+ )
1169
1178
 
1170
1179
 
1171
1180
  @syntactic_eq.register(object)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: effectful
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Metaprogramming infrastructure
5
5
  Author: Basis
6
6
  License-Expression: Apache-2.0
@@ -14,13 +14,13 @@ effectful/handlers/jax/scipy/special.py,sha256=yTIECFtQVPgraonrPlyenjvcnEYchZwIZ
14
14
  effectful/internals/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  effectful/internals/runtime.py,sha256=aLWol7sR1yHekn7zNz1evHKHARjiT1tnkmByLHPHBGc,1811
16
16
  effectful/internals/tensor_utils.py,sha256=3QCSUqdxCXod3dsY3oRMcg36Rqr8pVX-ktEyCEkeODo,1173
17
- effectful/internals/unification.py,sha256=CTzRDVqziYKMjqedB1IKHLK4YkHK8TZrlPaP5Ivb0-o,30180
17
+ effectful/internals/unification.py,sha256=MD0beZ29by9hbJaowafBLIZuKPF5MxHXezuGpSG_wCA,30254
18
18
  effectful/ops/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- effectful/ops/semantics.py,sha256=eFBKOKZ-ah0rN47GGUVW_hdBo1HXfk4hiuqjEgQCd-A,11596
20
- effectful/ops/syntax.py,sha256=5YZh7vBVsWqMRNGok0_yNYLhsJXjrnq2sL1VN9aiN7M,55531
19
+ effectful/ops/semantics.py,sha256=u6i7RTpiv5fCnOdh_pOL-5CSsO4QtW-SjfGEQiizeWk,11922
20
+ effectful/ops/syntax.py,sha256=PE9iuLIzwqFkkk99bBZWk93X4sqSUhtRPePiTQRnAdk,55825
21
21
  effectful/ops/types.py,sha256=W1gZJaBnX7_nFpWrG3vfCBQPSun3Gc9PqT61ls8B3EA,6599
22
- effectful-0.2.0.dist-info/licenses/LICENSE.md,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
23
- effectful-0.2.0.dist-info/METADATA,sha256=OXKK_zuSeSxST7LbwMCobitLX0OsOQu-wRfd7LzKJGM,5300
24
- effectful-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- effectful-0.2.0.dist-info/top_level.txt,sha256=gtuJfrE2nXil_lZLCnqWF2KAbOnJs9ILNvK8WnkRzbs,10
26
- effectful-0.2.0.dist-info/RECORD,,
22
+ effectful-0.2.1.dist-info/licenses/LICENSE.md,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
23
+ effectful-0.2.1.dist-info/METADATA,sha256=AgFY63eWiiFpOlvxgWa-3GOV9eSy__N0gF6ZIs5ljdc,5300
24
+ effectful-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
+ effectful-0.2.1.dist-info/top_level.txt,sha256=gtuJfrE2nXil_lZLCnqWF2KAbOnJs9ILNvK8WnkRzbs,10
26
+ effectful-0.2.1.dist-info/RECORD,,