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 Parser<T> = (input: string) => [T, string] | (null | Error); | |
| function pure<O>(o: O): Parser<O> { return i => [o, i] } | |
| { | |
| // This should reconstruct a tuple type | |
| // (Is there a better way to do this? please?) | |
| // (See below, apparently there is ... kinda ...) | |
| type Reconstruct<Is extends Array<unknown>> = { | |
| [k in keyof Is & number]: Is[k] |
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
| // This is a monadic parser type, but we will just use it as a selective applicative | |
| type Parser<T> = (input: string) => [T, string] | (null | Error); | |
| // The first parser in a select will return a union like | |
| // `{ case: "1", value: T1 } | { case: "2", value: T2 }` | |
| type SelectCases<Cases extends Record<string, unknown>> = { | |
| [k in keyof Cases]: { case: k, value: Cases[k] } | |
| }[keyof Cases]; // squash it into a union type | |
| // The second arugment is a record of parsers to handle each case. |
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
| -- A parsing machine inspired by “Comonads as Spaces” by Phil Freeman | |
| -- (https://blog.functorial.com/posts/2016-08-07-Comonads-As-Spaces.html) | |
| {-# LANGUAGE ScopedTypeVariables, OverloadedStrings, DerivingVia, GeneralizedNewtypeDeriving, LambdaCase, BlockArguments, DataKinds #-} | |
| module ParseMachine where | |
| import Prelude hiding (filter, lex) | |
| import qualified Data.Map as Map | |
| import Control.Applicative (Alternative(..), asum) | |
| import Control.Monad (join, void) | |
| import Data.Function ((&)) |
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
| // Silly little syntax sugars :3 | |
| // _.name({name:"hello"}) == "hello" | |
| // mk.name("hello") == {name: "hello"} | |
| // _pipe.join(", ").length.line_(["do", "re", "mi"]) == 10 | |
| // Create a simple proxy for syntactic sugar for method names and function calls | |
| const sugar = (handler, applier=undefined) => new Proxy(applier ? ()=>{} : {}, { | |
| get: (_target, property, _thisArg) => { | |
| return handler(property); |
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
| #!/usr/bin/env python3 | |
| import subprocess | |
| from time import sleep | |
| import sys | |
| buggy = True | |
| file = "'" + sys.argv[1] + "'" | |
| p = subprocess.Popen(["fish" if buggy else "bash", "-c", "ffplay -nodisp -autoexit -hide_banner -loglevel error " + file]) |
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
| #!/usr/bin/env python3 | |
| import re | |
| import sys | |
| # install this dependency from pip: | |
| from wrapt import ObjectProxy | |
| class FormattableMatch(ObjectProxy): | |
| def __str__(self): | |
| m = self.__wrapped__ |
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
| module coefin.notarealagdafile where | |
| -- This would be great syntax, but I don't think we can make it all implicit | |
| ------------------------------ | |
| -- Number/Numeral nonsense: -- | |
| ------------------------------ | |
| -- `Fin` is an implicit coercion |
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
| # pseudo-assembly for a turing machine | |
| # tape layout for SAT problem in nvar variables with CNF of length len | |
| # (convenient to assume len >= nvar to make a single measure of complexity) | |
| # we will be deleting clauses as we go, but otherwise the tape stays constant | |
| # nvar variables, 3 bits each | |
| nvar * <notSIGIL=0><mut mark=0><value> | |
| # sigil separating variable table from CNF | |
| <SIGIL=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
| { | |
| "abc-parser@1.1.2": | |
| 300, | |
| "abc-parser@1.2.0": | |
| 537, | |
| "abc-parser@1.2.1": | |
| 513, | |
| "abc-parser@1.3.0": | |
| 398, | |
| "abc-parser@1.4.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
| module Metalanguage where | |
| import Prelude | |
| import Data.Array as Array | |
| import Data.Maybe (Maybe(..)) | |
| import Data.Traversable (sequence, traverse) | |
| data Value = ScalarValue String | VectorValue (Array Value) | |
| data Sization = NonEmpty | Any |
NewerOlder