Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

sealed classes #45

Open
adsharma opened this issue May 27, 2021 · 0 comments
Open

sealed classes #45

adsharma opened this issue May 27, 2021 · 0 comments

Comments

@adsharma
Copy link

There is some discussion on typing-sig about sealed classes here:
https://mail.python.org/archives/list/typing-sig@python.org/thread/QSCT2N4RFPRQN2U7NIX6VCNVNDHGO22U/

Perhaps you can chime in with your thoughts as the author of this library.

@sealed
class Tree:
    EMPTY: None
    LEAF: Leaf
    NODE: Node
  
@dataclass  
class Leaf:
   data: int
   
@dataclass
class Node:
   left: Tree
   right: Tree  

would be nice. Other python libraries with similar functionality linked from here:

https://www.reddit.com/r/Python/comments/ipqqca/sum_types_discriminated_unions_for_python/

is pretty nice syntactically.

adsharma added a commit to adsharma/adt that referenced this issue May 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant