Skip to content

Instantly share code, notes, and snippets.

View nerodono's full-sized avatar
😒
У меня не отображается статус

Aleksandr nerodono

😒
У меня не отображается статус
View GitHub Profile
import dataclasses as dtc
@dtc.dataclass
class Ok:
ok: "Nigger"
@dtc.dataclass
class Err:
err: "Gay"
@nerodono
nerodono / compress.py
Created July 13, 2024 19:08
VienDesu! VNTools compressor implementation hint
import typing as t
import dataclasses as dtc
from functools import reduce
from pathlib import Path
class FileIsNotSupportedError(Exception):
def __init__(self, path: Path) -> None:
self.path = path
super().__init__(f"files of that kind are not supported by this compressor (path: {path})")
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running `nixos-help`).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
@nerodono
nerodono / typeck.py
Created May 18, 2024 12:42
Simplest typeck
import typing as t
from dataclasses import dataclass
Tp: t.TypeAlias = """
(
Struct
| Unknown
| Int
| Str
)
@nerodono
nerodono / Comb.py
Last active April 24, 2024 16:34
Another thing that I did on my phone (omg this was fucking suffering)
from functools import reduce as foldl
import string
import pprint
import builtins
class ParseFail(Exception):
...
def group_fails(message, *fails):
return ParseFail(f"{message}: {fails!r}")
@nerodono
nerodono / toython_tokenizer.py
Last active April 20, 2024 19:09
I wrote that on my phone because I was bored
from dataclasses import dataclass
from typing import (
Self,
Callable,
Sequence,
TypeAlias,
TypeVar,
Protocol,
Any,
)
"""Sole purpose of this thing - fix circular imports.
Consider, for example, message:
`slonogram.schemas.message.Message` depends on `slonogram.schemas.chat.Chat`
`Chat` also depends on `Message`, so that we got logically unsolvable circular imports problem.
This is the solution to it.
"""
from typing import Any, Iterable
from importlib import import_module
@nerodono
nerodono / mapper.py
Created February 8, 2024 22:00
Stupidly simple mapper
from typing import (
Generic,
TypeVar,
Protocol,
Any,
Type,
NewType,
)
T = TypeVar("T")
@nerodono
nerodono / lambda.rs
Created February 8, 2024 12:26
Lambda calculus on Rust types
trait Lam<X> {
type Result;
}
struct True0;
struct True1<X>(X);
struct False0;
struct False1<X>(X);
@nerodono
nerodono / nat-typefuck.rs
Created February 4, 2024 17:11
Silly natural numbers on types
trait Nat {
type Succ;
const NUMERIC: u64;
}
struct S<T>(T);
struct Z;
impl Nat for Z {