Skip to content

Instantly share code, notes, and snippets.

@Gabriella439
Gabriella439 / instructions.md
Last active June 22, 2023 19:33
How to reach me on Discord

My Discord handle is: gabriella439

{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Example where
import Data.Text (Text)
import GHC.Generics (Generic)
import Dhall (ToDhall)
import Dhall.Diff (Diff)
@Gabriella439
Gabriella439 / MaxiMin.hs
Created August 28, 2022 00:52
MaxiMin algorithm for one player versus uncertainty
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# OPTIONS_GHC -Wall #-}
module MaxiMin where
import Data.List.NonEmpty (NonEmpty(..))
import Data.MemoTrie (HasTrie(..))
@Gabriella439
Gabriella439 / Main.hs
Created August 18, 2022 00:39
Example async-exception-safe retry function
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Control.Concurrent (threadDelay)
import Control.Exception
retry :: Int -> IO a -> IO a
retry n io
@Gabriella439
Gabriella439 / typing.md
Last active February 4, 2023 21:15
Sketch of type inference without unification variables

The inference judgment is:

Γ ⊢ e ⇒ A ⊢ Δ

… where:

  • Γ (an input) is a context which is a map from variables to their types
  • e (an input) is an expression whose type we wish to infer
  • A (an output) is the inferred type
  • Δ (an output) is a context which is a map from variables to their types
@Gabriella439
Gabriella439 / free-will.md
Created June 29, 2022 05:13
Conversation with GPT-3 about free will

Hi, GPT-3. Do you have free will?

Yes, I do have free will.

Prove it.

I can choose to do whatever I want, within the bounds of my abilities.

I mean prove it to me.

@Gabriella439
Gabriella439 / Main.hs
Last active June 1, 2022 23:45
TODO list single-page application using GHCJS
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.JSString (JSString)
import GHCJS.Foreign.Callback (Callback)
import GHCJS.Types (JSVal)
import JavaScript.Array (JSArray)
@Gabriella439
Gabriella439 / incomeTax.ffg
Last active May 25, 2022 20:20
Income tax calculator
\input ->
let real/greaterThan = https://raw.githubusercontent.com/Gabriella439/grace/main/prelude/real/greaterThan.ffg
let toBracket
: List { "Tax rate": Real, "Lower bound": Real, "Minimum tax": Real }
-> { }
-> Real
-> Real
= \brackets -> \_ -> \income ->
@Gabriella439
Gabriella439 / soundness-violation.dhall
Last active April 1, 2022 19:06
Minimal reproduction for breaking Dhall's type system safety guarantees
-- This is a minimal reproducing example of a major escape hatch that
-- violate's Dhall type safety guarantees.
let -- The uninhabited type (isomorphic to `< >`, but this is more ergonomic to
-- use for this reproduction)
Void : Type = ∀(any : Type) → any
let -- We model type-level negation in the standard way as a function from a
-- given type to the uninhabited type. `Not a` is only inhabited if `a`
-- is uninhabited (i.e. isomorphic to `Void`)
@Gabriella439
Gabriella439 / HasCal.hs
Last active May 5, 2022 09:47
First steps towards modeling PlusCal as a Haskell eDSL
{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
module HasCal where
import Control.Applicative (Alternative(..), liftA2)