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

Add generic default #2192

Open
xsebek opened this issue Oct 20, 2024 · 0 comments
Open

Add generic default #2192

xsebek opened this issue Oct 20, 2024 · 0 comments
Labels
Z-Feature A new feature to be added to the game.

Comments

@xsebek
Copy link
Member

xsebek commented Oct 20, 2024

Is your feature request related to a problem? Please describe.

I want to write a dummy implementation of a value of an unknown type and not throw an exception.

I can not do that with undefined because Swarm is not lazy. It would have to be wrapped in either a function or delay.

Describe the solution you'd like

I would like to have a new keyword default : forall a. a, which will provide a default value of that type:

  • 0: Int
  • "": Text
  • noop: Cmd t
  • inl default: (t1 + t2)
  • \_. default: t0 -> t1
  • ...

Describe alternatives you've considered

I can write a definition like this:

def implementation_except_for_value = \value. [value=value, ...]

And provide some default at the call site, but this is not ergonomic.

Additional context

Admittedly, when #495 is implemented, I will not need dummy values as often.

@xsebek xsebek added the Z-Feature A new feature to be added to the game. label Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-Feature A new feature to be added to the game.
Projects
None yet
Development

No branches or pull requests

1 participant