Skip to content

Instantly share code, notes, and snippets.

View BartoszMilewski's full-sized avatar

Bartosz Milewski BartoszMilewski

View GitHub Profile
@BartoszMilewski
BartoszMilewski / Lens.idr
Created November 13, 2023 15:42
Profunctor lenses in Idris 2
module Lens
-- Concrete get/set lens
record Lens s t a b where
constructor MkLens
get : s -> a
set : s -> b -> t
unitLens : Lens a b a b
unitLens = MkLens id (\x => id)
@BartoszMilewski
BartoszMilewski / PolyLens.idr
Created November 11, 2023 12:16
Polynomial lens in Idris2
module Main
data Vect : Type -> Nat -> Type where
Nil : Vect a Z
(::) : (x: a) -> (xs : Vect a n) -> Vect a (S n)
data Tree : Type -> Nat -> Type where
Empty : Tree a Z
Leaf : a -> Tree a (S Z)
Node : Tree a k1 -> Tree a k2 -> Tree a (S (plus k1 k2))
@BartoszMilewski
BartoszMilewski / HVect.idr
Last active November 5, 2023 21:21
Neural Networks in Idris
module HVect
import Data.Vect
-- Heterogeneous vector
public export
data HVect : Vect n Type -> Type where
Nil : HVect Nil
(::) : h -> HVect t -> HVect (h :: t)
export
\[
\begin{tikzcd}
&C
\arrow[ld, "\pi_X"']
\arrow[rd, "\pi_Y"]
\\
P \langle X X \rangle
\arrow[dr, "{P \langle id, f \rangle}"']
&&P \langle Y, Y \rangle
\arrow[dl, "{P \langle f, id \rangle}"]
@BartoszMilewski
BartoszMilewski / cup-string.txt
Created June 17, 2021 23:00
Tikz string diagram illustrating the unit of adjunction
\begin{tikzpicture}
\def \xrightmost {2}
\def \xright {1}
\def \xmid {0}
\def \xleft {-\xright}
\def \xleftmost {-\xrightmost}
\def \ybot {0}
\def \ymid {1}