This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE RankNTypes #-} | |
| newtype Nat = Nat { unNat :: forall m. Monoid m => m -> m } | |
| instance Num Nat where | |
| Nat f + Nat g = Nat (\m -> f m <> g m) | |
| Nat f * Nat g = Nat (\m -> f (g m)) | |
| abs = id | |
| negate _ = error "negate @Nat" | |
| signum (Nat f) = if f [()] == [] then 0 else 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE RankNTypes #-} | |
| data List a = List (forall x. x -> (a -> List a -> x) -> x) | |
| instance Show a => Show (List a) where | |
| show = foldR "[]" (\a str -> show a ++ " :: " ++ str) | |
| instance Eq a => Eq (List a) where | |
| (List l1) == (List l2) = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Peeked<T> = { ready: true; value: T } | { ready: false }; | |
| class Peekable<T> implements IterableIterator<T> { | |
| private _peeked: Peeked<T> = { ready: false }; | |
| private _iter: Iterator<T>; | |
| constructor(iter: Iterable<T>) { | |
| this._iter = iter[Symbol.iterator](); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { delay } from "https://deno.land/std/async/delay.ts"; | |
| async function* messages(msg: string, timeout: number) { | |
| for (let i = 0; i < 100; ++i) { | |
| await delay(timeout); | |
| yield `${msg} ${i}`; | |
| } | |
| } | |
| async function* mergeStreams<T>(...streams: AsyncIterable<T>[]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use crate::ast::*; | |
| use crate::lexer; | |
| grammar; | |
| Comma<T>: Vec<T> = { | |
| <v:(<T> ",")*> <e: T?> => match e { | |
| None => v, | |
| Some(e) => { | |
| let mut v = v; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; instr 0 | |
| 1 3 7 7 | |
| 2 5 7 8 | |
| 2 7 7 7 | |
| 2 3 7 _ | |
| 1 0 0 0 | |
| 2 0 0 0 | |
| 2 0 0 0 | |
| 1 0 0 0 | |
| 1 0 1 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -----BEGIN PGP PUBLIC KEY BLOCK----- | |
| mQENBF3MelkBCAC2SlLs0Hw7KoRl8g9Ya2cYsXD87hLwdRD5xF5+38h1YKGNVc9Q | |
| 54a7GPvAg74qNn0eIxC5Hak31xeAoVaA1pMSrUxVAPaifz9pSr0zI+4QFkLHH2c1 | |
| N3WW3w6g+VRKwuX2p3vI1UaJZ0N1ls5kSOQUEwYHzktaJf8njXvo4+55CIx/gZIN | |
| 2QnVb4bQO5PBqSMi5Qlj10VL0mjh7sQFeOMwjKSVyTKlk54/Dq1Yi46j8BR9JQQb | |
| hh5sY2LKq3ORm6apg8H2Au16S/o6p4/cv1jAgVN3sxG25ftypLhYeZKXTt+lWte/ | |
| DJl8pKdhW8UbwOCiumveZuc7FJmuelVI07XzABEBAAG0MEzDumPDoXMgQ3LDrW9z | |
| dMOzaXIgTWVpZXIgPGNyb25va2lyYnlAZ21haWwuY29tPokBVAQTAQgAPhYhBJKB | |
| 0W/t2Kfme1QRcDubDum8Ie9cBQJdzHpZAhsDBQkDwmcABQsJCAcCBhUKCQgLAgQW |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 0000000000001119 <add>: | |
| 1119: 55 push rbp | |
| 111a: 48 89 e5 mov rbp,rsp | |
| 111d: 48 83 ec 10 sub rsp,0x10 | |
| 1121: 89 7d 00 mov DWORD PTR [rbp+0x0],edi | |
| 1124: 89 75 fc mov DWORD PTR [rbp-0x4],esi | |
| 1127: 8b 45 00 mov eax,DWORD PTR [rbp+0x0] | |
| 112a: 50 push rax | |
| 112b: 8b 45 fc mov eax,DWORD PTR [rbp-0x4] | |
| 112e: 50 push rax |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .globl add | |
| add: | |
| pushq %rbp | |
| movq %rsp, %rbp | |
| subq $16, %rsp | |
| movl %edi, 0(%rbp) | |
| movl %esi, -4(%rbp) | |
| movl 0(%rbp), %eax | |
| pushq %rax | |
| movl -4(%rbp), %eax |