Skip to content

Instantly share code, notes, and snippets.

View johnhaley81's full-sized avatar

John Haley johnhaley81

View GitHub Profile
[Error - 5:11:15 PM] Request textDocument/documentSymbol failed.
Error: Connection got disposed.
at Object.dispose (/Users/john/.vscode/extensions/ocamllabs.ocaml-platform-0.9.0/dist/index.js:26597:25)
at Object.dispose (/Users/john/.vscode/extensions/ocamllabs.ocaml-platform-0.9.0/dist/index.js:14916:35)
at LanguageClient.handleConnectionClosed (/Users/john/.vscode/extensions/ocamllabs.ocaml-platform-0.9.0/dist/index.js:17151:42)
at LanguageClient.handleConnectionClosed (/Users/john/.vscode/extensions/ocamllabs.ocaml-platform-0.9.0/dist/index.js:34239:15)
at closeHandler (/Users/john/.vscode/extensions/ocamllabs.ocaml-platform-0.9.0/dist/index.js:17138:18)
at CallbackList.invoke (/Users/john/.vscode/extensions/ocamllabs.ocaml-platform-0.9.0/dist/index.js:7965:39)
at Emitter.fire (/Users/john/.vscode/extensions/ocamllabs.ocaml-platform-0.9.0/dist/index.js:8024:36)
at closeHandler (/Users/john/.vscode/extensions/ocamllabs.ocaml-platform-0.9.0/dist/index.js:25933:26)
open Relude.Globals; // I usually do this in bsconfig
type user = {
firstName: string,
lastName: string,
};
type error =
| AlreadyLoggedIn;
type context = {
@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);
open Relude.Globals;
module ParseError = Decode.ParseError;
module Decode = {
let isValidDate: 'a => bool = [%raw
{|
function isValidDate(date) {
return date && Object.prototype.toString.call(date) === "[object Date]" && !isNaN(date);
}
@johnhaley81
johnhaley81 / Reselect.re
Created March 6, 2019 18:50
Reason bindings vs TypeScript types
type selector('state, 'result) = 'state => 'result;
[@bs.module "reselect"]
external createSelector1:
('state => 'a, 'a => 'result) => selector('state, 'result) =
"createSelector";
[@bs.module "reselect"]
external createSelector2:
('state => 'a, 'state => 'b, ('a, 'b) => 'result) =>
@johnhaley81
johnhaley81 / Decode_Result_Custom_test.re
Created November 26, 2018 21:44
Possible addition to tests for printing out custom errors
/* Snip */
test("Enum failure can be mapped to string", () => {
let message =
switch (Color.decode(jsonInvalidStr)) {
| Belt.Result.Ok(result) => result->Belt.Result.Ok
| Belt.Result.Error(parseError) =>
Decode_ParseError.toDebugString(
x =>
switch (x) {
| `InvalidColor => (_json => "Invalid color")
module Decode = {
type failure = [ DecodeBase.failure | `InvalidOption];
let failureToString = (v: failure, json) =>
(
switch (v) {
| `ExpectedBoolean => "Expected boolean"
| `ExpectedString => "Expected string"
| `ExpectedNumber => "Expected number"
| `ExpectedInt => "Expected int"
@johnhaley81
johnhaley81 / AxiosUtils.re
Created August 8, 2018 16:53
Example on wrapping a Reasonml binding to make a better API
open VowUtils.Infix;
module ErrorResponse = {
type t('a) = {
.
"config": Axios_types.config,
"response": {
.
"data": Js.Null.t(Js.Json.t),
"status": int,

Keybase proof

I hereby claim:

  • I am johnhaley81 on github.
  • I am johnhaley81 (https://keybase.io/johnhaley81) on keybase.
  • I have a public key ASB-ua8ysbm32WEPxuN7dMbQwXr8KuH_KkMo3TRsbwlr2Ao

To claim this, I am signing this object:

@johnhaley81
johnhaley81 / Person.hs
Created June 2, 2017 23:38
Spock and Yesod persisted types
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}