PythonDecoratorsRustAlgebraic Data Types
diff --git a/index.xml b/index.xml
index a77e1b59..a39475a2 100644
--- a/index.xml
+++ b/index.xml
@@ -1,6 +1,13 @@
-lavafrothhttps://lavafroth.is-a.dev/Recent content on lavafrothHugoen-usSun, 02 Nov 2025 19:08:46 +0530Algebraic Python Enumshttps://lavafroth.is-a.dev/post/algebraic-python-enums/Sun, 02 Nov 2025 19:08:46 +0530https://lavafroth.is-a.dev/post/algebraic-python-enums/<p>As much as I like rust for its ergonomic features, University has forced me to use Python for the past couple of months, especially because of the hype for machine learning and data science.</p>
-<p>One of the biggest things that I missed from the rust experience was enumerable data types whose variants can wrap around different datatypes.</p>
-<p>Fortunately, since Python 3.8, creating structs has been a breeze using the dataclass decorator. There’s even support for structural match expressions, like in rust, in recent versions of <a href="https://peps.python.org/pep-0636/">Python</a>.</p>note skta4v7n8h8https://lavafroth.is-a.dev/skta4v7n8h8/Fri, 31 Oct 2025 20:24:35 +0530https://lavafroth.is-a.dev/skta4v7n8h8/<h1 id="grpa-1">GrPA 1</h1>
+lavafrothhttps://lavafroth.is-a.dev/Recent content on lavafrothHugoen-usSun, 02 Nov 2025 19:08:46 +0530Algebraic Python Enumshttps://lavafroth.is-a.dev/post/algebraic-python-enums/Sun, 02 Nov 2025 19:08:46 +0530https://lavafroth.is-a.dev/post/algebraic-python-enums/<p>As much as I like Rust for its ergonomic features, university has forced me to
+use Python for the past couple of months, especially because of the hype for
+machine learning and data science.</p>
+<p>One of the biggest things that I missed from the rust experience was enumerable
+data types whose variants can wrap around different datatypes.</p>
+<p>Although Python has the answer to creating structs as
+<a href="https://peps.python.org/pep-0557/">dataclasses</a>, including support for
+<a href="https://peps.python.org/pep-0636/">structural match expressions</a> in recent
+versions, most tutorials will suggest <code>Union</code> types as the equivalent to Rust’s
+enums.</p>note skta4v7n8h8https://lavafroth.is-a.dev/skta4v7n8h8/Fri, 31 Oct 2025 20:24:35 +0530https://lavafroth.is-a.dev/skta4v7n8h8/<h1 id="grpa-1">GrPA 1</h1>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">swap</span>(arr, i, j):
</span></span><span style="display:flex;"><span> arr[i], arr[j] <span style="color:#f92672">=</span> arr[j], arr[i]
</span></span><span style="display:flex;"><span>
diff --git a/pagefind/fragment/en-us_37caf2f.pf_fragment b/pagefind/fragment/en-us_37caf2f.pf_fragment
deleted file mode 100644
index 35aeccd4..00000000
Binary files a/pagefind/fragment/en-us_37caf2f.pf_fragment and /dev/null differ
diff --git a/pagefind/fragment/en-us_ff9e431.pf_fragment b/pagefind/fragment/en-us_ff9e431.pf_fragment
new file mode 100644
index 00000000..3a2632cc
Binary files /dev/null and b/pagefind/fragment/en-us_ff9e431.pf_fragment differ
diff --git a/pagefind/index/en-us_18656bc.pf_index b/pagefind/index/en-us_18656bc.pf_index
new file mode 100644
index 00000000..cd282d43
Binary files /dev/null and b/pagefind/index/en-us_18656bc.pf_index differ
diff --git a/pagefind/index/en-us_2b3b249.pf_index b/pagefind/index/en-us_2b3b249.pf_index
deleted file mode 100644
index b9f76df6..00000000
Binary files a/pagefind/index/en-us_2b3b249.pf_index and /dev/null differ
diff --git a/pagefind/index/en-us_569df36.pf_index b/pagefind/index/en-us_569df36.pf_index
new file mode 100644
index 00000000..e65b2a34
Binary files /dev/null and b/pagefind/index/en-us_569df36.pf_index differ
diff --git a/pagefind/index/en-us_72a0d44.pf_index b/pagefind/index/en-us_72a0d44.pf_index
deleted file mode 100644
index 9d465615..00000000
Binary files a/pagefind/index/en-us_72a0d44.pf_index and /dev/null differ
diff --git a/pagefind/index/en-us_8a17e7e.pf_index b/pagefind/index/en-us_8a17e7e.pf_index
deleted file mode 100644
index 6c9751c3..00000000
Binary files a/pagefind/index/en-us_8a17e7e.pf_index and /dev/null differ
diff --git a/pagefind/index/en-us_93e47fa.pf_index b/pagefind/index/en-us_93e47fa.pf_index
deleted file mode 100644
index f90e3f4e..00000000
Binary files a/pagefind/index/en-us_93e47fa.pf_index and /dev/null differ
diff --git a/pagefind/index/en-us_979d23c.pf_index b/pagefind/index/en-us_979d23c.pf_index
deleted file mode 100644
index ede4e094..00000000
Binary files a/pagefind/index/en-us_979d23c.pf_index and /dev/null differ
diff --git a/pagefind/index/en-us_c668e46.pf_index b/pagefind/index/en-us_c668e46.pf_index
deleted file mode 100644
index c4ec96ad..00000000
Binary files a/pagefind/index/en-us_c668e46.pf_index and /dev/null differ
diff --git a/pagefind/index/en-us_ce84bb8.pf_index b/pagefind/index/en-us_ce84bb8.pf_index
new file mode 100644
index 00000000..46364028
Binary files /dev/null and b/pagefind/index/en-us_ce84bb8.pf_index differ
diff --git a/pagefind/index/en-us_e2f7899.pf_index b/pagefind/index/en-us_e2f7899.pf_index
new file mode 100644
index 00000000..654d7d69
Binary files /dev/null and b/pagefind/index/en-us_e2f7899.pf_index differ
diff --git a/pagefind/index/en-us_eec299e.pf_index b/pagefind/index/en-us_eec299e.pf_index
new file mode 100644
index 00000000..e24c54f8
Binary files /dev/null and b/pagefind/index/en-us_eec299e.pf_index differ
diff --git a/pagefind/index/en-us_f767589.pf_index b/pagefind/index/en-us_f767589.pf_index
new file mode 100644
index 00000000..26663b88
Binary files /dev/null and b/pagefind/index/en-us_f767589.pf_index differ
diff --git a/pagefind/pagefind-entry.json b/pagefind/pagefind-entry.json
index c9741368..7e7597e5 100644
--- a/pagefind/pagefind-entry.json
+++ b/pagefind/pagefind-entry.json
@@ -1 +1 @@
-{"version":"1.0.3","languages":{"en-us":{"hash":"en-us_6a23f48a599dc","wasm":"en-us","page_count":58}}}
\ No newline at end of file
+{"version":"1.0.3","languages":{"en-us":{"hash":"en-us_f3d6bd8299974","wasm":"en-us","page_count":58}}}
\ No newline at end of file
diff --git a/pagefind/pagefind.en-us_6a23f48a599dc.pf_meta b/pagefind/pagefind.en-us_6a23f48a599dc.pf_meta
deleted file mode 100644
index 776eee72..00000000
Binary files a/pagefind/pagefind.en-us_6a23f48a599dc.pf_meta and /dev/null differ
diff --git a/pagefind/pagefind.en-us_f3d6bd8299974.pf_meta b/pagefind/pagefind.en-us_f3d6bd8299974.pf_meta
new file mode 100644
index 00000000..2b7e0adb
Binary files /dev/null and b/pagefind/pagefind.en-us_f3d6bd8299974.pf_meta differ
diff --git a/post/algebraic-python-enums/index.html b/post/algebraic-python-enums/index.html
index 73a5a9b2..e92c96dd 100644
--- a/post/algebraic-python-enums/index.html
+++ b/post/algebraic-python-enums/index.html
@@ -1,6 +1,21 @@
-Algebraic Python Enums - lavafroth
Algebraic Python Enums
As much as I like rust for its ergonomic features, University has forced me to use Python for the past couple of months, especially because of the hype for machine learning and data science.
One of the biggest things that I missed from the rust experience was enumerable data types whose variants can wrap around different datatypes.
Fortunately, since Python 3.8, creating structs has been a breeze using the dataclass decorator. There’s even support for structural match expressions, like in rust, in recent versions of Python.
To that end, creating the equivalent to Rust’s enum types involves Python union types.
As much as I like Rust for its ergonomic features, university has forced me to
+use Python for the past couple of months, especially because of the hype for
+machine learning and data science.
One of the biggest things that I missed from the rust experience was enumerable
+data types whose variants can wrap around different datatypes.
Although Python has the answer to creating structs as
+dataclasses, including support for
+structural match expressions in recent
+versions, most tutorials will suggest Union types as the equivalent to Rust’s
+enums.
I highly encourage you to try out the code snippets and follow along with this article.
+Use the collapse explanation button to copy multiple code blocks in one go.
Naive draft
# glass_enum.pyfrom dataclasses import dataclass
@@ -19,8 +34,63 @@ Fortunately, since Python 3.8, creating structs has been a breeze using the data
return"Whoops, looks like you've finished your drink!"case Full(drink):
returnf"Ah a {drink}, what a fine taste!"
-
Pitfalls
No direct variant access
Since there is no namespacing, we also can’t instantiate variants under the Glass namespace. The following code does not work.
dr_pepper = Glass.Full("Dr. Pepper")
-
This can be partially solved by putting the entire enumerable type inside a module.
+
We can’t instantiate variants as members of the Glass namespace. The following code does not work.
dr_pepper = Glass.Full("Dr. Pepper")
+
This can be partially solved by keeping just the Glass type inside a module.
Here we have saved the file as glass_enum.py. From a different module we can
access the variants as glass_enum.Empty and glass_enum.Full.
# main.pyimport glass_enum
@@ -30,12 +100,14 @@ access the variants as glass_enum.Empty and glass_enum.Full
Now any function outside the module has to ingest a rather confusing argument of type glass_enum.Glass.
Since using a module namespace only causes more confusion, we will discard this idea.
No methods on the enum itself
With no namespaceing, methods cannot be defined on the Union of the different variants.
In the case of our concrete example, we can’t add methods to the Glass type.
defrefill(glass: Glass) -> Glass:
+
Since module namespacing only causes more confusion, we will discard this idea.
No methods on the enum itself
Python also disallows methods from being defined on Union types.
+In the case of our concrete example, we can’t add methods to the Glass type.
The following code uses a hypothetical is_empty() method on the Glass union
+type which is not allowed. Hence the code won’t run.
defrefill(glass: Glass) -> Glass:
if glass.is_empty(): # can't implement on type `Glass` directlyreturn Full('water')
return glass
-
Even if we use module level namespacing, it’s simply not possible to define any method on a Union type in Python.
To define a method like is_empty(), it must be implemented on both the classes Full and Empty. This can get
-tedious if there are 3 or more variants.
Python is a sneaky language
Last week I discovered that Python allows creating nested classes to keep things organized.
from dataclasses import dataclass
+
To define a method like is_empty(), it must be implemented on both the classes
+Full and Empty. This gets tedious for 3 or more variants.
Python is a sneaky language
Last week I discovered that Python allows creating nested classes to keep things organized.
from dataclasses import dataclass
classGlass:
@dataclass
@@ -46,7 +118,7 @@ tedious if there are 3 or more variants.
P
classFull:
drink: str
Python will happily run the above code and we can access the “variants” under the Glass namespace.
lemonade = Glass.Full('lemonade')
-
If only we could register the variants as the Glass type itself and inherit all its methods.
Redecorate
We can define a decorator that takes all of the nested dataclasses and makes them inherit the outer class.
import inspect
+
If only we could register the variants as the Glass type itself and inherit all its methods.
Redecorate
We can define a decorator that takes all of the nested dataclasses and makes them inherit the outer class.
import inspect
defAlgebraicEnum(cls):
for subclass_name, subclass in inspect.getmembers(cls, predicate=inspect.isclass):
@@ -54,7 +126,8 @@ tedious if there are 3 or more variants.
That’s all there is to the magic! Now we can simply add this decorator above the previous class declaration
+
The inheritance means all methods of the outer class are available on the nested
+classes and any object of a nested class isinstance of the outer class.
That’s all there is to the magic! Now we can simply add this decorator above the previous class declaration
and the variants like Glass.Empty and Glass.Full would be of the type Glass.
from dataclasses import dataclass
@AlgebraicEnum
@@ -67,22 +140,71 @@ and the variants like Glass.Empty and Glass.Full would
classFull:
drink: str
-defreport_drink(self) -> str:
+defreport_drink(self: 'Glass') -> str:
match self:
case Glass.Empty():
return"Whoops, looks like you've finished your drink!"case Glass.Full(drink):
returnf"Ah a {drink}, what a fine taste!"
-defis_empty(self) -> str:
+defis_empty(self: 'Glass') -> bool:
match self:
case Glass.Empty():
returnTruereturnFalse
As a bonus, the variants will also inherit any methods defined on the Glass type.
Note how the report_drink method accepts a self of type Glass and the match arms
-compare it with Glass.Empty and Glass.Full.
These methods get automatically called via the method resolution order chain due to the inheritance.
Closing thoughts
Those 6 lines are the bare minimum of what you can do right now to have well organized and namespaced algebraic enums in Python
-which are somewhat comparable to those in Rust. These enums also play nicely with static type checkers
-and goto-definitions will also lead you to the correct class defining a variant or the enum itself.
I have packaged this decorator with a couple more typing restrictions into a library at github:lavafroth/ape.
I hope you enjoyed this foray into contorting Python.
\ No newline at end of file
diff --git a/post/index.html b/post/index.html
index 4418468a..44b7a64b 100644
--- a/post/index.html
+++ b/post/index.html
@@ -1,4 +1,4 @@
-Posts - lavafroth
PythonDecoratorsRustAlgebraic Data Types
diff --git a/post/index.xml b/post/index.xml
index f9d1c768..80982987 100644
--- a/post/index.xml
+++ b/post/index.xml
@@ -1,6 +1,13 @@
-Posts on lavafrothhttps://lavafroth.is-a.dev/post/Recent content in Posts on lavafrothHugoen-usSun, 02 Nov 2025 19:08:46 +0530Algebraic Python Enumshttps://lavafroth.is-a.dev/post/algebraic-python-enums/Sun, 02 Nov 2025 19:08:46 +0530https://lavafroth.is-a.dev/post/algebraic-python-enums/<p>As much as I like rust for its ergonomic features, University has forced me to use Python for the past couple of months, especially because of the hype for machine learning and data science.</p>
-<p>One of the biggest things that I missed from the rust experience was enumerable data types whose variants can wrap around different datatypes.</p>
-<p>Fortunately, since Python 3.8, creating structs has been a breeze using the dataclass decorator. There’s even support for structural match expressions, like in rust, in recent versions of <a href="https://peps.python.org/pep-0636/">Python</a>.</p>NixOS Notes to Selfhttps://lavafroth.is-a.dev/post/nixos-notes-to-self/Sun, 14 Sep 2025 18:31:52 +0530https://lavafroth.is-a.dev/post/nixos-notes-to-self/<p>A dedicated post collecting solutions to minor NixOS headaches.</p>
+Posts on lavafrothhttps://lavafroth.is-a.dev/post/Recent content in Posts on lavafrothHugoen-usSun, 02 Nov 2025 19:08:46 +0530Algebraic Python Enumshttps://lavafroth.is-a.dev/post/algebraic-python-enums/Sun, 02 Nov 2025 19:08:46 +0530https://lavafroth.is-a.dev/post/algebraic-python-enums/<p>As much as I like Rust for its ergonomic features, university has forced me to
+use Python for the past couple of months, especially because of the hype for
+machine learning and data science.</p>
+<p>One of the biggest things that I missed from the rust experience was enumerable
+data types whose variants can wrap around different datatypes.</p>
+<p>Although Python has the answer to creating structs as
+<a href="https://peps.python.org/pep-0557/">dataclasses</a>, including support for
+<a href="https://peps.python.org/pep-0636/">structural match expressions</a> in recent
+versions, most tutorials will suggest <code>Union</code> types as the equivalent to Rust’s
+enums.</p>NixOS Notes to Selfhttps://lavafroth.is-a.dev/post/nixos-notes-to-self/Sun, 14 Sep 2025 18:31:52 +0530https://lavafroth.is-a.dev/post/nixos-notes-to-self/<p>A dedicated post collecting solutions to minor NixOS headaches.</p>
<h2 id="nixos-rebuild-shows-no-network-activity"><code>nixos-rebuild</code> shows no network activity</h2>
<p>On rare occasions, a system rebuild will get stuck while downloading a package from a source.
No network activity, no timeout, no writes to the nix store.</p>
diff --git a/tags/algebraic-data-types/index.html b/tags/algebraic-data-types/index.html
index 5c620dbe..3e642716 100644
--- a/tags/algebraic-data-types/index.html
+++ b/tags/algebraic-data-types/index.html
@@ -1,4 +1,4 @@
-Algebraic Data Types - lavafroth
PythonDecoratorsRustAlgebraic Data Types
diff --git a/tags/algebraic-data-types/index.xml b/tags/algebraic-data-types/index.xml
index aee5d614..dd50589c 100644
--- a/tags/algebraic-data-types/index.xml
+++ b/tags/algebraic-data-types/index.xml
@@ -1,3 +1,10 @@
-Algebraic Data Types on lavafrothhttps://lavafroth.is-a.dev/tags/algebraic-data-types/Recent content in Algebraic Data Types on lavafrothHugoen-usSun, 02 Nov 2025 19:08:46 +0530Algebraic Python Enumshttps://lavafroth.is-a.dev/post/algebraic-python-enums/Sun, 02 Nov 2025 19:08:46 +0530https://lavafroth.is-a.dev/post/algebraic-python-enums/<p>As much as I like rust for its ergonomic features, University has forced me to use Python for the past couple of months, especially because of the hype for machine learning and data science.</p>
-<p>One of the biggest things that I missed from the rust experience was enumerable data types whose variants can wrap around different datatypes.</p>
-<p>Fortunately, since Python 3.8, creating structs has been a breeze using the dataclass decorator. There’s even support for structural match expressions, like in rust, in recent versions of <a href="https://peps.python.org/pep-0636/">Python</a>.</p>
\ No newline at end of file
+Algebraic Data Types on lavafrothhttps://lavafroth.is-a.dev/tags/algebraic-data-types/Recent content in Algebraic Data Types on lavafrothHugoen-usSun, 02 Nov 2025 19:08:46 +0530Algebraic Python Enumshttps://lavafroth.is-a.dev/post/algebraic-python-enums/Sun, 02 Nov 2025 19:08:46 +0530https://lavafroth.is-a.dev/post/algebraic-python-enums/<p>As much as I like Rust for its ergonomic features, university has forced me to
+use Python for the past couple of months, especially because of the hype for
+machine learning and data science.</p>
+<p>One of the biggest things that I missed from the rust experience was enumerable
+data types whose variants can wrap around different datatypes.</p>
+<p>Although Python has the answer to creating structs as
+<a href="https://peps.python.org/pep-0557/">dataclasses</a>, including support for
+<a href="https://peps.python.org/pep-0636/">structural match expressions</a> in recent
+versions, most tutorials will suggest <code>Union</code> types as the equivalent to Rust’s
+enums.</p>
\ No newline at end of file
diff --git a/tags/decorators/index.html b/tags/decorators/index.html
index c676fe2e..076f297d 100644
--- a/tags/decorators/index.html
+++ b/tags/decorators/index.html
@@ -1,4 +1,4 @@
-Decorators - lavafroth
PythonDecoratorsRustAlgebraic Data Types
diff --git a/tags/decorators/index.xml b/tags/decorators/index.xml
index 823fdad4..274ac849 100644
--- a/tags/decorators/index.xml
+++ b/tags/decorators/index.xml
@@ -1,3 +1,10 @@
-Decorators on lavafrothhttps://lavafroth.is-a.dev/tags/decorators/Recent content in Decorators on lavafrothHugoen-usSun, 02 Nov 2025 19:08:46 +0530Algebraic Python Enumshttps://lavafroth.is-a.dev/post/algebraic-python-enums/Sun, 02 Nov 2025 19:08:46 +0530https://lavafroth.is-a.dev/post/algebraic-python-enums/<p>As much as I like rust for its ergonomic features, University has forced me to use Python for the past couple of months, especially because of the hype for machine learning and data science.</p>
-<p>One of the biggest things that I missed from the rust experience was enumerable data types whose variants can wrap around different datatypes.</p>
-<p>Fortunately, since Python 3.8, creating structs has been a breeze using the dataclass decorator. There’s even support for structural match expressions, like in rust, in recent versions of <a href="https://peps.python.org/pep-0636/">Python</a>.</p>
\ No newline at end of file
+Decorators on lavafrothhttps://lavafroth.is-a.dev/tags/decorators/Recent content in Decorators on lavafrothHugoen-usSun, 02 Nov 2025 19:08:46 +0530Algebraic Python Enumshttps://lavafroth.is-a.dev/post/algebraic-python-enums/Sun, 02 Nov 2025 19:08:46 +0530https://lavafroth.is-a.dev/post/algebraic-python-enums/<p>As much as I like Rust for its ergonomic features, university has forced me to
+use Python for the past couple of months, especially because of the hype for
+machine learning and data science.</p>
+<p>One of the biggest things that I missed from the rust experience was enumerable
+data types whose variants can wrap around different datatypes.</p>
+<p>Although Python has the answer to creating structs as
+<a href="https://peps.python.org/pep-0557/">dataclasses</a>, including support for
+<a href="https://peps.python.org/pep-0636/">structural match expressions</a> in recent
+versions, most tutorials will suggest <code>Union</code> types as the equivalent to Rust’s
+enums.</p>
\ No newline at end of file
diff --git a/tags/python/index.html b/tags/python/index.html
index fed1e5db..0d55b150 100644
--- a/tags/python/index.html
+++ b/tags/python/index.html
@@ -1,4 +1,4 @@
-Python - lavafroth
PythonDecoratorsRustAlgebraic Data Types
diff --git a/tags/python/index.xml b/tags/python/index.xml
index a27138d1..fd75b2e9 100644
--- a/tags/python/index.xml
+++ b/tags/python/index.xml
@@ -1,6 +1,13 @@
-Python on lavafrothhttps://lavafroth.is-a.dev/tags/python/Recent content in Python on lavafrothHugoen-usSun, 02 Nov 2025 19:08:46 +0530Algebraic Python Enumshttps://lavafroth.is-a.dev/post/algebraic-python-enums/Sun, 02 Nov 2025 19:08:46 +0530https://lavafroth.is-a.dev/post/algebraic-python-enums/<p>As much as I like rust for its ergonomic features, University has forced me to use Python for the past couple of months, especially because of the hype for machine learning and data science.</p>
-<p>One of the biggest things that I missed from the rust experience was enumerable data types whose variants can wrap around different datatypes.</p>
-<p>Fortunately, since Python 3.8, creating structs has been a breeze using the dataclass decorator. There’s even support for structural match expressions, like in rust, in recent versions of <a href="https://peps.python.org/pep-0636/">Python</a>.</p>PicoCTF SansAlpha Writeuphttps://lavafroth.is-a.dev/post/picoctf-sansalpha-writeup/Sun, 05 Jan 2025 11:55:52 +0530https://lavafroth.is-a.dev/post/picoctf-sansalpha-writeup/<p>Hey everyone, since 2024 hasn’t seen a lot of posts on this blog, I plan to
+Python on lavafrothhttps://lavafroth.is-a.dev/tags/python/Recent content in Python on lavafrothHugoen-usSun, 02 Nov 2025 19:08:46 +0530Algebraic Python Enumshttps://lavafroth.is-a.dev/post/algebraic-python-enums/Sun, 02 Nov 2025 19:08:46 +0530https://lavafroth.is-a.dev/post/algebraic-python-enums/<p>As much as I like Rust for its ergonomic features, university has forced me to
+use Python for the past couple of months, especially because of the hype for
+machine learning and data science.</p>
+<p>One of the biggest things that I missed from the rust experience was enumerable
+data types whose variants can wrap around different datatypes.</p>
+<p>Although Python has the answer to creating structs as
+<a href="https://peps.python.org/pep-0557/">dataclasses</a>, including support for
+<a href="https://peps.python.org/pep-0636/">structural match expressions</a> in recent
+versions, most tutorials will suggest <code>Union</code> types as the equivalent to Rust’s
+enums.</p>PicoCTF SansAlpha Writeuphttps://lavafroth.is-a.dev/post/picoctf-sansalpha-writeup/Sun, 05 Jan 2025 11:55:52 +0530https://lavafroth.is-a.dev/post/picoctf-sansalpha-writeup/<p>Hey everyone, since 2024 hasn’t seen a lot of posts on this blog, I plan to
start this year off by going back to the roots.</p>
<p>I’ll be focusing on posting more CTF writeups again! Today’s challenge is
<em>SansAlpha</em> from PicoCTF. The challenge description states</p>
diff --git a/tags/rust/index.html b/tags/rust/index.html
index d8bbb120..c4ee2cd6 100644
--- a/tags/rust/index.html
+++ b/tags/rust/index.html
@@ -1,4 +1,4 @@
-Rust - lavafroth
PythonDecoratorsRustAlgebraic Data Types
diff --git a/tags/rust/index.xml b/tags/rust/index.xml
index dad1a4c1..b27dc0a4 100644
--- a/tags/rust/index.xml
+++ b/tags/rust/index.xml
@@ -1,6 +1,13 @@
-Rust on lavafrothhttps://lavafroth.is-a.dev/tags/rust/Recent content in Rust on lavafrothHugoen-usSun, 02 Nov 2025 19:08:46 +0530Algebraic Python Enumshttps://lavafroth.is-a.dev/post/algebraic-python-enums/Sun, 02 Nov 2025 19:08:46 +0530https://lavafroth.is-a.dev/post/algebraic-python-enums/<p>As much as I like rust for its ergonomic features, University has forced me to use Python for the past couple of months, especially because of the hype for machine learning and data science.</p>
-<p>One of the biggest things that I missed from the rust experience was enumerable data types whose variants can wrap around different datatypes.</p>
-<p>Fortunately, since Python 3.8, creating structs has been a breeze using the dataclass decorator. There’s even support for structural match expressions, like in rust, in recent versions of <a href="https://peps.python.org/pep-0636/">Python</a>.</p>Wrapping up GSoC 2024https://lavafroth.is-a.dev/post/the-gsoc-grand-finale/Sat, 24 Aug 2024 10:28:50 +0530https://lavafroth.is-a.dev/post/the-gsoc-grand-finale/<h1 id="overview">Overview</h1>
+Rust on lavafrothhttps://lavafroth.is-a.dev/tags/rust/Recent content in Rust on lavafrothHugoen-usSun, 02 Nov 2025 19:08:46 +0530Algebraic Python Enumshttps://lavafroth.is-a.dev/post/algebraic-python-enums/Sun, 02 Nov 2025 19:08:46 +0530https://lavafroth.is-a.dev/post/algebraic-python-enums/<p>As much as I like Rust for its ergonomic features, university has forced me to
+use Python for the past couple of months, especially because of the hype for
+machine learning and data science.</p>
+<p>One of the biggest things that I missed from the rust experience was enumerable
+data types whose variants can wrap around different datatypes.</p>
+<p>Although Python has the answer to creating structs as
+<a href="https://peps.python.org/pep-0557/">dataclasses</a>, including support for
+<a href="https://peps.python.org/pep-0636/">structural match expressions</a> in recent
+versions, most tutorials will suggest <code>Union</code> types as the equivalent to Rust’s
+enums.</p>Wrapping up GSoC 2024https://lavafroth.is-a.dev/post/the-gsoc-grand-finale/Sat, 24 Aug 2024 10:28:50 +0530https://lavafroth.is-a.dev/post/the-gsoc-grand-finale/<h1 id="overview">Overview</h1>
<p>Hello and welcome to the final GSoC post for 2024! My task was to formalize the SWHKD parser using context-free EBNF notation. This post is to serve as a birdseye view of what
I have developed over this summer.</p>
<h1 id="report">Report</h1>