Skip to content

Instantly share code, notes, and snippets.

View mlms13's full-sized avatar
⚗️

Michael Martin mlms13

⚗️
View GitHub Profile
module AsyncResult = Relude.AsyncResult;
module Effect = ReludeReact.Effect;
module IO = Relude.IO;
module Option = Relude.Option;
module Reducer = ReludeReact.Reducer;
let (toBusy, completeOk, completeError) =
AsyncResult.(toBusy, completeOk, completeError);
type state('a, 'e) = AsyncResult.t('a, 'e);
@laughinghan
laughinghan / Every possible TypeScript type.md
Last active March 31, 2024 04:40
Diagram of every possible TypeScript type

Hasse diagram of every possible TypeScript type

  • any: magic, ill-behaved type that acts like a combination of never (the proper [bottom type]) and unknown (the proper [top type])
    • Anything except never is assignable to any, and any is assignable to anything at all.
    • Identities: any & AnyTypeExpression = any, any | AnyTypeExpression = any
    • Key TypeScript feature that allows for [gradual typing].
  • unknown: proper, well-behaved [top type]
    • Anything at all is assignable to unknown. unknown is only assignable to itself (unknown) and any.
    • Identities: unknown & AnyTypeExpression = AnyTypeExpression, unknown | AnyTypeExpression = unknown
  • Prefer over any whenever possible. Anywhere in well-typed code you're tempted to use any, you probably want unknown.
@johnhaley81
johnhaley81 / EnvVars.re
Last active December 19, 2019 20:08
Some reasonml bindings for graphile worker
open Relude.Globals;
[@bs.module "dotenv"] external getEnvVars: unit => unit = "config";
let getEnvVars = () =>
getEnvVars()
|> (() => Node.Process.process##env)
|> (Js.Dict.map((. x) => x |> Json.Encode.string) >> Json.Encode.dict);
@yukims19
yukims19 / Reant.re
Last active July 2, 2020 08:40
ReasonConf Dojo
type style = ReactDOMRe.Style.t;
type element = React.element;
module Breadcrumb = {
[@bs.module "antd"] [@react.component]
external make:
(~ariaLabel: string=?, ~key: string=?, ~style: style=?, ~children: 'b) =>
element =
"Breadcrumb";
@mbilokonsky
mbilokonsky / thinking_like_a_function.md
Last active October 25, 2021 14:47
Thinking Like a Function

Thinking Like a Function

Part 1: What's a function?

As a software engineer, you probably think of a function as a unit of code that takes some arguments and returns some value, eg:

 function square(x) { 
   return x * x;
 }
@evancz
evancz / data-interchange.md
Last active April 29, 2024 16:53
Why do I have to write JSON decoders in Elm?

A vision for data interchange in Elm

How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?

These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.

Literature Review

By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.