Skip to content

Instantly share code, notes, and snippets.

View bukzor's full-sized avatar
🌥️
learning google cloud

Buck Evan bukzor

🌥️
learning google cloud
  • google.com
  • Appleton, WI
  • 06:42 (UTC -05:00)
View GitHub Profile
@bukzor
bukzor / gist:21ea47b35ca6c4f36a211edc9b15be25
Created September 14, 2020 20:02
__file__ is always realpath?
$ cd "$(mktemp -d)"
$ ln -sf realpath symlink
$ mkdir realpath
$ cd symlink
$ touch foo.py

This kinda-sorta works:

$ cd share/Formality/

$ git diff
diff --git a/javascript/FormalityToJS.js b/javascript/FormalityToJS.js
index c2dc6a1..2089d39 100644
--- a/javascript/FormalityToJS.js
+++ b/javascript/FormalityToJS.js
@bukzor
bukzor / cat.fm
Last active August 17, 2020 05:25
cat.IO.readline<A: Type>(_: A): IO(String)
use line = IO.ask<String>("get_line", "")
IO.end<String>(line)
cat.go<A: Type>(io: IO(A)): IO(Unit)
get bind pure = IO.monad
let io1 = bind<,>(io, cat.IO.readline<>)
let io2 = bind<,>(io1, IO.print)
cat.go<>(io2)
@bukzor
bukzor / formality.md
Last active August 14, 2020 11:32
Figuring out type definitions in Formality lang. https://github.com/moonad/Formality

Type definition

T Color.
| Red.;
| Blue.;

Desugars to:

@bukzor
bukzor / .fm
Created August 9, 2020 22:18
The simple Formality proofs. https://github.com/moonad/Formality/
T False
T True
| true;
Not(A: Type): Type
A -> False
T Equal<A: Type> ~ (a: A, b: A)
| same<a: A> ~ (a, a);
$ cat head2.fm
head2.IO.readline(_: Unit): IO(String)
use line = IO.ask<String>("get_line", "")
IO.end<String>(line)
head2: IO(Unit)
get bind pure = IO.monad
let io0 = pure<>(Unit.new)
let io1 = bind<,>(io0, head2.IO.readline)
@bukzor
bukzor / example.log
Created August 3, 2020 01:27
"The.value" typeerror, but values seem to match.
$ cat example.fm
example.3.0 : _
pythonic.str.split("", "abc")
example.3.1 : _
["a", "b", "c"]
example.3.test: The(_, example.3.1)
The.value<>(example.3.0)
$ head head.fm
head.splitc(c: Char, xs: List(Char)): List(List(Char))
case xs:
| nil => List.nil<List(Char)>;
| cons => if U16.eql(xs.head, c)
then List.cons<>(c, head.splitc(c, xs.tail))
else head.splitc(c, xs.tail);
head.splitc_example3 : _
head.splitc('x', ['a', 'x', 'b'])
head.splitc_example3 : The(List(List(Char)), head.splitc('x', ['a', 'x', 'b']))
The.value<List(List(Char))>([['a'], ['b']])
Inside head.splitc_example3:
Found type... The(List(List(Char)),List.cons(List.cons('a',List.nil),List.cons(List.cons('b',List.nil),List.nil)))
Instead of... The(List(List(Char)),head.splitc('x',List.cons('a',List.cons('x',List.cons('b',List.nil)))))
On line 19:
18| head.splitc_example3 : The(List(List(Char)), head.splitc('x', ['a','x', 'b']))
19| The.value<List(List(Char))>([['a'], ['b']])
from __future__ import print_function
import contextlib
import pytest
# Introduce a Loud integer class that has some annoying properties that force us into a bunch of
# set up in our tests (in this case, to prevent unnecessary output to stdout during test)
class LoudInt(int):