Skip to content

Instantly share code, notes, and snippets.


Michael Martin-Smucker mlms13

Block or report user

Report or block mlms13

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
open Typeclasses;
// a binary search tree is a binary tree that holds order-able members and
// keeps lesser values on the left and greater or equal values on the right
module Make = (Order: Ord) => {
type t =
| Empty
| Node(t, Order.t, t);
// O(log n) operation to add a new value in a valid position in the tree
mlms13 /
Created Apr 9, 2019
Different approaches to representing elements pulled out from the natural flow (menus, tooltips, etc)
let onClick = _ => send(ToggleMenu);
// The following is how elm-ui does it (translated to JSX)
// Pros:
// - Relatively easy to understand
// - `Button` is any normal component
// - It's obvious that the container element can have all of the normal
// layout props and decoration attributes
// Cons:
mlms13 /
Created Apr 9, 2019
I don't know anything about PPXs, and I'm not even quite a do-notation pro, but I'd really like something like this in Reason
[%do Future]
do {
user <- getUser("some_user_id")
orders = user.orders
firstOrderId <- orders |> List.head |> Future.fromOption
order <- getOrder(firstOrderId)
pure(user.firstName ++ " ordered a " ++ order.productName)
mlms13 /
Created Mar 28, 2019
Evaluate rules using other rules?
// I'm not entirely sure what this thing is. It feels powerful and expressive
// and like you can compose things. Not sure what it would be useful for, though.
// Maybe you could make a UI to build arbitrarily complex predicate functions
// for filtering collections of data?
module RuleEngine = {
type t('a) =
| Rule('a)
| Not(t('a))
| And(t('a), t('a))
[@bs.module "react-native-calendario"]
external calendar: ReasonReact.reactClass = "default";
type dateRange = {
startDate: Js.Date.t,
endDate: option(Js.Date.t),
let dateRangeFromJS = range => {
startDate: range##startDate,

Current behavior

onfocus: send UpdateLocationSuggesion


  • if we already have geolocation: send UpdateLocationSuggesions
  • if we don't: send GetLocation


  • if mobile and empty input and LocationSuccess:
mlms13 /
Created Feb 24, 2019
t-first and t-last approach when working with nested data structures in Reason
* t-first and t-last examples when working with `Future.t(Result.t('a, 'e))`
// `Future` and `Result` are both t-last
|>, v => ShowData(v)))
|> Future.tap(send);
mlms13 /
Created Feb 21, 2019
Like TEA, but for a game loop?

The Elm Architecture, specialized for games.

Key points:

  • Instead of reacting to events, application state is updated on regular intervals
    • The engine collects all input events (keys up/down, mouse movement, button clicks, possibly joysticks, game pads)
    • User of this library specifies how to translate diffs in input events to game actions
  • Instead of a single "update" function, there are several specialized functions
    • physics update
      • given a current state (which should include things like position and velocity) and a time delta, provide a new state
mlms13 /
Last active Feb 15, 2019
Categorize Git Commits
module Git = {
type commitish = Sha(string);
type commit = {
title: string,
descriptiong: string,
author: string,
date: Date.t
mlms13 /
Created Feb 12, 2019
Dealing with async changes to state in ReasonReact
type state = {products: RemoteData.t(array(Product.t), string)};
type action =
| FetchProducts
| SetProducts(RemoteData.t(array(Product.t), string));
let component = ReasonReact.reducerComponent(__MODULE__);
let make = _children => {
initialState: () => {products: NotAsked},
You can’t perform that action at this time.