darklang / rescript-tea

The Elm Architecture for Rescript
Other
119 stars 9 forks source link

Add normal names for functions with "'" #11

Closed pbiggar closed 2 years ago

pbiggar commented 2 years ago

Some functions have an apostrophe in their name, because the function name was also an OCaml keyword. Rescript has different keywords, so we should go through the list of functions that has an apostrophe (such as class'), and add versions without the apostrophe.

OceanOak commented 2 years ago

view’

let view' = model => {
    open Tea_html2
    module A = Tea_html2.Attributes
    module E = Tea_html2.Events
    let (selected_index, selected_model, paused) = switch model.state {
    | Running => (0, List.hd(model.history) |> snd, false)
    | Paused(index) => (index, List.nth(model.history, index) |> snd, true)
    }

subscriptions'

let subscriptions' = model =>
    model.history |> List.hd |> snd |> subscriptions |> Tea_sub.map(client_msg)

shutdown'

let shutdown' = model => model.history |> List.hd |> snd |> shutdown |> Tea_cmd.map(client_msg)

  (init_debug, update', view', subscriptions', shutdown')

update'

let update' = (model, x) =>
    switch x {
    | ClientMsg(msg) =>
      if model.state == Running {
        let (_, cmodel) = List.hd(model.history)
        let (cmodel', cmd) = update(cmodel, msg)
        let dmodel' = {...model, history: list{(string_of_msg(msg), cmodel'), ...model.history}}
        (dmodel', cmd |> Tea_cmd.map(client_msg))
      } else {
        (model, Tea_cmd.none)
      }
    | TogglePaused =>
      switch model.state {
      | Paused(_) => ({...model, state: Running}, Tea_cmd.none)
      | Running => ({...model, state: Paused(0)}, Tea_cmd.none)
      }
    | SelectHistoryItem(i) => ({...model, state: Paused(i)}, Tea_cmd.none)
    | ToggleDetails => ({...model, show_details: !model.show_details}, Tea_cmd.none)
    }

tea_html.res

br’

let br' = (~key="", ~unique="", props, nodes) => fullnode("", "br", key, unique, props, nodes)

input’

let input' = (~key="", ~unique="", props, nodes) => fullnode("", "input", key, unique, props, nodes)

option’

let option' = (~key="", ~unique="", props, nodes) =>
  fullnode("", "option", key, unique, props, nodes)

object’

let object' = (~key="", ~unique="", props, nodes) =>
  fullnode("", "object", key, unique, props, nodes)

var’

let var' = (~key="", ~unique="", props, nodes) => fullnode("", "var", key, unique, props, nodes)

class’

let class' = name => prop("className", name)

type’

let type' = typ => prop("type", typ)

for’

let for' = str => prop("htmlFor", str)

method’

let method' = m => prop("method", m)

tea_html2.res

Same as tea_html

tea_svg_attributes.res

begin’

let begin' = v => attribute("", "begin", v)

class’

let class' = v => attribute("", "class", v)

end’

let end' = v => attribute("", "end", v)

in’

let in' = v => attribute("", "in", v)

method’

let method' = v => attribute("", "method", v)

to’

let to' = v => attribute("", "to", v)

type’

let type' = v => attribute("", "type", v)

tea_svg.res

text’

let text' = (~key="", ~unique="", props, nodes) =>
  fullnode(svgNamespace, "text", key, unique, props, nodes)

switch’

let switch' = (~key="", ~unique="", props, nodes) =>
  fullnode(svgNamespace, "switch", key, unique, props, nodes)
pbiggar commented 2 years ago

Are any of them in a module where there is a function of the same name but without an apostrophe? They'll need to be kept.

Apart from those, I guess see what happens when you remove the apostrophe. If there's a syntax error, that's likely still a keyword and we'll have to to keep the current name.

pbiggar commented 2 years ago

Fixed in #16