Skip to content

Instantly share code, notes, and snippets.

@LSLeary
LSLeary / 0-InlineFix.hs
Last active October 3, 2024 22:51
Unrolling recursive functions at static arguments using church numerals
{-# LANGUAGE BlockArguments #-}
module InlineFix (
Rec,
inlineFix,
Church, (|&), _0, _1, _2, _3, _4, _5, _6, _7, _8, _9,
) where
import GHC.Exts (inline)
import Data.Function (fix)
{-# LANGUAGE TemplateHaskellQuotes #-}
{-# LANGUAGE GADTs #-}
module Pat3 where
import qualified Language.Haskell.TH as TH (Code, Q,)
import qualified Language.Haskell.TH.Syntax as TH (Lift(..))
import Data.Functor.Identity
type Code = TH.Code TH.Q
@LSLeary
LSLeary / Rec.hs
Last active October 3, 2024 22:51
Almost obnoxious levels of duality in fixed-points.
{-# LANGUAGE QuantifiedConstraints, BlockArguments, LambdaCase #-}
module Rec where
import Data.Functor.Product (Product(..))
import Data.Functor.Sum (Sum(..))
import Data.Kind (Type, Constraint)
import Control.Arrow ((&&&), (|||))
cabal-version: 2.4
name: Squeeze
version: 0.1.0.0
author: Ignat Insarov
maintainer: [email protected]
library
hs-source-dirs: .
build-depends: base, distributive
default-language: Haskell2010
import qualified Data.Set as S
import Data.Set (Set)
import Data.Char (isLower)
import Data.Ord (comparing, Down (Down))
import Data.List (sortBy, subsequences, minimumBy, maximumBy)
import Control.Monad.Trans.Writer.CPS
import Data.Monoid
import Data.Foldable (traverse_)
wordFilter :: String -> Bool
@bitonic
bitonic / vectorized-atan2f.cpp
Last active August 9, 2024 12:54
Vectorized & branchless atan2f
// Copyright (c) 2021 Francesco Mazzoli <[email protected]>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
@phadej
phadej / Mokhov.agda
Created July 1, 2021 08:56
Mokhov is (at least) skew monoidal product, see https://arxiv.org/pdf/1201.4981.pdf
{-# OPTIONS --cubical --type-in-type #-}
module Mokhov where
open import Cubical.Foundations.Everything
open import Cubical.Data.Sum
open import Cubical.Data.Prod
open import Cubical.Data.Unit
record Mokhov (F : Set → Set) (G : Set → Set) (A : Set) : Set where
constructor mokhov
notacji C7+ używam jako skrótu Cmaj7 
  (a więc nie oznacza to C z podniesioną kwintą i septymą małą (C5+7), tylko C z septymą wielką) 
d7(f-c-d) oznacza, że tak można grać prawą rękę akordu d7
(D) oznacza, że można tu zagrać D lub nie zagrać
d0 to czterodźwięk D zmniejszony (D-F-Ab-Cb)
d07 to czterodźwięk D półzmniejszony (D-F-Ab-C)
E< to trójdźwięk E zwiększony
|| oznacza początek nowego taktu

dziękuję wszystkim oryginalnym autorom, krytykom, muzom

@munificent
munificent / generate.c
Last active September 15, 2024 03:16
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@hsyl20
hsyl20 / ghc_gitlab.user.js
Created January 14, 2019 16:16
Add some buttons to Gitlab instance of GHC
// ==UserScript==
// @name Gitlab discussion helper
// @version 1
// @grant none
// @description This script let you toggle all discussions in Gitlab
// @include https://gitlab.haskell.org/*
// @run-at document-idle
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// ==/UserScript==