Skip to content

Instantly share code, notes, and snippets.

module R where
open import Agda.Builtin.FromNat
open import Data.Unit using (tt)
open import Data.Rational as ℚ
open import Data.Rational.Properties
open import Data.Rational.Literals as ℚ
open import Data.Nat as ℕ using (ℕ)
import Data.Nat.Properties as ℕ
import Data.Integer as ℤ
@Lysxia
Lysxia / DPoly.agda
Last active October 25, 2022 00:04
Directed polynomial as strict categories https://danel.ahman.ee/papers/msfp16.pdf
{-# OPTIONS --cubical #-}
module DPoly where
open import Cubical.Core.Everything
open import Cubical.Foundations.Structure
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Transport
open import Cubical.Foundations.HLevels
@Lysxia
Lysxia / Derecordify.hs
Created October 20, 2022 17:14
Deriving Read and Show for records as if they weren't records
{-# LANGUAGE DeriveGeneric, DerivingVia #-}
import GHC.Generics (Generic)
import Generic.Data
import Generic.Data.Microsurgery
data R = R {a :: Int, b :: Int}
deriving Generic
deriving (Read, Show) via Surgery Derecordify R
{-# LANGUAGE DataKinds, TypeFamilies, TypeOperators #-}
module D where
import Control.Applicative (liftA2)
import Data.Kind (Type)
data F = VALUE | F :-> F
infixr 1 :->
@Lysxia
Lysxia / mh.txt
Created September 22, 2022 10:45
Monoid homomorphisms
monoid homomorphism is_odd : Z -> B
Categorically, a monoid (Z, 1, (*)) is described by a pair of morphisms (const 1 : () -> Z) and (uncurry (*) : Z x Z -> Z).
A monoid homomorphism is_odd : Z -> B is a morphism which makes the following diagrams commute:
const 1
() ------------> Z
| |
id | | is_odd
| |
{-# LANGUAGE
ConstraintKinds,
FlexibleContexts,
FlexibleInstances,
MultiParamTypeClasses,
QuantifiedConstraints,
RankNTypes,
ScopedTypeVariables,
TypeApplications,
UndecidableInstances #-}
@Lysxia
Lysxia / GF.hs
Last active September 20, 2022 23:40
Incoherence in gsolomap
{-# LANGUAGE DeriveGeneric #-}
module Main where
import Generic.Functor
import GHC.Generics (Generic)
data T a b = C Int a b
deriving (Show, Generic)
fmapT :: (b -> b') -> T a b -> T a b'
@Lysxia
Lysxia / DG.hs
Last active September 20, 2022 21:53
Quantified constraint trick
{-# LANGUAGE
ConstraintKinds,
FlexibleContexts,
FlexibleInstances,
MultiParamTypeClasses,
QuantifiedConstraints,
RankNTypes,
ScopedTypeVariables,
TypeApplications,
UndecidableInstances #-}
@Lysxia
Lysxia / T.agda
Created September 12, 2022 19:01
Traversables as Graded functors
-- Traversables as Graded functors
-- Graded functors as functors that commute with grading
--
-- Graded endofunctors on KleisliApp are Traversables
--
-- Laws omitted.
module T where
open import Level
@Lysxia
Lysxia / F.hs
Created September 12, 2022 13:39
{-# LANGUAGE
DataKinds,
PolyKinds,
StandaloneKindSignatures,
TypeFamilies #-}
module F where
import Data.Void
import Data.Functor.Const
import Data.Kind (Type)