Skip to content

Instantly share code, notes, and snippets.

View rampion's full-sized avatar

Noah Luck Easterly rampion

  • Mercury Technologies
View GitHub Profile
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wall -Werror -Wextra #-}
module Hyperfunction where
import Control.Category
import Data.Function (fix)
import Prelude hiding (id, (.))
extern crate structopt;
use clap::ArgGroup;
use structopt::StructOpt;
#[derive(Debug, StructOpt, PartialEq)]
#[structopt(group(ArgGroup::with_name("confs").multiple(true)))]
pub struct Command {
#[structopt(long = "config", group = "confs", parse(from_str = config))]
configs: Vec<Conf>,
@rampion
rampion / monad.rs
Created December 8, 2020 19:23
An implementation of the Functor/Applicative/Monad trait family using carrier types.
#![allow(incomplete_features)]
#![feature(generic_associated_types)]
use std::marker::PhantomData;
macro_rules! do_notation {
(| $ty:ty | pure $e:expr) => {
<$ty>::pure($e)
};
(| $ty:ty | $e:expr) => {
$e
@rampion
rampion / SortAsReverse.hs
Created December 5, 2020 16:15
"Implement the reverse function using the sort function" from https://bindthegap.news/issues/BindTheGap-01Nov2020.pdf
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module SortAsReverse where
-- challenge from bindthegap.news issue 1, Nov 2020
--
-- implement reverse using sort
import Data.Coerce (coerce)
{-# OPTIONS_GHC -Wno-name-shadowing #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}

WHAT hey

what ho

  1. What's a recipe?
  2. What's a target?
  3. What's a rule?
  4. What's that `.PHONY` thing?
  5. What's that `.DEFAULT_GOAL` thing?
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
@rampion
rampion / LetsGetDangerous.md
Last active January 20, 2020 05:02
Let's Get Dangerous
@rampion
rampion / Money.hs
Last active January 16, 2020 10:35
Showing how to generalize PMoney and SMoney using dependent types and singletons, follow up to https://twitter.com/alexnixon_uk/status/1217446321348661248?s=20
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}
@rampion
rampion / README.md
Last active November 15, 2023 04:10

What is the type of \f x -> f (f x)?