Skip to content

Instantly share code, notes, and snippets.

@li-vu
li-vu / phantom.fs
Created October 6, 2019 19:29 — forked from davidglassborow/phantom.fs
Use of phantom types for static validation of list length
// Phantom types - http://web.archive.org/web/20100615031841/http://blog.matthewdoig.com/?p=138
// Rather than DUs, just use simple marker interfaces
type Zero = interface end
type Succ<'length> = interface end
type Phantom<'a,'length> = Phantom of 'a list
let toList (Phantom l) = l
let nil = Phantom [] : Phantom<_,Zero>
from pyparsing import *
# By default, PyParsing treats \n as whitespace and ignores it
# In our grammer, \n is significant, so tell PyParsing not to ignore it
ParserElement.setDefaultWhitespaceChars(" \t")
def parse(input_string):
def convert_prop_to_dict(tokens):
"""Convert a list of field property tokens to a dict"""
prop_dict = {}