Skip to content

Instantly share code, notes, and snippets.

View thelissimus's full-sized avatar
🧑‍🍳
Cooking.

kei thelissimus

🧑‍🍳
Cooking.
View GitHub Profile
@thelissimus
thelissimus / Label.hs
Created April 12, 2025 01:07
Labeling traversables.
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE DerivingStrategies #-}
import Control.Monad.State
data Tree a = Node (Tree a) a (Tree a) | Leaf
deriving stock (Show, Functor, Foldable, Traversable)
data Rose a = Rose a [Rose a]
deriving stock (Show, Functor, Foldable, Traversable)
module Lib (module Lib) where
import Control.Monad (ap, (>=>))
----------------------------------------------------------------------------------------------------
data Coroutine i o a
= Await (i -> Coroutine i o a)
| Yield o (Coroutine i o a)
| Done a
@thelissimus
thelissimus / Utils.hs
Created February 10, 2025 23:20
brokkr-hashtables missing pieces
module Utils (module Utils) where
import Brokkr.HashTable qualified as HT
import Control.Monad
import Control.Monad.Primitive
import Data.Hashable (hashWithSalt)
instance HT.Hash ShortText where
module BoundedNat where
open import Data.Nat
open import Data.Nat.Properties
open import Data.Product
record BoundedNat (min max : ℕ) : Set where
constructor mk
field
val : ℕ
open import Function.Bundles
open import Data.Bool
open import Data.Product
open import Relation.Binary.PropositionalEquality
open Equivalence
fn : {a : Set} → (a × a) ⇔ (Bool → a)
fn .to (_ , snd) false = snd
fn .to (fst , _) true = fst
module MicroLens where
open import Function using (id; _∘_)
open import Data.Sum using (_⊎_) renaming (inj₁ to inl; inj₂ to inr)
record Profunctor (P : Set → Set → Set) : Set₁ where
field
dimap : ∀ {a' a b b'} → (a' → a) → (b → b') → P a b → P a' b'
lmap : ∀ {a' a b} → (a' → a) → P a b → P a' b
@thelissimus
thelissimus / HoTTestArend.ard
Created November 21, 2024 19:15
Some HoTT notes in Arend.
\import Logic
\import Paths
\data Circle
| base
| loop I \with {
| left => base
| right => base
}
@thelissimus
thelissimus / main.go
Created November 16, 2024 19:43
Vigenère Cipher exntended to support UTF, implemented in Go.
import (
"fmt"
"strings"
)
func cypher(str string, key string) string {
s, ix := new(strings.Builder), 0
for _, cs := range str {
s.WriteRune(cs + rune(key[ix%len(key)]))
ix++
@thelissimus
thelissimus / Bon.lean
Last active November 5, 2024 20:40
Bon language AST.
class Expr (F : Type → Type) where
bool : Bool → F Bool
not : F Bool → F Bool
and : F Bool → F Bool → F Bool
or : F Bool → F Bool → F Bool
int : Int → F Int
add : F Int → F Int → F Int
sub : F Int → F Int → F Int
@thelissimus
thelissimus / AbstractAlgebra.lean
Created October 28, 2024 18:42
Definition of Group, Abelian Group, Ring and Homomorphisms for them.
universe u
class Group (G : Type u) extends Add G where
inv : G → G
e : G
add_assoc : ∀ a b c : G, (a + b) + c = a + (b + c)
add_left_inv : ∀ a : G, (inv a) + a = e
add_right_inv : ∀ a : G, a + (inv a) = e
add_left_id : ∀ a : G, e + a = a