Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Gabriella439 / gist:be7c8cfc536be91ef4f5
Last active August 29, 2015 14:19
Quick annah walkthrough
-- Example Annah programs and their reductions
-- I'll start with simple non-recursive data types so that you can get a feel for the syntax and then work up to recursive data
-- types followed by mutually recursive types
-- Example #1: Bool, the type
$ annah
type Bool
data True
data False
in Bool
import Numeric.AD
assert = print
eval = id
main = do
let a x = 2 * x^2 + 3
let b = eval a 1
assert (b == 5) -- Prints `True`
Gabriella439 / Main.purs
Last active March 31, 2018 14:43
Purescript Flare - Simon example
module Main where
import Data.Array ((..), reverse)
import Data.Int (toNumber)
import Flare (UI, radioGroup)
import Flare.Drawing (runFlareDrawing)
import Graphics.Drawing
import Graphics.Drawing.Font (font, sansSerif, bold)
import Math (cos, sin, pi)
import Prelude
Gabriella439 / tree.dhall
Created December 18, 2018 03:53
Merry Christmas!
let Prelude =
let repeat =
λ(t : Text)
→ λ(n : Natural)
→ Prelude.`Text`.concat (Prelude.`List`.replicate n Text t)
let spaces = repeat " "
Gabriella439 / increment.dhall
Created April 25, 2019 21:39
Example of non-trivial equivalence
{- If I remember correctly, one consequence of Gödel's second incompleteness
theorem is that extensional equivalence is not decidable in general for
any programming language that can encode Peano numerals.
The exact case that a programming language fails on may differ from language
to language (depending on how many tricks they add to try to detect
non-trivial equivalences). However, many of them will typically fail to
detect the equivalence between two ways to encode `increment` for Peano
Gabriella439 / take.dhall
Created July 1, 2019 02:42
Dhall implementation of `take`
{- This is a bit ugly and inefficient. See this thread for a discussion about
adding a `Natural/subtract` built-in to improve this:
let Natural/predecessor : Natural → Natural
= λ(n : Natural)
→ let result = Natural/fold
(Optional Natural)
Gabriella439 / foreach.dhall
Created August 9, 2019 22:55
Example of how the equivalent of `foreach` in Dhall is ``
let Prelude =
let FN = Natural/even
let a = 2
let b = 3
let c = 5
Gabriella439 / Main.hs
Created December 5, 2019 03:54
Simple Twitter chat bot
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
import Data.ByteString (ByteString)
import Data.Default.Class (Default(..))
import GHC.Generics (Generic)
import Network.Connection (ConnectionParams(..))
import Options.Generic (ParseRecord)
Gabriella439 /
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

Gabriella439 / api-design.txt
Last active April 12, 2020 13:20
API design notes
* Importance of category theory
* Answers the question: "What is a *timeless* API?"
* What does "timeless" mean?
* Likely to still be relevant years from now
* Likely to be low maintenance (since unlikely to change)
* Less likely to be subject to controversy or discussion ("obvious")
* Examples:
* Everything Haskell's typeclassopedia (except maybe `Foldable`)
* Categories / Monoids
* `(.)` / `id`