Skip to content

Instantly share code, notes, and snippets.

View aztek's full-sized avatar

Evgenii Kotelnikov aztek

View GitHub Profile
@aztek
aztek / RomanNumerals.agda
Created April 6, 2014 14:09
Syntax of Roman numerals, checked on type level with Agda's dependent types and instance arguments
module RomanNumerals where
open import Data.List
open import Data.Unit using (⊤; tt)
open import Data.Empty using (⊥)
data Literal : Set where
𝐼 𝑉 𝑋 𝐿 𝐶 𝐷 𝑀 : Literal
infix 4 ones_
@aztek
aztek / InsertionSort.agda
Last active April 11, 2025 12:57
Insertion sort in Agda
open import Level
open import Data.List
open import Data.Sum
open import Relation.Binary
module InsertionSort {ℓ ℓ₁ ℓ₂} (totalOrder : TotalOrder ℓ ℓ₁ ℓ₂) where
open TotalOrder totalOrder renaming (Carrier to A)
open IsTotalOrder isTotalOrder renaming (trans to ≤-trans; total to _≤?_)
@aztek
aztek / NatIsInfinite.agda
Created November 23, 2014 10:46
A simple Agda proof that the set of naturals is infinite
open import Level using (_⊔_)
open import Function
open import Data.Fin using (Fin; zero; suc)
open import Data.Nat hiding (_⊔_)
open import Data.Nat.Properties
open import Data.Vec
open import Data.Product
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary.Core
@aztek
aztek / Quinedrome.hs
Created January 8, 2022 22:42
A Haskell quine that is also a palindrome
q="eurT=fmap const pure 'q' abs;eslaF=fmap const show q gcd;xam=fmap const pure '=' odd;denifednu=ip<>di;dns=eurT<>xam;tsf=dns<>eslaF;ip=pure$!tsf;di=fmap const pure q cos;ton=dna<$>unlines;dna=putStr`fmap`yna;yna=mappend<*>reverse;main=let erehw main=main in fmap const ton denifednu main"
eurT=fmap const pure 'q' abs;eslaF=fmap const show q gcd;xam=fmap const pure '=' odd;denifednu=ip<>di;dns=eurT<>xam;tsf=dns<>eslaF;ip=pure$!tsf;di=fmap const pure q cos;ton=dna<$>unlines;dna=putStr`fmap`yna;yna=mappend<*>reverse;main=let erehw main=main in fmap const ton denifednu main
niam undefined not tsnoc pamf ni niam=niam where tel=niam;esrever>*<dneppam=any;any`pamf`rtStup=and;senilnu>$<and=not;soc q erup tsnoc pamf=id;fst!$erup=pi;False><snd=fst;max><True=snd;id><pi=undefined;ddo '=' erup tsnoc pamf=max;dcg q wohs tsnoc pamf=False;sba 'q' erup tsnoc pamf=True
"niam undefined not tsnoc pamf ni niam=niam where tel=niam;esrever>*<dneppam=any;any`pamf`rtStup=and;senilnu>$<and=not;soc q erup tsnoc pamf=id;fst!$erup=pi;F