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

Improve string interpolation for various types #642

Open
farism opened this issue Sep 3, 2023 · 0 comments
Open

Improve string interpolation for various types #642

farism opened this issue Sep 3, 2023 · 0 comments
Labels
discussion enhancement New feature or request language Language feature

Comments

@farism
Copy link
Contributor

farism commented Sep 3, 2023

I believe only String and Number are directly supported when using string interpolation (please correct me if I'm wrong)

It would be very convenient to support at least three other things:

  • Bool
  • Record
  • Enum

If there are others that make sense they can be considered too.

record Point2D {
  x : Number,
  y : Number
}

component Main {
  fun componentDidMount {
    /* this works */
    Debug.log("number: #{2}")

    /*
    This errors with errors with "The expected type is `String`"

    Why does only Number have implicit coercion?
    */
    Debug.log("bool: #{true}")

    /*
    Predictably this also errors with "The expected type is `String`".

    It would be nice if we could pretty print a nice json object string somehow
    */
    Debug.log("record: #{Point2D(0,0)}")

    /* enums could be nice too */
    Debug.log("enum: #{Maybe::Just(Point2D(0,0))}")
  }

  fun render : Html {
    <div/>
  }
}
@Sija Sija added enhancement New feature or request language Language feature discussion labels Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request language Language feature
Development

No branches or pull requests

2 participants