This file contains 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 typing as t | |
from dataclasses import dataclass | |
Tp: t.TypeAlias = """ | |
( | |
Struct | |
| Unknown | |
| Int | |
| Str | |
) |
This file contains 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
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}") |
This file contains 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
from dataclasses import dataclass | |
from typing import ( | |
Self, | |
Callable, | |
Sequence, | |
TypeAlias, | |
TypeVar, | |
Protocol, | |
Any, | |
) |
This file contains 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
"""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 |
This file contains 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
from typing import ( | |
Generic, | |
TypeVar, | |
Protocol, | |
Any, | |
Type, | |
NewType, | |
) | |
T = TypeVar("T") |
This file contains 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
trait Lam<X> { | |
type Result; | |
} | |
struct True0; | |
struct True1<X>(X); | |
struct False0; | |
struct False1<X>(X); |
This file contains 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
trait Nat { | |
type Succ; | |
const NUMERIC: u64; | |
} | |
struct S<T>(T); | |
struct Z; | |
impl Nat for Z { |
This file contains 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 JsonParser where | |
import qualified Data.Map as M | |
import qualified Data.Bifunctor as Bi | |
import Data.Char ( ord | |
, chr | |
, isHexDigit | |
, isDigit | |
) |
This file contains 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 Number where | |
data Nat = S Nat | Z | |
deriving(Eq) | |
natIntoHaskellInt :: Nat -> Int | |
natIntoHaskellInt Z = 0 | |
natIntoHaskellInt (S v) = natIntoHaskellInt v + 1 | |
instance Show Nat where |
This file contains 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 LambdellCalculus where | |
import qualified Data.Bifunctor as Bi | |
data Term = ApplyT Term Term | |
| VarT Char | |
| FunT Char Term | |
deriving(Show, Eq) | |
isValidVar :: Char -> Bool |
NewerOlder