From 6b457ae132d7f7d31d98a741ea7f35d8e848331f Mon Sep 17 00:00:00 2001 From: gregorbednov Date: Sat, 20 Jun 2026 13:26:45 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell.nix | 16 ++++++++++------ tern.py | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 tern.py diff --git a/shell.nix b/shell.nix index 95591a5..e2f91bd 100644 --- a/shell.nix +++ b/shell.nix @@ -2,13 +2,17 @@ pkgs.mkShell { packages = [ - (pkgs.python3.withPackages (pythonPackages: [ - pythonPackages.simpy - pythonPackages.prompt-toolkit + # Python + third-party deps + (pkgs.python313.withPackages (ps: [ + ps.simpy + ps.prompt-toolkit ])) - pkgs.basedpyright - pkgs.codex-acp - pkgs.clang + # Frontend toolchain + pkgs.nodejs_22 ]; + + shellHook = '' + echo "simpy-terns: python $(python --version 2>&1 | cut -d' ' -f2), node $(node --version)" + ''; } diff --git a/tern.py b/tern.py new file mode 100644 index 0000000..af2a1ba --- /dev/null +++ b/tern.py @@ -0,0 +1,26 @@ +from enum import Enum +from typing import override + + +class Tern(Enum): + N = -1 + U = 0 + Y = 1 + + @override + def __str__(self): + if self.value == -1: + return "0" + if self.value == 1: + return "1" + return "N" + + @classmethod + def from_string(cls, s: str) -> "Tern": + if s == "N": + return Tern.U + if s == "0": + return Tern.N + if s == "1": + return Tern.Y + return cls[s]