Skip to content

Improve string interpolation for various types #642

@farism

Description

@farism

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/>
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlanguageLanguage feature

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions