diff --git a/core/source/Array.mint b/core/source/Array.mint index 9003299ce..92be3cb4f 100644 --- a/core/source/Array.mint +++ b/core/source/Array.mint @@ -8,7 +8,7 @@ module Array { Array.any([1, 3], (number : Number) : Bool { number % 2 == 0 }) == false */ fun any (array : Array(item), function : Function(item, Bool)) : Bool { - case (Array.find(array, function)) { + case Array.find(array, function) { Maybe::Nothing => false Maybe::Just => true } @@ -44,7 +44,7 @@ module Array { array, [], (memo : Array(item), item : Maybe(item)) : Array(item) { - case (item) { + case item { Maybe::Just(value) => Array.push(memo, value) Maybe::Nothing => memo } @@ -135,7 +135,7 @@ module Array { */ fun find (array : Array(item), function : Function(item, Bool)) : Maybe(item) { Array.first( - for (item of array) { + for item of array { item } when { function(item) @@ -289,7 +289,7 @@ module Array { Array.indexOf(["a","b","c"], "a") == 0 */ fun indexOf (array : Array(item), search : item) : Maybe(Number) { - for (item, index of array) { + for item, index of array { index } when { item == search @@ -374,7 +374,7 @@ module Array { Array.map([1, 2, 3], (number : Number) : Number { number + 1 }) == [2, 3, 4] */ fun map (array : Array(item), method : Function(item, result)) : Array(result) { - for (item of array) { + for item of array { method(item) } } @@ -392,7 +392,7 @@ module Array { array : Array(item), method : Function(item, Number, result) ) : Array(result) { - for (item, index of array) { + for item, index of array { method(item, index) } } @@ -405,7 +405,7 @@ module Array { Array.max([]) == Maybe::Nothing */ fun max (array : Array(Number)) : Maybe(Number) { - if (Array.size(array) > 0) { + if Array.size(array) > 0 { Maybe::Just(`Math.max(...#{array})`) } else { Maybe::Nothing @@ -420,7 +420,7 @@ module Array { Array.min([]) == Maybe::Nothing */ fun min (array : Array(Number)) : Maybe(Number) { - if (Array.size(array) > 0) { + if Array.size(array) > 0 { Maybe::Just(`Math.min(...#{array})`) } else { Maybe::Nothing @@ -552,7 +552,7 @@ module Array { Array.reverseIf([1, 2, 3], true) == [3, 2, 1] */ fun reverseIf (array : Array(item), condition : Bool) : Array(item) { - if (condition) { + if condition { Array.reverse(array) } else { array @@ -745,7 +745,7 @@ module Array { Array.uniq(["a", "a", "b", "b", "c"] == ["a", "b", "c"] */ fun uniq (array : Array(item)) : Array(item) { - for (item, index of array) { + for item, index of array { item } when { indexOf(array, item) == Maybe::Just(index) @@ -781,7 +781,7 @@ module Array { index : Number, method : Function(item, item) ) : Array(item) { - case (array[index]) { + case array[index] { Maybe::Just(item) => setAt(array, index, method(item)) Maybe::Nothing => array } diff --git a/core/source/Dom.mint b/core/source/Dom.mint index 9f7054baf..014901f0f 100644 --- a/core/source/Dom.mint +++ b/core/source/Dom.mint @@ -56,7 +56,7 @@ module Dom { |> Dom.getElementById() */ fun focus (maybeElement : Maybe(Dom.Element)) : Promise(Void) { - case (maybeElement) { + case maybeElement { Maybe::Just(element) => { focusWhenVisible(element) diff --git a/core/source/Http.mint b/core/source/Http.mint index a3ab0f38e..81c4c1068 100644 --- a/core/source/Http.mint +++ b/core/source/Http.mint @@ -199,7 +199,7 @@ module Http { |> Http.send() */ fun jsonBody (request : Http.Request, body : Object) : Http.Request { - if (hasHeader(request, "Content-Type")) { + if hasHeader(request, "Content-Type") { { request | body: `JSON.stringify(#{body})` } } else { { request | body: `JSON.stringify(#{body})` } diff --git a/core/source/If.mint b/core/source/If.mint index e7207a47b..0412699d5 100644 --- a/core/source/If.mint +++ b/core/source/If.mint @@ -7,7 +7,7 @@ component If { property condition : Bool = true fun render : Array(Html) { - if (condition) { + if condition { children } else { [] diff --git a/core/source/Map.mint b/core/source/Map.mint index 202c81f75..61310221b 100644 --- a/core/source/Map.mint +++ b/core/source/Map.mint @@ -14,7 +14,7 @@ module Map { */ fun delete (map : Map(key, value), keyToDelete : key) : Map(key, value) { Map.fromArray( - for (key, value of map) { + for key, value of map { {key, value} } when { key != keyToDelete @@ -31,7 +31,7 @@ module Map { */ fun deleteValues (map : Map(key, value), valueToDelete : value) : Map(key, value) { Map.fromArray( - for (key, value of map) { + for key, value of map { {key, value} } when { value != valueToDelete @@ -70,7 +70,7 @@ module Map { function : Function(value, Bool) ) : Maybe(key) { Array.first( - for (key, value of map) { + for key, value of map { key } when { function(value) @@ -98,7 +98,7 @@ module Map { */ fun get (map : Map(key, value), search : key) : Maybe(value) { Array.first( - for (key, value of map) { + for key, value of map { value } when { key == search @@ -128,7 +128,7 @@ module Map { */ fun has (map : Map(key, value), search : key) : Bool { Array.first( - for (key, value of map) { + for key, value of map { true } when { key == search @@ -158,7 +158,7 @@ module Map { |> Map.values()) == ["a", "b"] */ fun keys (map : Map(key, value)) : Array(key) { - for (key, value of map) { + for key, value of map { key } } @@ -177,7 +177,7 @@ module Map { function : Function(key, value, result) ) : Map(key, result) { Map.fromArray( - for (key, value of map) { + for key, value of map { ({key, function(key, value)}) }) } @@ -318,7 +318,7 @@ module Map { |> Map.values()) == [1, 2] */ fun values (map : Map(key, value)) : Array(value) { - for (key, value of map) { + for key, value of map { value } } diff --git a/core/source/Math.mint b/core/source/Math.mint index 6f2ac62d3..3d0a50f6d 100644 --- a/core/source/Math.mint +++ b/core/source/Math.mint @@ -124,7 +124,7 @@ module Math { */ fun truncate (value : Number, to : Number) : Number { let multiplier = - if (to == 0) { + if to == 0 { 1 } else { to * 100 diff --git a/core/source/Maybe.mint b/core/source/Maybe.mint index e6c2a7f51..c3916d58a 100644 --- a/core/source/Maybe.mint +++ b/core/source/Maybe.mint @@ -21,7 +21,7 @@ module Maybe { maybe : Maybe(value), transform : Function(value, Maybe(result)) ) : Maybe(result) { - case (maybe) { + case maybe { Maybe::Just(value) => transform(value) Maybe::Nothing => Maybe::Nothing } @@ -35,7 +35,7 @@ module Maybe { |> Maybe.flatten()) == Maybe.just("A") */ fun flatten (maybe : Maybe(Maybe(value))) : Maybe(value) { - case (maybe) { + case maybe { Maybe::Nothing => Maybe::Nothing Maybe::Just(value) => value } @@ -73,7 +73,7 @@ module Maybe { |> Maybe.map((number : Number) : Number { number + 2 })) == 3 */ fun map (maybe : Maybe(value), func : Function(value, result)) : Maybe(result) { - case (maybe) { + case maybe { Maybe::Just(value) => Maybe::Just(func(value)) Maybe::Nothing => Maybe::Nothing } @@ -102,7 +102,7 @@ module Maybe { Maybe.toResult(Maybe.just("A"), "Error") == Result.ok("A") */ fun toResult (maybe : Maybe(value), error : error) : Result(error, value) { - case (maybe) { + case maybe { Maybe::Just(value) => Result::Ok(value) Maybe::Nothing => Result::Err(error) } @@ -125,7 +125,7 @@ module Maybe { Maybe.withLazyDefault(Maybe.just("B"), () { "A" }) == "B" */ fun withLazyDefault (maybe : Maybe(value), func : Function(value)) : value { - case (maybe) { + case maybe { Maybe::Nothing => func() Maybe::Just(value) => value } diff --git a/core/source/Number.mint b/core/source/Number.mint index a1d5854fe..11644a709 100644 --- a/core/source/Number.mint +++ b/core/source/Number.mint @@ -26,7 +26,7 @@ module Number { |> Maybe.withDefault("") |> String.chopEnd("0") - if (String.isEmpty(decimals)) { + if String.isEmpty(decimals) { prefix + digits } else { prefix + digits + "." + decimals diff --git a/core/source/Provider/AnimationFrame.mint b/core/source/Provider/AnimationFrame.mint index b54536097..33819a342 100644 --- a/core/source/Provider/AnimationFrame.mint +++ b/core/source/Provider/AnimationFrame.mint @@ -10,7 +10,7 @@ provider Provider.AnimationFrame : Provider.AnimationFrame.Subscription { /* Call the subscribers. */ fun process (timestamp : Number) : Promise(Void) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.frames(timestamp) } @@ -19,9 +19,9 @@ provider Provider.AnimationFrame : Provider.AnimationFrame.Subscription { /* Updates the provider. */ fun update : Promise(Void) { - if (Array.isEmpty(subscriptions)) { + if Array.isEmpty(subscriptions) { next { id: AnimationFrame.cancel(id) } - } else if (id == -1) { + } else if id == -1 { next { id: AnimationFrame.request(process) } } else { next { } diff --git a/core/source/Provider/ElementSize.mint b/core/source/Provider/ElementSize.mint index 1a2256610..f5085d750 100644 --- a/core/source/Provider/ElementSize.mint +++ b/core/source/Provider/ElementSize.mint @@ -14,9 +14,9 @@ provider Provider.ElementSize : Provider.ElementSize.Subscription { /* Notifies all subscribers when there are changes. */ fun notify (entries : Array(ResizeObserver.Entry)) : Array(Array(Promise(Void))) { - for (entry of entries) { - for (subscription of subscriptions) { - if (subscription.element == Maybe::Just(entry.target)) { + for entry of entries { + for subscription of subscriptions { + if subscription.element == Maybe::Just(entry.target) { subscription.changes(entry.dimensions) } else { next { } @@ -27,12 +27,12 @@ provider Provider.ElementSize : Provider.ElementSize.Subscription { /* Updates the provider. */ fun update : Promise(Void) { - for (element of Array.compact(observedElements)) { + for element of Array.compact(observedElements) { ResizeObserver.unobserve(observer, element) } - for (subscription of subscriptions) { - case (subscription.element) { + for subscription of subscriptions { + case subscription.element { Maybe::Just(element) => { ResizeObserver.observe(observer, element) @@ -46,7 +46,7 @@ provider Provider.ElementSize : Provider.ElementSize.Subscription { next { observedElements: - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.element } } diff --git a/core/source/Provider/Intersection.mint b/core/source/Provider/Intersection.mint index c096d810f..4be7c7122 100644 --- a/core/source/Provider/Intersection.mint +++ b/core/source/Provider/Intersection.mint @@ -18,14 +18,14 @@ provider Provider.Intersection : Provider.Intersection.Subscription { longer present. */ let currentObservers = - for (item of observers) { + for item of observers { let {subscription, observer} = item - if (Array.contains(subscriptions, subscription)) { + if Array.contains(subscriptions, subscription) { Maybe::Just({subscription, observer}) } else { - case (subscription.element) { + case subscription.element { Maybe::Just(observed) => { IntersectionObserver.unobserve(observer, observed) @@ -40,8 +40,8 @@ provider Provider.Intersection : Provider.Intersection.Subscription { /* Create new observers. */ let newObservers = - for (subscription of subscriptions) { - case (subscription.element) { + for subscription of subscriptions { + case subscription.element { Maybe::Just(observed) => Maybe::Just( { diff --git a/core/source/Provider/Keydown.mint b/core/source/Provider/Keydown.mint index bb39f150d..e94f3509b 100644 --- a/core/source/Provider/Keydown.mint +++ b/core/source/Provider/Keydown.mint @@ -10,18 +10,18 @@ provider Provider.Keydown : Provider.Keydown.Subscription { /* The event handler. */ fun handle (event : Html.Event) : Array(Promise(Void)) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.keydowns(event) } } /* Updates the provider. */ fun update : Promise(Void) { - if (Array.isEmpty(subscriptions)) { + if Array.isEmpty(subscriptions) { Maybe.map(listener, (unsubscribe : Function(Void)) { unsubscribe() }) next { listener: Maybe::Nothing } } else { - case (listener) { + case listener { Maybe::Nothing => next { listener: Maybe::Just(Window.addEventListener("keydown", true, handle)) } diff --git a/core/source/Provider/Keyup.mint b/core/source/Provider/Keyup.mint index cbeb4af5d..10e1541cc 100644 --- a/core/source/Provider/Keyup.mint +++ b/core/source/Provider/Keyup.mint @@ -10,18 +10,18 @@ provider Provider.Keyup : Provider.Keyup.Subscription { /* The event handler. */ fun handle (event : Html.Event) : Array(Promise(Void)) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.keyups(event) } } /* Updates the provider. */ fun update : Promise(Void) { - if (Array.isEmpty(subscriptions)) { + if Array.isEmpty(subscriptions) { Maybe.map(listener, (unsubscribe : Function(Void)) { unsubscribe() }) next { listener: Maybe::Nothing } } else { - case (listener) { + case listener { Maybe::Nothing => next { listener: Maybe::Just(Window.addEventListener("keyup", true, handle)) } diff --git a/core/source/Provider/MediaQuery.mint b/core/source/Provider/MediaQuery.mint index 2d5cef416..d86b6b7b4 100644 --- a/core/source/Provider/MediaQuery.mint +++ b/core/source/Provider/MediaQuery.mint @@ -21,7 +21,7 @@ provider Provider.MediaQuery : Provider.MediaQuery.Subscription { memo : Map(String, Function(Void)), subscription : Provider.MediaQuery.Subscription ) { - case (Map.get(listeners, subscription.query)) { + case Map.get(listeners, subscription.query) { Maybe::Nothing => Map.set( memo, @@ -29,7 +29,7 @@ provider Provider.MediaQuery : Provider.MediaQuery.Subscription { Window.addMediaQueryListener( subscription.query, (active : Bool) { - for (item of subscriptions) { + for item of subscriptions { subscription.changes(active) } when { item.query == subscription.query @@ -54,7 +54,7 @@ provider Provider.MediaQuery : Provider.MediaQuery.Subscription { |> Array.find( (item : Provider.MediaQuery.Subscription) { item.query == query }) - case (subscription) { + case subscription { Maybe::Just => memo Maybe::Nothing => diff --git a/core/source/Provider/Mouse.mint b/core/source/Provider/Mouse.mint index fb6b343b1..51dc783f8 100644 --- a/core/source/Provider/Mouse.mint +++ b/core/source/Provider/Mouse.mint @@ -15,7 +15,7 @@ provider Provider.Mouse : Provider.Mouse.Subscription { /* Updates the provider. */ fun update : Promise(Void) { - if (Array.isEmpty(subscriptions)) { + if Array.isEmpty(subscriptions) { Maybe.map( listeners, ( @@ -31,7 +31,7 @@ provider Provider.Mouse : Provider.Mouse.Subscription { next { listeners: Maybe::Nothing } } else { - case (listeners) { + case listeners { Maybe::Nothing => next { @@ -42,7 +42,7 @@ provider Provider.Mouse : Provider.Mouse.Subscription { "click", true, (event : Html.Event) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.clicks(event) } }), @@ -57,7 +57,7 @@ provider Provider.Mouse : Provider.Mouse.Subscription { id: AnimationFrame.request( (timestamp : Number) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.moves(event) } }) @@ -67,7 +67,7 @@ provider Provider.Mouse : Provider.Mouse.Subscription { "mouseup", false, (event : Html.Event) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.ups(event) } }) diff --git a/core/source/Provider/Mutation.mint b/core/source/Provider/Mutation.mint index ee55c6495..770b8d2c8 100644 --- a/core/source/Provider/Mutation.mint +++ b/core/source/Provider/Mutation.mint @@ -17,11 +17,11 @@ provider Provider.Mutation : Provider.Mutation.Subscription { /* Notifies the subscribers when changes occur. */ fun notify (entries : Array(MutationObserver.Entry)) : Array(Array(Promise(Void))) { - for (entry of entries) { - for (subscription of subscriptions) { - case (subscription.element) { + for entry of entries { + for subscription of subscriptions { + case subscription.element { Maybe::Just(element) => - if (Dom.contains(element, entry.target)) { + if Dom.contains(element, entry.target) { subscription.changes() } else { next { } @@ -36,13 +36,13 @@ provider Provider.Mutation : Provider.Mutation.Subscription { /* Updates the provider. */ fun update : Promise(Void) { /* Unobserve all elements. */ - for (element of Array.compact(observedElements)) { + for element of Array.compact(observedElements) { MutationObserver.unobserve(observer, element) } /* For each subscription observe the given elements. */ - for (subscription of subscriptions) { - case (subscription.element) { + for subscription of subscriptions { + case subscription.element { Maybe::Just(element) => { MutationObserver.observe(observer, element, true, true) @@ -57,7 +57,7 @@ provider Provider.Mutation : Provider.Mutation.Subscription { next { observedElements: - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.element } } diff --git a/core/source/Provider/OutsideClick.mint b/core/source/Provider/OutsideClick.mint index 11a0e43e2..882569707 100644 --- a/core/source/Provider/OutsideClick.mint +++ b/core/source/Provider/OutsideClick.mint @@ -11,13 +11,13 @@ provider Provider.OutsideClick : Provider.OutsideClick.Subscription { /* The event handler. */ fun handle (event : Html.Event) : Array(Promise(Void)) { - for (subscription of subscriptions) { + for subscription of subscriptions { let inside = subscription.elements |> Array.compact() |> Array.any((item : Dom.Element) { Dom.contains(item, event.target) }) - if (inside) { + if inside { Promise.never() } else { subscription.clicks() @@ -27,11 +27,11 @@ provider Provider.OutsideClick : Provider.OutsideClick.Subscription { /* Updates the provider. */ fun update : Promise(Void) { - if (Array.isEmpty(subscriptions)) { + if Array.isEmpty(subscriptions) { Maybe.map(listener, (unsubscribe : Function(Void)) { unsubscribe() }) next { listener: Maybe::Nothing } } else { - case (listener) { + case listener { Maybe::Nothing => next { listener: Maybe::Just(Window.addEventListener("mouseup", true, handle)) } diff --git a/core/source/Provider/Pointer.mint b/core/source/Provider/Pointer.mint index d7c1cbcd6..1310fd94e 100644 --- a/core/source/Provider/Pointer.mint +++ b/core/source/Provider/Pointer.mint @@ -15,7 +15,7 @@ provider Provider.Pointer : Provider.Pointer.Subscription { /* Updates the provider. */ fun update : Promise(Void) { - if (Array.isEmpty(subscriptions)) { + if Array.isEmpty(subscriptions) { Maybe.map( listeners, ( @@ -31,7 +31,7 @@ provider Provider.Pointer : Provider.Pointer.Subscription { next { listeners: Maybe::Nothing } } else { - case (listeners) { + case listeners { Maybe::Nothing => next { @@ -42,7 +42,7 @@ provider Provider.Pointer : Provider.Pointer.Subscription { "pointerdown", true, (event : Html.Event) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.downs(event) } }), @@ -57,7 +57,7 @@ provider Provider.Pointer : Provider.Pointer.Subscription { id: AnimationFrame.request( (timestamp : Number) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.moves(event) } }) @@ -67,7 +67,7 @@ provider Provider.Pointer : Provider.Pointer.Subscription { "pointerup", false, (event : Html.Event) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.ups(event) } }) diff --git a/core/source/Provider/Resize.mint b/core/source/Provider/Resize.mint index 4246f5dc5..b44499bce 100644 --- a/core/source/Provider/Resize.mint +++ b/core/source/Provider/Resize.mint @@ -10,18 +10,18 @@ provider Provider.Resize : Provider.Resize.Subscription { /* Handles the resize events. */ fun handle (event : Html.Event) : Array(Promise(Void)) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.resizes(event) } } /* Updates the provider. */ fun update : Promise(Void) { - if (Array.isEmpty(subscriptions)) { + if Array.isEmpty(subscriptions) { Maybe.map(listener, (unsubscribe : Function(Void)) { unsubscribe() }) next { listener: Maybe::Nothing } } else { - case (listener) { + case listener { Maybe::Nothing => next { listener: Maybe::Just(Window.addEventListener("resize", true, handle)) } diff --git a/core/source/Provider/Scroll.mint b/core/source/Provider/Scroll.mint index bfae69d11..c1a506869 100644 --- a/core/source/Provider/Scroll.mint +++ b/core/source/Provider/Scroll.mint @@ -10,18 +10,18 @@ provider Provider.Scroll : Provider.Scroll.Subscription { /* Handles the scroll events. */ fun handle (event : Html.Event) : Array(Promise(Void)) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.scrolls(event) } } /* Updates the provider. */ fun update : Promise(Void) { - if (Array.isEmpty(subscriptions)) { + if Array.isEmpty(subscriptions) { Maybe.map(listener, (unsubscribe : Function(Void)) { unsubscribe() }) next { listener: Maybe::Nothing } } else { - case (listener) { + case listener { Maybe::Nothing => next { listener: Maybe::Just(Window.addEventListener("scroll", false, handle)) } diff --git a/core/source/Provider/Shortcuts.mint b/core/source/Provider/Shortcuts.mint index 26146c223..84d0c35e3 100644 --- a/core/source/Provider/Shortcuts.mint +++ b/core/source/Provider/Shortcuts.mint @@ -26,14 +26,14 @@ provider Provider.Shortcuts : Provider.Shortcuts.Subscription { /* Handles keypress events. */ fun handle (event : Html.Event) : Array(Array(Promise(Void))) { let control = - if (event.ctrlKey && event.keyCode != 17) { + if event.ctrlKey && event.keyCode != 17 { Maybe::Just(17) } else { Maybe::Nothing } let shift = - if (event.shiftKey && event.keyCode != 16) { + if event.shiftKey && event.keyCode != 16 { Maybe::Just(16) } else { Maybe::Nothing @@ -47,8 +47,8 @@ provider Provider.Shortcuts : Provider.Shortcuts.Subscription { let focused = `document.querySelector("*:focus")` - for (subscription of subscriptions) { - for (item of subscription.shortcuts) { + for subscription of subscriptions { + for item of subscription.shortcuts { Html.Event.stopPropagation(event) Html.Event.preventDefault(event) item.action() @@ -64,11 +64,11 @@ provider Provider.Shortcuts : Provider.Shortcuts.Subscription { /* Updates the provider. */ fun update : Promise(Void) { - if (Array.isEmpty(subscriptions)) { + if Array.isEmpty(subscriptions) { Maybe.map(listener, (unsubscribe : Function(Void)) { unsubscribe() }) next { listener: Maybe::Nothing } } else { - case (listener) { + case listener { Maybe::Nothing => next { listener: Maybe::Just(Window.addEventListener("keydown", true, handle)) } diff --git a/core/source/Provider/TabFocus.mint b/core/source/Provider/TabFocus.mint index 02117feb3..c31773bb9 100644 --- a/core/source/Provider/TabFocus.mint +++ b/core/source/Provider/TabFocus.mint @@ -12,11 +12,11 @@ provider Providers.TabFocus : Provider.TabFocus.Subscription { /* The `keyUp` event handler. */ fun handleKeyUp (event : Html.Event) : Array(Promise(Void)) { - if (event.keyCode == Html.Event:TAB) { + if event.keyCode == Html.Event:TAB { let activeElement = Dom.getActiveElement() - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.onTabIn() } when { subscription.element == activeElement @@ -28,11 +28,11 @@ provider Providers.TabFocus : Provider.TabFocus.Subscription { /* The `keyDown` event handler. */ fun handleKeyDown (event : Html.Event) : Array(Promise(Void)) { - if (event.keyCode == Html.Event:TAB) { + if event.keyCode == Html.Event:TAB { let target = Maybe::Just(event.target) - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.onTabOut() } when { subscription.element == target @@ -44,7 +44,7 @@ provider Providers.TabFocus : Provider.TabFocus.Subscription { /* Updates the provider. */ fun update : Promise(Void) { - if (Array.isEmpty(subscriptions)) { + if Array.isEmpty(subscriptions) { Maybe.map( listeners, (methods : Tuple(Function(Void), Function(Void))) { @@ -57,7 +57,7 @@ provider Providers.TabFocus : Provider.TabFocus.Subscription { next { listeners: Maybe::Nothing } } else { - case (listeners) { + case listeners { Maybe::Nothing => next { diff --git a/core/source/Provider/Tick.mint b/core/source/Provider/Tick.mint index 8c56093c0..112ac5560 100644 --- a/core/source/Provider/Tick.mint +++ b/core/source/Provider/Tick.mint @@ -9,16 +9,16 @@ provider Provider.Tick : Provider.Tick.Subscription { /* Call the subscribers. */ fun process : Array(Promise(Void)) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.ticks() } } /* Attaches the provider. */ fun update : Promise(Void) { - if (Array.isEmpty(subscriptions)) { + if Array.isEmpty(subscriptions) { next { id: `clearInterval(#{id}) || -1` } - } else if (id == -1) { + } else if id == -1 { next { id: `setInterval(#{process}, 1000)` } } else { next { } diff --git a/core/source/Provider/Url.mint b/core/source/Provider/Url.mint index 8f925f43a..5f6589f1a 100644 --- a/core/source/Provider/Url.mint +++ b/core/source/Provider/Url.mint @@ -13,18 +13,18 @@ provider Provider.Url : Provider.Url.Subscription { let url = Window.url() - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.changes(url) } } /* Updates the provider. */ fun update : Promise(Void) { - if (Array.isEmpty(subscriptions)) { + if Array.isEmpty(subscriptions) { Maybe.map(listener, (unsubscribe : Function(Void)) { unsubscribe() }) next { listener: Maybe::Nothing } } else { - case (listener) { + case listener { Maybe::Nothing => next { listener: Maybe::Just(Window.addEventListener("popstate", false, handle)) } diff --git a/core/source/Provider/Websocket.mint b/core/source/Provider/Websocket.mint index 63f0709d9..3e41e82a2 100644 --- a/core/source/Provider/Websocket.mint +++ b/core/source/Provider/Websocket.mint @@ -5,7 +5,7 @@ provider Provider.WebSocket : WebSocket.Config { /* Handles the open event. */ fun onOpen (url : String, socket : WebSocket) : Promise(Void) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.onOpen(socket) } when { subscription.url == url @@ -16,7 +16,7 @@ provider Provider.WebSocket : WebSocket.Config { /* Handles the message event. */ fun onMessage (url : String, data : String) : Promise(Void) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.onMessage(data) } when { subscription.url == url @@ -27,7 +27,7 @@ provider Provider.WebSocket : WebSocket.Config { /* Handles the error event. */ fun onError (url : String) : Promise(Void) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.onError() } when { subscription.url == url @@ -38,7 +38,7 @@ provider Provider.WebSocket : WebSocket.Config { /* Handles the close event. */ fun onClose (url : String) : Promise(Void) { - for (subscription of subscriptions) { + for subscription of subscriptions { subscription.onClose() } when { subscription.url == url @@ -57,7 +57,7 @@ provider Provider.WebSocket : WebSocket.Config { memo : Map(String, WebSocket), config : WebSocket.Config ) { - case (Map.get(connections, config.url)) { + case Map.get(connections, config.url) { Maybe::Nothing => Map.set( memo, @@ -90,7 +90,7 @@ provider Provider.WebSocket : WebSocket.Config { |> Array.find( (config : WebSocket.Config) { config.url == url }) - case (subscription) { + case subscription { Maybe::Nothing => { WebSocket.closeWithoutReconnecting(socket) diff --git a/core/source/Result.mint b/core/source/Result.mint index 88301990f..c252f8cfb 100644 --- a/core/source/Result.mint +++ b/core/source/Result.mint @@ -39,7 +39,7 @@ module Result { |> Result.isError()) == true */ fun isError (input : Result(a, b)) : Bool { - case (input) { + case input { Result::Err => true Result::Ok => false } @@ -52,7 +52,7 @@ module Result { |> Result.isOk()) == true */ fun isOk (input : Result(a, b)) : Bool { - case (input) { + case input { Result::Err => false Result::Ok => true } @@ -65,7 +65,7 @@ module Result { Result.join(Result::Err("Error") == Result::Err("Error") */ fun join (input : Result(error, Result(error, value))) : Result(error, value) { - case (input) { + case input { Result::Err(error) => Result::Err(error) Result::Ok(value) => value } @@ -81,7 +81,7 @@ module Result { |> Result.map(\item : String => item + "1")) == Result.ok("ok1") */ fun map (input : Result(a, b), func : Function(b, c)) : Result(a, c) { - case (input) { + case input { Result::Ok(value) => Result::Ok(func(value)) Result::Err => input } @@ -97,7 +97,7 @@ module Result { |> Result.mapError(\item : String => item + "1")) == Result.ok("ok") */ fun mapError (input : Result(a, b), func : Function(a, c)) : Result(c, b) { - case (input) { + case input { Result::Err(value) => Result::Err(func(value)) Result::Ok => input } @@ -123,7 +123,7 @@ module Result { |> Result.toMaybe()) == Maybe.nothing() */ fun toMaybe (result : Result(a, b)) : Maybe(b) { - case (result) { + case result { Result::Ok(value) => Maybe::Just(value) Result::Err => Maybe::Nothing } @@ -139,7 +139,7 @@ module Result { |> Result.withDefault("a")) == "ok" */ fun withDefault (input : Result(a, b), defaultValue : b) : b { - case (input) { + case input { Result::Ok(value) => value Result::Err => defaultValue } @@ -155,7 +155,7 @@ module Result { |> Result.withError("a")) == "a" */ fun withError (input : Result(a, b), defaultError : a) : a { - case (input) { + case input { Result::Err(value) => value Result::Ok => defaultError } diff --git a/core/source/String.mint b/core/source/String.mint index 49fcbc063..e4191dcff 100644 --- a/core/source/String.mint +++ b/core/source/String.mint @@ -494,7 +494,7 @@ module String { String.withDefault("Hello", "The quick brown fox jumps.") == "Hello" */ fun withDefault (string : String, value : String) : String { - if (String.isEmpty(string)) { + if String.isEmpty(string) { value } else { string diff --git a/core/source/Time.mint b/core/source/Time.mint index b80db5f52..6edc40ea5 100644 --- a/core/source/Time.mint +++ b/core/source/Time.mint @@ -167,7 +167,7 @@ module Time { Time.month(Time.utcDate(2018, 4, 5)) == Month::April */ fun month (time : Time) : Month { - case (monthNumber(time)) { + case monthNumber(time) { 1 => Month::January 2 => Month::February 3 => Month::March @@ -270,7 +270,7 @@ module Time { Time.dayOfWeek(Time.utcDate(2018, 4, 5)) == Weekday::Thursday */ fun dayOfWeek (time : Time) : Weekday { - case (dayOfWeekNumber(time)) { + case dayOfWeekNumber(time) { 1 => Weekday::Monday 2 => Weekday::Tuesday 3 => Weekday::Wednesday diff --git a/core/source/Time/Format.mint b/core/source/Time/Format.mint index e32dbdb96..aee9a2a40 100644 --- a/core/source/Time/Format.mint +++ b/core/source/Time/Format.mint @@ -19,7 +19,7 @@ module Time { let distance = Time.toUnix(to) - Time.toUnix(from) - if (distance == 0) { + if distance == 0 { language.rightNow } else { let seconds = @@ -37,38 +37,38 @@ module Time { let positive = distance > 0 - if (minutes < 1) { - if (positive) { + if minutes < 1 { + if positive { language.someSecondsAgo } else { language.inSomeSeconds }(seconds) - } else if (hours < 1) { - if (positive) { + } else if hours < 1 { + if positive { language.someMinutesAgo } else { language.inSomeMinutes }(minutes) - } else if (hours < 24) { - if (positive) { + } else if hours < 24 { + if positive { language.someHoursAgo } else { language.inSomeHours }(hours) - } else if (days < 30) { - if (positive) { + } else if days < 30 { + if positive { language.someDaysAgo } else { language.inSomeDays }(days) - } else if (days < 365) { - if (positive) { + } else if days < 365 { + if positive { language.someMonthsAgo } else { language.inSomeMonths }(Math.trunc(days / 30)) } else { - if (positive) { + if positive { language.someYearsAgo } else { language.inSomeYears @@ -196,7 +196,7 @@ module Time { language : Time.Format.Language, token : String ) : String { - case (token) { + case token { /* short day name (Sun, Mon, Tue, ...) */ "a" => time @@ -424,7 +424,7 @@ module Time { let number = dayOfWeekNumber(time) - if (number == 7) { + if number == 7 { 0 } else { number diff --git a/core/source/Time/Languages/English.mint b/core/source/Time/Languages/English.mint index 2d2d5e5de..dd17fb942 100644 --- a/core/source/Time/Languages/English.mint +++ b/core/source/Time/Languages/English.mint @@ -4,7 +4,7 @@ module Time.Format { { toMonthAbbreviation: (month : Month) { - case (month) { + case month { Month::January => "Jan" Month::February => "Feb" Month::March => "Mar" @@ -21,7 +21,7 @@ module Time.Format { }, toMonthName: (month : Month) { - case (month) { + case month { Month::January => "January" Month::February => "February" Month::March => "March" @@ -38,7 +38,7 @@ module Time.Format { }, toWeekdayName: (weekday : Weekday) { - case (weekday) { + case weekday { Weekday::Monday => "Monday" Weekday::Tuesday => "Tuesday" Weekday::Wednesday => "Wednesday" @@ -50,7 +50,7 @@ module Time.Format { }, toWeekdayAbbreviation: (weekday : Weekday) { - case (weekday) { + case weekday { Weekday::Monday => "Mon" Weekday::Tuesday => "Tue" Weekday::Wednesday => "Wed" @@ -62,13 +62,13 @@ module Time.Format { }, toOrdinalSuffix: (day : Number) { - case (day % 100) { + case day % 100 { 11 => "th" 12 => "th" 13 => "th" => - case (day % 10) { + case day % 10 { 1 => "st" 2 => "nd" 3 => "rd" @@ -78,7 +78,7 @@ module Time.Format { }, amPm: (hour : Number) { - if (hour >= 12) { + if hour >= 12 { "pm" } else { "am" @@ -86,7 +86,7 @@ module Time.Format { }, someSecondsAgo: (seconds : Number) { - if (seconds < 30) { + if seconds < 30 { "just now" } else { "#{seconds} seconds ago" @@ -94,7 +94,7 @@ module Time.Format { }, someMinutesAgo: (minutes : Number) { - if (minutes < 2) { + if minutes < 2 { "a minute ago" } else { "#{minutes} minutes ago" @@ -102,7 +102,7 @@ module Time.Format { }, someHoursAgo: (hours : Number) { - if (hours < 2) { + if hours < 2 { "an hour ago" } else { "#{hours} hours ago" @@ -110,7 +110,7 @@ module Time.Format { }, someDaysAgo: (days : Number) { - if (days < 2) { + if days < 2 { "yesterday" } else { "#{days} days ago" @@ -118,7 +118,7 @@ module Time.Format { }, someMonthsAgo: (months : Number) { - if (months < 2) { + if months < 2 { "last month" } else { "#{months} months ago" @@ -126,7 +126,7 @@ module Time.Format { }, someYearsAgo: (years : Number) { - if (years < 2) { + if years < 2 { "last year" } else { "#{years} years ago" @@ -134,7 +134,7 @@ module Time.Format { }, inSomeSeconds: (seconds : Number) { - if (seconds < 30) { + if seconds < 30 { "in a few seconds" } else { "in #{seconds} seconds" @@ -142,7 +142,7 @@ module Time.Format { }, inSomeMinutes: (minutes : Number) { - if (minutes < 2) { + if minutes < 2 { "in a minute" } else { "in #{minutes} minutes" @@ -150,7 +150,7 @@ module Time.Format { }, inSomeHours: (hours : Number) { - if (hours < 2) { + if hours < 2 { "in an hour" } else { "in #{hours} hours" @@ -158,7 +158,7 @@ module Time.Format { }, inSomeDays: (days : Number) { - if (days < 2) { + if days < 2 { "tomorrow" } else { "in #{days} days" @@ -166,7 +166,7 @@ module Time.Format { }, inSomeMonths: (months : Number) { - if (months < 2) { + if months < 2 { "in a month" } else { "in #{months} months" @@ -174,7 +174,7 @@ module Time.Format { }, inSomeYears: (years : Number) { - if (years < 2) { + if years < 2 { "in a year" } else { "in #{years} years" diff --git a/core/source/Time/Languages/Hungarian.mint b/core/source/Time/Languages/Hungarian.mint index 6e438b384..a9fbd7723 100644 --- a/core/source/Time/Languages/Hungarian.mint +++ b/core/source/Time/Languages/Hungarian.mint @@ -4,7 +4,7 @@ module Time.Format { { toMonthAbbreviation: (month : Month) { - case (month) { + case month { Month::January => "jan." Month::February => "febr." Month::March => "márc." @@ -21,7 +21,7 @@ module Time.Format { }, toMonthName: (month : Month) { - case (month) { + case month { Month::January => "janár" Month::February => "február" Month::March => "március" @@ -38,7 +38,7 @@ module Time.Format { }, toWeekdayName: (weekday : Weekday) { - case (weekday) { + case weekday { Weekday::Monday => "hétfő" Weekday::Tuesday => "kedd" Weekday::Wednesday => "szerda" @@ -50,7 +50,7 @@ module Time.Format { }, toWeekdayAbbreviation: (weekday : Weekday) { - case (weekday) { + case weekday { Weekday::Monday => "hé" Weekday::Tuesday => "ke" Weekday::Wednesday => "sze." @@ -62,7 +62,7 @@ module Time.Format { }, toOrdinalSuffix: (day : Number) { - case (day) { + case day { 1 => "-je" 2 => "-a" 3 => "-a" @@ -99,7 +99,7 @@ module Time.Format { }, amPm: (hour : Number) { - if (hour >= 12) { + if hour >= 12 { "du." } else { "de." @@ -107,7 +107,7 @@ module Time.Format { }, someSecondsAgo: (seconds : Number) { - if (seconds < 30) { + if seconds < 30 { "épp most" } else { "#{seconds} másodperce" @@ -115,7 +115,7 @@ module Time.Format { }, someMinutesAgo: (minutes : Number) { - if (minutes < 2) { + if minutes < 2 { "egy perce" } else { "#{minutes} perce" @@ -123,7 +123,7 @@ module Time.Format { }, someHoursAgo: (hours : Number) { - if (hours < 2) { + if hours < 2 { "egy órája" } else { "#{hours} órája" @@ -131,7 +131,7 @@ module Time.Format { }, someDaysAgo: (days : Number) { - if (days < 2) { + if days < 2 { "tegnap" } else { "#{days} napja" @@ -139,7 +139,7 @@ module Time.Format { }, someMonthsAgo: (months : Number) { - if (months < 2) { + if months < 2 { "egy hónapja" } else { "#{months} hónapja" @@ -147,7 +147,7 @@ module Time.Format { }, someYearsAgo: (years : Number) { - if (years < 2) { + if years < 2 { "egy éve" } else { "#{years} éve" @@ -155,7 +155,7 @@ module Time.Format { }, inSomeSeconds: (seconds : Number) { - if (seconds < 30) { + if seconds < 30 { "nemsokára" } else { "#{seconds} másodperc múlva" @@ -163,7 +163,7 @@ module Time.Format { }, inSomeMinutes: (minutes : Number) { - if (minutes < 2) { + if minutes < 2 { "egy perc múlva" } else { "#{minutes} perc múlva" @@ -171,7 +171,7 @@ module Time.Format { }, inSomeHours: (hours : Number) { - if (hours < 2) { + if hours < 2 { "egy óra múlva" } else { "#{hours} óra múlva" @@ -179,7 +179,7 @@ module Time.Format { }, inSomeDays: (days : Number) { - if (days < 2) { + if days < 2 { "holnap" } else { "#{days} nam múlva" @@ -187,7 +187,7 @@ module Time.Format { }, inSomeMonths: (months : Number) { - if (months < 2) { + if months < 2 { "egy hónap múlva" } else { "#{months} hónap múlva" @@ -195,7 +195,7 @@ module Time.Format { }, inSomeYears: (years : Number) { - if (years < 2) { + if years < 2 { "egy év múlva" } else { "#{years} év múlva" diff --git a/core/source/Unless.mint b/core/source/Unless.mint index e78e0b7ab..520ed63b9 100644 --- a/core/source/Unless.mint +++ b/core/source/Unless.mint @@ -7,7 +7,7 @@ component Unless { property condition : Bool = true fun render : Array(Html) { - if (!condition) { + if !condition { children } else { [] diff --git a/core/source/Validation.mint b/core/source/Validation.mint index 4d349dea1..c5d1b8be1 100644 --- a/core/source/Validation.mint +++ b/core/source/Validation.mint @@ -73,7 +73,7 @@ module Validation { size : Number, error : Tuple(String, String) ) : Maybe(Tuple(String, String)) { - if (String.size(value) == size) { + if String.size(value) == size { Maybe::Nothing } else { Maybe::Just(error) @@ -95,7 +95,7 @@ module Validation { size : Number, error : Tuple(String, String) ) : Maybe(Tuple(String, String)) { - if (String.size(value) >= size) { + if String.size(value) >= size { Maybe::Nothing } else { Maybe::Just(error) @@ -110,7 +110,7 @@ module Validation { Maybe::Just({"name", "Name is empty!"}) */ fun isNotBlank (value : String, error : Tuple(String, String)) : Maybe(Tuple(String, String)) { - if (String.isNotBlank(value)) { + if String.isNotBlank(value) { Maybe::Nothing } else { Maybe::Just(error) @@ -124,7 +124,7 @@ module Validation { Maybe::Just({"age", "Age is not a number!"}) */ fun isNumber (value : String, error : Tuple(String, String)) : Maybe(Tuple(String, String)) { - case (Number.fromString(value)) { + case Number.fromString(value) { Maybe::Just => Maybe::Nothing => Maybe::Just(error) } @@ -140,7 +140,7 @@ module Validation { Maybe::Just({"confirmation", "Confirmation is not the same!"}) */ fun isSame (value : a, value2 : a, error : Tuple(String, String)) : Maybe(Tuple(String, String)) { - if (value == value2) { + if value == value2 { Maybe::Nothing } else { Maybe::Just(error) @@ -156,7 +156,7 @@ module Validation { Maybe::Just({"email", "Email is not a valid email address!"}) */ fun isValidEmail (value : String, error : Tuple(String, String)) : Maybe(Tuple(String, String)) { - if (Regexp.match(EMAIL_REGEXP, value)) { + if Regexp.match(EMAIL_REGEXP, value) { Maybe::Nothing } else { Maybe::Just(error) @@ -181,7 +181,7 @@ module Validation { memo : Map(String, Array(String)), item : Maybe(Tuple(String, String)) ) : Map(String, Array(String)) { - case (item) { + case item { Maybe::Just(error) => { let {key, message} = diff --git a/core/tests/tests/Decoding.mint b/core/tests/tests/Decoding.mint index 9ea5a4bda..4d7b5687e 100644 --- a/core/tests/tests/Decoding.mint +++ b/core/tests/tests/Decoding.mint @@ -1,6 +1,6 @@ suite "Decode" { test "it decodes tuples" { - case (decode (encode {"A", 0, true}) as Tuple(String, Number, Bool)) { + case decode (encode {"A", 0, true}) as Tuple(String, Number, Bool) { Result::Ok(decoded) => {"A", 0, true} == decoded Result::Err => false } diff --git a/core/tests/tests/Dom.mint b/core/tests/tests/Dom.mint index 6b1052b94..d887166b9 100644 --- a/core/tests/tests/Dom.mint +++ b/core/tests/tests/Dom.mint @@ -103,7 +103,7 @@ component Test.Dom.Focus { } get display : String { - if (shown) { + if shown { "inline-block" } else { "none" diff --git a/core/tests/tests/Http.mint b/core/tests/tests/Http.mint index f8a3ffa21..4b7cbfd08 100644 --- a/core/tests/tests/Http.mint +++ b/core/tests/tests/Http.mint @@ -284,11 +284,11 @@ component Test.Http { }) `) - await case (request) { + await case request { Result::Ok(response) => next { status: response.status } Result::Err(error) => - case (error.type) { + case error.type { Http.Error::NetworkError => next { diff --git a/core/tests/tests/Maybe.mint b/core/tests/tests/Maybe.mint index 1c33bac51..3ccbc40de 100644 --- a/core/tests/tests/Maybe.mint +++ b/core/tests/tests/Maybe.mint @@ -135,7 +135,7 @@ suite "Maybe.andThen" { (Maybe::Just(6) |> Maybe.andThen( (num : Number) : Maybe(String) { - if (num > 4) { + if num > 4 { Maybe::Just(Number.toString(num * num)) } else { Maybe::Nothing @@ -147,7 +147,7 @@ suite "Maybe.andThen" { (Maybe::Just(4) |> Maybe.andThen( (num : Number) : Maybe(String) { - if (num > 4) { + if num > 4 { Maybe::Just(Number.toString(num)) } else { Maybe::Nothing diff --git a/core/tests/tests/Provider/AnimationFrame.mint b/core/tests/tests/Provider/AnimationFrame.mint index 05de009c4..e657cc915 100644 --- a/core/tests/tests/Provider/AnimationFrame.mint +++ b/core/tests/tests/Provider/AnimationFrame.mint @@ -4,7 +4,7 @@ component Test.Provider.AnimationFrame { use Provider.AnimationFrame { frames: (timestamp : Number) : Promise(Void) { - if (timestamp > 0) { + if timestamp > 0 { next { frames: frames + 1 } } else { next { } diff --git a/core/tests/tests/Storage/Local.mint b/core/tests/tests/Storage/Local.mint index fe8203ec6..3672ffff4 100644 --- a/core/tests/tests/Storage/Local.mint +++ b/core/tests/tests/Storage/Local.mint @@ -7,7 +7,7 @@ suite "Storage.Local.set" { test "sets the given value at the given key" { Storage.Local.set("test", "test") - case (Storage.Local.get("test")) { + case Storage.Local.get("test") { Result::Ok(value) => value == "test" Result::Err => false } @@ -26,14 +26,14 @@ suite "Storage.Local.get" { test "it returns the value if exists" { Storage.Local.set("test", "test") - case (Storage.Local.get("test")) { + case Storage.Local.get("test") { Result::Ok(value) => value == "test" Result::Err => false } } test "it returns nothing if the key does not exists" { - case (Storage.Local.get("test")) { + case Storage.Local.get("test") { Result::Ok(value) => false Result::Err => true } diff --git a/core/tests/tests/Storage/Session.mint b/core/tests/tests/Storage/Session.mint index 31e5b313a..0a96dac36 100644 --- a/core/tests/tests/Storage/Session.mint +++ b/core/tests/tests/Storage/Session.mint @@ -35,7 +35,7 @@ suite "Storage.Session.get" { } test "it returns nothing if the key does not exists" { - case (Storage.Session.get("test")) { + case Storage.Session.get("test") { Result::Ok(value) => false Result::Err => true } diff --git a/core/tests/tests/Time.mint b/core/tests/tests/Time.mint index f9f0b7876..7388f7433 100644 --- a/core/tests/tests/Time.mint +++ b/core/tests/tests/Time.mint @@ -191,12 +191,12 @@ suite "Time.calendarWeek" { test "returns proper calendar week" { let expected = - for (item of TEST_DATA) { + for item of TEST_DATA { ({item[1][0], item[1][1]}) } let actual = - for (item of TEST_DATA) { + for item of TEST_DATA { Time.utcDate(item[0][0], item[0][1], item[0][2]) |> Time.calendarWeek } @@ -306,12 +306,12 @@ suite "Time.shift" { test "shifts the given time with the given span" { let expected = - for (item of TEST_DATA) { + for item of TEST_DATA { item[1] } let actual = - for (item of TEST_DATA) { + for item of TEST_DATA { Time.shift(BASE_TIME, item[0]) } diff --git a/core/tests/tests/Time/Format.mint b/core/tests/tests/Time/Format.mint index 2a07f5ce7..b822641b6 100644 --- a/core/tests/tests/Time/Format.mint +++ b/core/tests/tests/Time/Format.mint @@ -40,13 +40,13 @@ suite "Time.distanceOfTimeInWords" { Time.utc(2016, 1, 1, 12, 34, 50, 200) let expected = - for (item of TEST_DATA) { + for item of TEST_DATA { item[1] } |> String.join("\n") let actual = - for (item of TEST_DATA) { + for item of TEST_DATA { Time.distanceOfTimeInWords(Time.shift(now, item[0]), now, Time.Format:ENGLISH) } |> String.join("\n") @@ -83,13 +83,13 @@ suite "Time.format" { test "formats parts correctly" { let expected = - for (item of TEST_DATA) { + for item of TEST_DATA { item[2] } |> String.join("\n") let actual = - for (item of TEST_DATA) { + for item of TEST_DATA { Time.format(item[0], Time.Format:ENGLISH, item[1]) } |> String.join("\n") diff --git a/spec/formatters/array_destructuring b/spec/formatters/array_destructuring index d56f7d9df..512428b43 100644 --- a/spec/formatters/array_destructuring +++ b/spec/formatters/array_destructuring @@ -1,6 +1,6 @@ module Test { fun test : String { - case ([]) { + case [] { [a, b, ...rest] => "" => "" } @@ -9,7 +9,7 @@ module Test { -------------------------------------------------------------------------------- module Test { fun test : String { - case ([]) { + case [] { [a, b, ...rest] => "" => "" } diff --git a/spec/formatters/case b/spec/formatters/case index 5734a324e..45e2eee5b 100644 --- a/spec/formatters/case +++ b/spec/formatters/case @@ -6,7 +6,7 @@ module Test { -------------------------------------------------------------------------------- module Test { fun test : String { - case ("Hello") { + case "Hello" { "a" => "a" "b" => "b" => "others" diff --git a/spec/formatters/case_branch b/spec/formatters/case_branch index 4364f0190..875e8e6e8 100644 --- a/spec/formatters/case_branch +++ b/spec/formatters/case_branch @@ -10,7 +10,7 @@ module Test { -------------------------------------------------------------------------------- module Test { fun test : String { - case ("Hello") { + case "Hello" { /* Comment1 */ "singleline" => "single line content" diff --git a/spec/formatters/css_with_case b/spec/formatters/css_with_case index d77f77f8f..f32b501fc 100644 --- a/spec/formatters/css_with_case +++ b/spec/formatters/css_with_case @@ -16,7 +16,7 @@ component A { -------------------------------------------------------------------------------- component A { style test { - case (true) { + case true { false => background: red; color: blue; diff --git a/spec/formatters/css_with_if b/spec/formatters/css_with_if index b2a627349..b129e3b8c 100644 --- a/spec/formatters/css_with_if +++ b/spec/formatters/css_with_if @@ -12,7 +12,7 @@ component A { background: red; color: blue; - if (true) { + if true { color: yellow; } } diff --git a/spec/formatters/css_with_if_and_else b/spec/formatters/css_with_if_and_else index 35f7465c7..9271d1dd1 100644 --- a/spec/formatters/css_with_if_and_else +++ b/spec/formatters/css_with_if_and_else @@ -12,7 +12,7 @@ component A { background: red; color: blue; - if (true) { + if true { color: yellow; } else { color: brown; diff --git a/spec/formatters/enum_record b/spec/formatters/enum_record index 39d84afc5..81a684e8b 100644 --- a/spec/formatters/enum_record +++ b/spec/formatters/enum_record @@ -5,7 +5,7 @@ enum A { component Main { fun render : String { - case (A::B(name: "Joe", color: "Blue")) { + case A::B(name: "Joe", color: "Blue") { A::B(name, color) => "" A::C => "" } @@ -19,7 +19,7 @@ enum A { component Main { fun render : String { - case (A::B(name: "Joe", color: "Blue")) { + case A::B(name: "Joe", color: "Blue") { A::B(name, color) => "" A::C => "" } diff --git a/spec/formatters/for b/spec/formatters/for index 1a623bd56..51ad6c52b 100644 --- a/spec/formatters/for +++ b/spec/formatters/for @@ -6,7 +6,7 @@ component Main { -------------------------------------------------------------------------------- component Main { fun render : Array(String) { - for (item of ["B"]) { + for item of ["B"] { item } when { item == "A" diff --git a/spec/formatters/if_with_comments b/spec/formatters/if_with_comments index 93d81d64a..237faac94 100644 --- a/spec/formatters/if_with_comments +++ b/spec/formatters/if_with_comments @@ -8,7 +8,7 @@ module Test { module Test { fun test : Bool { // a single inline comment - if (true) { + if true { /* A */ true diff --git a/spec/formatters/if_with_else_if b/spec/formatters/if_with_else_if index e80102ad2..dbd76f60a 100644 --- a/spec/formatters/if_with_else_if +++ b/spec/formatters/if_with_else_if @@ -6,9 +6,9 @@ module Test { -------------------------------------------------------------------------------- module Test { fun test : Bool { - if (true) { + if true { true - } else if (false) { + } else if false { false } else { true diff --git a/spec/formatters/if_with_else_if_with_comment b/spec/formatters/if_with_else_if_with_comment index 35ccb61c7..e7a14d2ba 100644 --- a/spec/formatters/if_with_else_if_with_comment +++ b/spec/formatters/if_with_else_if_with_comment @@ -8,11 +8,11 @@ module Test { module Test { fun test : Bool { // a single inline comment - if (true) { + if true { true } else { /* COMMENT */ - if (false) { + if false { false } else { true diff --git a/spec/parsers/case_spec.cr b/spec/parsers/case_spec.cr index ea00b25b6..55443741b 100644 --- a/spec/parsers/case_spec.cr +++ b/spec/parsers/case_spec.cr @@ -7,8 +7,8 @@ describe "Case Expression" do expect_ignore "::" expect_ignore "asd" - expect_error "case", Mint::Parser::CaseExpectedOpeningParentheses - expect_error "case ", Mint::Parser::CaseExpectedOpeningParentheses + expect_error "case", Mint::Parser::CaseExpectedCondition + expect_error "case ", Mint::Parser::CaseExpectedCondition expect_error "case (", Mint::Parser::CaseExpectedCondition expect_error "case (a", Mint::Parser::CaseExpectedClosingParentheses expect_error "case (a)", Mint::Parser::CaseExpectedOpeningBracket diff --git a/spec/parsers/for_spec.cr b/spec/parsers/for_spec.cr index 86e4dbf15..f7f970ba0 100644 --- a/spec/parsers/for_spec.cr +++ b/spec/parsers/for_spec.cr @@ -7,7 +7,7 @@ describe "For Expression" do expect_ignore "::" expect_ignore "asd" - expect_error "for ", Mint::Parser::ForExpectedOpeningParentheses + expect_error "for ", Mint::Parser::ForExpectedOf expect_error "for (", Mint::Parser::ForExpectedOf expect_error "for (a", Mint::Parser::ForExpectedOf expect_error "for (a, b", Mint::Parser::ForExpectedOf diff --git a/spec/parsers/if_spec.cr b/spec/parsers/if_spec.cr index f8493d381..4ad0f97f2 100644 --- a/spec/parsers/if_spec.cr +++ b/spec/parsers/if_spec.cr @@ -7,8 +7,8 @@ describe "If Expression" do expect_ignore "::" expect_ignore "asd" - expect_error "if", Mint::Parser::IfExpectedOpeningParentheses - expect_error "if ", Mint::Parser::IfExpectedOpeningParentheses + expect_error "if", Mint::Parser::IfExpectedCondition + expect_error "if ", Mint::Parser::IfExpectedCondition expect_error "if (", Mint::Parser::IfExpectedCondition expect_error "if (a", Mint::Parser::IfExpectedClosingParentheses expect_error "if (a)", Mint::Parser::IfExpectedTruthyOpeningBracket diff --git a/src/formatters/case.cr b/src/formatters/case.cr index b4c29d10d..bcbabc201 100644 --- a/src/formatters/case.cr +++ b/src/formatters/case.cr @@ -13,7 +13,7 @@ module Mint await = "await " if node.await - "case (#{await}#{condition}) {\n#{indent(body)}\n}" + "case #{await}#{condition} {\n#{indent(body)}\n}" end end end diff --git a/src/formatters/for.cr b/src/formatters/for.cr index 4d6100344..ce8a6b96a 100644 --- a/src/formatters/for.cr +++ b/src/formatters/for.cr @@ -20,7 +20,7 @@ module Mint condition = format node.condition - "for (#{arguments} of #{subject}) #{body}#{condition}" + "for #{arguments} of #{subject} #{body}#{condition}" end end end diff --git a/src/formatters/if.cr b/src/formatters/if.cr index 4c7695603..b8749c52d 100644 --- a/src/formatters/if.cr +++ b/src/formatters/if.cr @@ -42,7 +42,7 @@ module Mint condition end - "if (#{condition}) #{truthy}#{falsy}" + "if #{condition} #{truthy}#{falsy}" end end end diff --git a/src/messages/case_expected_opening_parentheses.cr b/src/messages/case_expected_opening_parentheses.cr deleted file mode 100644 index 179b6417b..000000000 --- a/src/messages/case_expected_opening_parentheses.cr +++ /dev/null @@ -1,16 +0,0 @@ -message CaseExpectedOpeningParentheses do - title "Syntax Error" - - block do - text "I was looking for the " - bold "opening parenthesis " - code "(" - text " of a " - bold "case expression " - text "but found " - code got - text " instead." - end - - snippet node -end diff --git a/src/messages/for_expected_opening_parentheses.cr b/src/messages/for_expected_opening_parentheses.cr deleted file mode 100644 index ffda23607..000000000 --- a/src/messages/for_expected_opening_parentheses.cr +++ /dev/null @@ -1,16 +0,0 @@ -message ForExpectedOpeningParentheses do - title "Syntax Error" - - block do - text "I was looking for the " - bold "opening parenthesis " - code "(" - text "of a" - bold "for expression " - text "but found " - code got - text " instead." - end - - snippet node -end diff --git a/src/messages/if_expected_opening_parentheses.cr b/src/messages/if_expected_opening_parentheses.cr deleted file mode 100644 index 351081c96..000000000 --- a/src/messages/if_expected_opening_parentheses.cr +++ /dev/null @@ -1,15 +0,0 @@ -message IfExpectedOpeningParentheses do - title "Syntax Error" - - block do - text "The" - bold "condition" - text "of an" - bold "if expression" - text "must be enclosed by parenthesis." - end - - was_looking_for "opening parenthesis", got, "(" - - snippet node -end diff --git a/src/parsers/case.cr b/src/parsers/case.cr index c943d0f87..2914179e3 100644 --- a/src/parsers/case.cr +++ b/src/parsers/case.cr @@ -1,6 +1,5 @@ module Mint class Parser - syntax_error CaseExpectedOpeningParentheses syntax_error CaseExpectedClosingParentheses syntax_error CaseExpectedOpeningBracket syntax_error CaseExpectedClosingBracket @@ -13,7 +12,7 @@ module Mint whitespace - char '(', CaseExpectedOpeningParentheses + parens = char! '(' whitespace await = keyword "await" @@ -22,7 +21,7 @@ module Mint condition = expression! CaseExpectedCondition whitespace - char ')', CaseExpectedClosingParentheses + char ')', CaseExpectedClosingParentheses if parens body = block( opening_bracket: CaseExpectedOpeningBracket, diff --git a/src/parsers/for.cr b/src/parsers/for.cr index 52333d6bc..34ba64a49 100644 --- a/src/parsers/for.cr +++ b/src/parsers/for.cr @@ -1,6 +1,5 @@ module Mint class Parser - syntax_error ForExpectedOpeningParentheses syntax_error ForExpectedClosingParentheses syntax_error ForExpectedOpeningBracket syntax_error ForExpectedClosingBracket @@ -14,11 +13,11 @@ module Mint next unless whitespace? whitespace - char '(', ForExpectedOpeningParentheses + parens = char! '(' whitespace arguments = list( - terminator: ')', + terminator: parens ? ')' : '{', separator: ',' ) { variable } @@ -29,7 +28,7 @@ module Mint subject = expression! ForExpectedSubject whitespace - char ')', ForExpectedClosingParentheses + char ')', ForExpectedClosingParentheses if parens whitespace body = diff --git a/src/parsers/if.cr b/src/parsers/if.cr index 05a0cc0e3..2b867fe35 100644 --- a/src/parsers/if.cr +++ b/src/parsers/if.cr @@ -4,7 +4,6 @@ module Mint syntax_error IfExpectedTruthyClosingBracket syntax_error IfExpectedFalsyOpeningBracket syntax_error IfExpectedFalsyClosingBracket - syntax_error IfExpectedOpeningParentheses syntax_error IfExpectedClosingParentheses syntax_error IfExpectedTruthyExpression syntax_error IfExpectedFalsyExpression @@ -16,11 +15,11 @@ module Mint next unless keyword "if" whitespace - char '(', IfExpectedOpeningParentheses + parens = char! '(' whitespace condition = expression! IfExpectedCondition whitespace - char ')', IfExpectedClosingParentheses + char ')', IfExpectedClosingParentheses if parens whitespace truthy =