Skip to content

Instantly share code, notes, and snippets.

View dpwiz's full-sized avatar
👁️‍🗨️
🌈

Alexander Bondarenko dpwiz

👁️‍🗨️
🌈
View GitHub Profile
@VictorTaelin
VictorTaelin / implementing_fft.md
Last active April 30, 2024 05:32
Implementing complex numbers and FFT with just datatypes (no floats)

Implementing complex numbers and FFT with just datatypes (no floats)

In this article, I'll explain why implementing numbers with just algebraic datatypes is desirable. I'll then talk about common implementations of FFT (Fast Fourier Transform) and why they hide inherent inefficiencies. I'll then show how to implement integers and complex numbers with just algebraic datatypes, in a way that is extremely simple and elegant. I'll conclude by deriving a pure functional implementation of complex FFT with just datatypes, no floats.

This is an example of how using "fix" and open recursion lets us instrument
functions in a way reminiscent of aspect-oriented programming.
We are going to take an evaluator function for a simple expression language,
and augument it with an interactive debugger.
But first, the unavoidable dance of extensions and imports:
> {-# LANGUAGE ScopedTypeVariables #-}
> {-# LANGUAGE MultiWayIf #-}
@Kazark
Kazark / CurryHoward.lhs
Last active January 12, 2024 13:21
Curry-Howard Tutorial in Literate Haskell
This is a tutorial on the Curry-Howard correspondence, or the correspondence
between logic and type theory, written by Keith Pinson, who is still a learner
on this subject. If you find an error, please let me know.
This is a Bird-style literate Haskell file. Everything is a comment by default.
Lines of actual code start with `>`. I recommend that you view it in an editor
that understands such things (e.g. Emacs with `haskell-mode`). References will
also be made to Scala, for programmers less familiar with Haskell.
We will need to turn on some language extensions. This is not an essay on good
@snoyberg
snoyberg / Main.hs
Created April 1, 2020 08:54
Complete snapshot layer
#!/usr/bin/env stack
-- stack --resolver foo.yaml script
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
import Pantry
import RIO
import Path
import Path.IO
import Data.Yaml (encodeFile)
@Gabriella439
Gabriella439 / open-source-contributions.md
Created February 5, 2020 21:29
Notes for livestream on contributing to open source projects

These are my rough notes when preparing for a Haskell livestream that I thought would be worth sharing. Some things are general comments on contributing to the open source ecosystem whereas other notes are specific to the stream (e.g. Haskell and the streamly package)

How things look from a maintainer's point of view (for highly active projects):

  • Reactive

As projects become more active the maintainer's "inbox" gets pretty large. A

VERSION='9.4.1-rc1'
# Note: this ghc version requires stack 2.7.3 or newer to install correctly
cd /tmp
mkdir ghc-test && cd ghc-test
wget "https://raw.githubusercontent.com/DanBurton/stack-setup-info-gen/master/output/stack-ghc-$VERSION.yaml"
mv "stack-ghc-$VERSION.yaml" stack.yaml
stack setup
stack repl
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@xgrommx
xgrommx / HRecursionSchemes.hs
Last active December 9, 2021 07:30
HRecursionSchemes
{-# LANGUAGE StandaloneDeriving, DataKinds, PolyKinds, GADTs, RankNTypes, TypeOperators, FlexibleContexts, TypeFamilies, KindSignatures #-}
-- http://www.timphilipwilliams.com/posts/2013-01-16-fixing-gadts.html
module HRecursionSchemes where
import Control.Applicative
import Data.Functor.Identity
import Data.Functor.Const
import Text.PrettyPrint.Leijen hiding ((<>))
compiler: ghc-8.2.0.20170507
compiler-check: match-exact
resolver: lts-8.13
setup-info:
ghc:
linux64:
8.2.0.20170507:
url: https://downloads.haskell.org/~ghc/8.2.1-rc2/ghc-8.2.0.20170507-x86_64-deb8-linux.tar.xz
content-length: 141011788
sha1: ff886437c1d2ddfa5686d6c9efb0819a957c3dde
@puffnfresh
puffnfresh / chromebook-nix.sh
Last active October 28, 2020 03:06
Installation script for Nix on ChromeOS
#!/bin/sh
sudo mount -o remount,exec /tmp
if [ -x /usr/local/nixstrap/proot-x86_64 ] && [ -h ~/.nix-profile ]; then
echo "Launching shell with nix-* tools!"
exec /usr/local/nixstrap/proot-x86_64 -b /usr/local/nixstrap/nix-1.8-x86_64-linux:/nix bash --init-file ~/.nix-profile/etc/profile.d/nix.sh
fi
set -e