mint icon indicating copy to clipboard operation
mint copied to clipboard

Improve string interpolation for various types

Open farism opened this issue 2 years ago • 0 comments

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

farism avatar Sep 03 '23 20:09 farism