This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 : ℕ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\import Logic | |
\import Paths | |
\data Circle | |
| base | |
| loop I \with { | |
| left => base | |
| right => base | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder