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

List type #12

Open
yb66 opened this issue Mar 7, 2018 · 1 comment
Open

List type #12

yb66 opened this issue Mar 7, 2018 · 1 comment

Comments

@yb66
Copy link

yb66 commented Mar 7, 2018

Hi,

Really like the look of this library, though I'm struggling to use or define a/the list type. I tried defining my own and I've tried using the one in lib/algebrick/types.rb - I'm not even sure I should be calling that directly. I'm at a bit of a loss. Is there an example for this somewhere, or do you know of a library using it? (real world examples are always best:)

Any help or insight would be much appreciated.

Regards,
iain

@yb66
Copy link
Author

yb66 commented Mar 7, 2018

Perhaps an example of what I'm trying to achieve would be helpful. I want to define a Rose Tree. In Haskell it might be data Rose a = Node a [Rose a]

My attempt with Algebrick:

RoseTree = Algebrick.type do |rosetree|
  variants Empty = atom,
               Node  = type { fields Integer, Algebrick::List[rosetree] }
end

The error is:

TypeError: fields or variants have to be set
from /Users/iainb/Projects/algebrick/lib/algebrick/product_variant.rb:161:in `kind'

I'm probably missing something obvious.

Regards,
iain

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