Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singleton with parameters #34

Open
deltadecay opened this issue Nov 25, 2024 · 1 comment
Open

Singleton with parameters #34

deltadecay opened this issue Nov 25, 2024 · 1 comment

Comments

@deltadecay
Copy link

Hello,
I want to create a tree type with parameter:

@data Tree{T} begin
    Empty
    Leaf(T)
    Node(T, Tree{T}, Tree{T})
end

And then create a tree:
Tree.Node(5, Tree.Leaf(3), Tree.Empty())

but I can't get this working, the empty tree is of another type than the integer tree. How would I instantiate a Tree.Empty() which is compatible with Tree.Leaf(3). I am thinking I might be be missing some syntax but can't find examples in the documentation.

I'm using Moshi v0.3.5 and Julia v1.11.1

@deltadecay
Copy link
Author

Okay, I think I figured the syntax. Need to specify the type for the singleton
Tree.Node(5, Tree.Leaf(3), Tree.Empty{Int64}())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant