- 
                Notifications
    You must be signed in to change notification settings 
- Fork 109
Example use cases
        J. S. Choi edited this page Apr 14, 2025 
        ·
        2 revisions
      
    This was an out-of-date, old, unsorted, incomplete list of real-world use cases.
For more-up-to-date example use cases, see these sections in the proposal explainer:
Old content from 2021
[For context, see HISTORY.md.]
See the examples from the explainer.
// Before
if ( cache && localStorage.getItem(endpoint) ) {
  return m.prop( JSON.parse( localStorage.get(endpoint) ) )
}
// After
if ( cache && localStorage.getItem(endpoint) ) {
  return endpoint
      |> localStorage.get
      |> JSON.parse
      |> m.prop
}
// Alternatively
if ( cache && localStorage.getItem(endpoint) ) {
  return endpoint |> localStorage.get |> JSON.parse |> m.prop
}Easy to type & delete logging, assuming you have a friendly log function on hand.
function log (message) {
  return function (subject) {
    console.log(message, subject)
    return subject
  }
}
// Before
unify( env, constraints.map( c => t.substitute(subst, c) ) )
// After
constraints.map( c => t.substitute(subst, c) )
|> unify.papp(env)
// After, with debugging
constraints.map( c => t.substitute(subst, c) )
|> log("Constraints:")
|> unify.papp(env)// Before
return item[item.length-1] === '/'
  ? Array.flattenOneLevel(
      await crawlFolder(githubToken, course_name_id, Git.fileTreeUrl(course_name_id, item))
    )
  : { type: 'file', name: Path.basename(item), path: item }
// After
return item[item.length-1] === '/'
  ? Git.fileTreeUrl(course_name_id, item)
    |> url => crawlFolder(githubToken, course_name_id, url)
    |> await
    |> Array.flattenOneLevel
  : { type: 'file', name: Path.basename(item), path: item }// Before
let items = base64ToJSON(response.data.content)
items = Array.isArray(items) ? items : [items]
// After
const items = base64ToJSON(response.data.content)
              |> x => Array.isArray(x) ? x : [x]// Before:
return Event.create(
  Object.assign(attrs, { parent_id: parentId, status: 'draft' })
)
// After:
return Object.assign(attrs, { parent_id: parentId, status: 'draft' })
  |> Event.create