Instantly share code, notes, and snippets.

/* this works */
|> Js.String.split("=")
|. Js.log;
/* this works, too */
-> Js.log;
/* but this doesn't */

Claim: Difficulty with interop with JS when accepting nested object param from JS to Reason

Reasonml Ver: 3.3.2

  • No problem with taking parameters from JS and matching to any type contains optional with one depth

  • But it seems to lose values wrapped by option if you have more depth like below

from typing import List
from random import randint
from import Card
from .player import Me, Other
def bet(
me: Me,
bet_players: List[Other],

I wanted to make an npm module via ReasonML

  • a function need to accept objects
  • but couldn't find a way to convert an JS Object to a Reason Record (holds optional value)
// I wanted to have an npm module function like below
reasonFnExposedToJs({key1: 'blah', key2: undefined})

// and works fine with Reason side but generated argsFromJs looks like below
View ttl.jsx
const ttl = (strings, ...variables) => [strings, ...variables]
// or const ttl = (...args) => [...args]
// we are using as an example
const Adder = ({className, x, y}) => {
return (
<span className={className}> {x+y} </span>
View no-concurrency-promise.js
function printTo100(n) {
for (i in [...Array(100).keys()]){
return Promise.resolve()
# find a process using port 3000 via
sudo lsof -n -i :3000 | grep LISTEN
# export env vars from a file via
export $(cat .env | xargs)
# check the reachability of the website every 1 seconds
while true; do curl -I; sleep 1; done
# pipe stdout as one arg to another command
View example.js
const { hss, scene, storage, market } = require('hire-scene-stealer')
.domIndex(0) // you can skip if it's 0
.viewport(900, 700)
View Echo.elm
port module Echo exposing (..)
import Platform exposing (program, Program)
import Json.Decode
-- importing Json.Decode is necessary for now because of
---- MODEL ----
type alias Model =
{ crap : String }