Skip to content

Instantly share code, notes, and snippets.

View friedbrice's full-sized avatar
🔵
You have unread notifications

Daniel P. Brice friedbrice

🔵
You have unread notifications
View GitHub Profile
-- This is some boilerplate code, don't worry about it.
{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
main = return ()
-- ** Start here for Interlude 1. **
-- I. Types
type Address = {
street: string
zipCode: string
}
type Contact = {
name: string
phoneNumber: string
email: string
}
{-# LANGUAGE DataKinds, KindSignatures, GADTs, TypeOperators #-}
module BlockMatrix where
import GHC.TypeLits
data Block (n :: Nat) (m :: Nat) a where
Number :: a -> Block 1 1 a
Fourths :: Block n1 m1 a -> Block n1 m2 a -> Block n2 m1 a -> Block n2 m2 a -> Block (n1 + n2) (m1 + m2) a
Vhalves :: Block n m1 a -> Block n m2 a -> Block n (m1 + m2) a
Hhalves :: Block n1 m a -> Block n2 m a -> Block (n1 + n2) m a
@friedbrice
friedbrice / Haskell (Cabal).sublime-syntax
Created July 28, 2020 16:42
Rudimentary Sublime Text Config for Haskell
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: Haskell (Cabal)
file_extensions:
- cabal
scope: source.cabal
variables:
ident: '[a-zA-Z\_][a-zA-Z\_\-0-9]*'
@friedbrice
friedbrice / MOVED.md
Last active July 27, 2020 06:02
Stack wrapper for single-file haskell programs.
@friedbrice
friedbrice / haskell-time.hs
Last active April 4, 2024 16:09
Haskell Time Crib Sheet
-- ghcid -c'stack repl --resolver nightly --package time' haskell-time.hs --allow-eval
----
-- # Haskell Time Crib Sheet
----
-- Excellent sources for this small guide include:
--
-- * https://two-wrongs.com/haskell-time-library-tutorial.html
-- * https://williamyaoh.com/posts/2019-09-16-time-cheatsheet.html
@friedbrice
friedbrice / queues.hs
Last active July 11, 2020 05:26
Threadsafe logging from a queue
import Control.Concurrent (forkIO, threadDelay)
import Control.Monad.STM (atomically)
import Data.Foldable (for_)
import System.Environment (lookupEnv)
import System.Random (randomRIO)
import Text.Read (readMaybe)
import qualified Control.Concurrent.STM.TBQueue as TBQ
@friedbrice
friedbrice / monadstate-example.hs
Last active April 4, 2024 16:57
MonadState Example
-- monadstate-example.hs
--
-- Load this program in GHCi:
--
-- stack repl \
-- --resolver nightly \
-- --package transformers \
-- --package mtl \
-- monadstate-example.hs
--
-- | A manifold is a locally-euclidean space.
--
-- Formally, a manifold is a set @x@, together with a set @d@ of /direction
-- vectors/ and a rule @'step' :: (Signed d, x) -> x@ defining how the
-- direction vectors can be used to move around short distances on the
-- manifold. Each manifold has a /dimension/, which is the cardinality of
-- its set of direction vectors.
--
-- Instances are expected to satisfy the following laws:
--
.PHONY: list
list: ## Show available targets.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##\s*\(.*\)/\n\t\1\n/'
.PHONY: clean
clean: ## Delete project-local Npm and Spago caches.
rm -rf .cache
rm -rf .psci_modules
rm -rf .spago
rm -rf dist