Skip to content

Instantly share code, notes, and snippets.

@girvo
girvo / Parser.fs
Created December 10, 2016 00:31 — forked from xavierzwirtz/Parser.fs
module Emly.Parser
open Emly.UntypedAST
open FParsec
open FParsec.CharParsers
open Emly.ParserUtils
open Emly.ParserUtils.IndentationParserWithoutBacktracking
let keywords =
Set.ofList ["let"; "fun"; "rec"; "impure"; "in"; "of"; "if"; "then"; "else"; "match"; "with"; "type"; "foreign"; "mutable"]
@girvo
girvo / utils.re
Created January 17, 2018 08:29
A small utility module I use with my ReasonML projects
module Result = {
type result('a, 'b) =
| Ok('a)
| Error('b);
let isOk = (result_) =>
switch result_ {
| Ok(_) => true
| Error(_) => false
};
let isError = (result_) =>
@girvo
girvo / decoder-inference.js
Last active March 26, 2018 13:48
Flow type inference using the "decoders" library
// @flow
import { guard, object, string, number } from 'decoders'
import type { Decoder } from 'decoders'
// This is the type-level "function" that pulls the generic out of the decoder
type ExtractDecoderType = <T>(d: Decoder<T>) => T
// Now we define our run-time decoder, without defining the type first...
const person = object({
name: string,