Skip to content

Instantly share code, notes, and snippets.

View joom's full-sized avatar

Joomy Korkut joom

View GitHub Profile
@joom
joom / tree.rs
Last active August 18, 2023 02:40
A Yew app to show a binary tree
use yew::{html, Component, Context, Html};
use gloo::console::{self};
use std::collections::VecDeque;
#[derive(Debug, Clone)]
pub struct Annot {
}
impl Default for Annot {
fn default() -> Annot { Annot { } }
export BASH_SILENCE_DEPRECATION_WARNING=1
# https://github.com/dotzero/iTerm-2-Peppermint
git_branch () {
if git rev-parse --git-dir >/dev/null 2>&1
then echo -e "" [ $(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')]
else
echo ""
fi
}
function git_color {
@joom
joom / DefaultKeyBinding.dict
Created February 16, 2021 15:14
put it in ~/Library/KeyBindings on Mac systems
{
"~P" = (insertText:, "Π");
"~s" = (insertText:, "ş");
"~S" = (insertText:, "Ş");
"~k" = (insertText:, "ı");
"~K" = (insertText:, "İ");
"~g" = (insertText:, "ğ");
"~G" = (insertText:, "Ğ");
"~l" = (insertText:, "λ");
"~L" = (insertText:, "Λ");
@joom
joom / matchConstructor.hs
Last active December 8, 2020 22:21
Find out if a value matches a certain constructor.
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
import Data.Data
import Unsafe.Coerce
type family Last (a :: *) :: * where
Last (b -> c) = Last c
Last d = d
full :: (Typeable a, Data (Last a)) => a -> Last a
full x = case typeRepArgs (typeOf x) of
@joom
joom / A.v
Created September 21, 2019 02:13
Coq extraction in separate modules
Inductive color := red | green | blue.
@joom
joom / Scott.hs
Last active February 27, 2019 13:19
Automatically going back and forth between a Haskell value and its Scott encoding, using Data and Typeable. For more explanation, look for my work on "Direct Reflection for Free!"
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE IncoherentInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}
module Scott where
@joom
joom / rockPaperScissors.hs
Last active December 11, 2018 10:51
Rock Paper Scissors in Haskell
import System.Random
data Move = Rock | Paper | Scissors deriving (Show, Eq, Enum)
instance Ord Move where
(<=) x y = x == y || (x,y) `elem` [(Rock,Paper),(Paper,Scissors),(Scissors,Rock)]
humanSelect :: IO Move
humanSelect = fmap (toEnum . read) getLine
@joom
joom / SimplyTypedLambdaCalculus.agda
Created May 10, 2016 23:52
Simply typed lambda calculus with extensions
module SimplyTypedLambdaCalculus where
open import Data.Bool
open import Data.Nat hiding (erase)
import Data.Unit
open import Data.Maybe
open import Data.Product
open import Data.Sum
open import Relation.Binary.PropositionalEquality hiding ([_])
open import Relation.Nullary
module Unquote
%access public export
||| An interface to recover things from their canonical representations
||| as reflected terms, i.e. to reify things.
|||
||| This interface is intended to be used during proof
||| automation and the construction of custom tactics.
|||
||| @ t the type to quote it from (typically `TT` or `Raw`)
%language ElabReflection
data SatisfyPairs : (a -> a -> Type) -> List a -> Type where
SatEmpty : SatisfyPairs p []
SatSingleton : SatisfyPairs p [x]
SatPair : p x y -> SatisfyPairs p (y :: ys) -> SatisfyPairs p (x :: y :: ys)
MonotonicallyIncreasingNat : List Nat -> Type
MonotonicallyIncreasingNat = SatisfyPairs LTE