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 file contains 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
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 #-} |
This file contains 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
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 |
This file contains 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
#!/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) |
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
This file contains 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
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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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 ((<>)) |
This file contains 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
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 |
This file contains 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
#!/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 |
NewerOlder