mint-lang v0.5.0 Release Notes

Release Date: 2019-04-15 // about 5 years ago
  • JavaScript output optimizations

    โšก๏ธ All generated JavaScript code is now optimized in the following way:

    • top level entity names are now mangled (Components, Stores, Modules, etc.)
    • entity level names are now mangled
    • ๐Ÿ— white space is removed from the generated code (build only)
    • the CSS selectors and variables are now mangled

    This change means that inlined JavaScripts no longer can access arguments by name.

    This will result in a runtime error because the argument message is mangled:

    fun log (message : String) : Void {
      `console.log(message)`
    }
    

    To fix this we need to interpolate the argument:

    fun log (message : String) : Void {
      `console.log(#{message})`
    }
    

    Calls on expressions

    Previously the calls to functions were implemented in two forms: call on a
    variable and call on a module function.

    This meant that calling a function which
    is in a record or which is a result of a function call were not possible.

    ๐Ÿš€ This release makes it possible to make a call on the result of an expression.

    This is an example which raises in error in 0.4.0 but compiles properly in 0.5.0:

    module Test {
      fun a (message : String) : Function(String) {
        () : String => { message }
      }
    
      fun b : String {
        a("Hello")()
      }
    
      fun c : String {
        try {
          record = {
            function = (message : String) : String => { message }
          }
    
          record.message("Hello")
        }
      }
    }
    

    Partial Application

    Functions now can be partially applied by calling them with less arguments than
    needed.

    An example of using partial application:

      /* Format a number by thousands, output: 1,000,000 */
    
      "1000000"
      |> String.split("")
      |> Array.groupsOfFromEnd(3)
      |> Array.map(String.join(""))
      |> String.join(",")
    
      /* 
        The argument String.join("") (to Array.map) is a partially applied function
        where it's type is Function(Array(String), String)
      */
    

    โš  Warning for unkown CSS properties

    CSS properties are now checked against a list and will result in an error if
    they are not in the list.

    ๐Ÿ”„ Changes

    • ๐Ÿ›  Fixed array access ([]) when an expression is used as an index
    • 0๏ธโƒฃ Default values of properties are now only calucated once when the component is initialized
    • Providers can now be accessed the same a stores, or modules for introspection
    • Records now can be created without type definition. Such records have a temporary type definition created for them during type checking
    • [Runtime] Functions are bound to components and modules only once (in the constructor) instead of using .bind every time they are called

    Formatter

    • Inline functions can now be forced to format the body on a new line by adding
      a line break after the opening bracket {
    • 0๏ธโƒฃ Properties can now be forced to format the default values on a new line by
      โž• adding a line break after the equal sign =
    • โž• Added missing formatter for array access ([])

    Core

    • โž• Added Array.groupsOfFromEnd which is the same as Array.groupsOf but grouping from the end
    • โž• Added Array.indexBy to get an items index by a function
    • โž• Added Http.requests for inspection purposes
    • โž• Added String.rchop
    • โž• Added String.lchop
    • Html.Event is now wrapped in an actual record, so it can now be safely used in sequence or parallell expression