Skip to content

Instantly share code, notes, and snippets.

View tonymorris's full-sized avatar

Tony Morris tonymorris

View GitHub Profile
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeFamilies #-}
-- If there were an opportunity to fix the IsList type-class...
import Control.Lens
import Data.List.NonEmpty hiding (fromList)
class FromList l f | l -> f where
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE DefaultSignatures #-}
-- A better One type-class than Relude.Container.One
import Control.Applicative
import Control.Lens
data LSystem a b =
LSystem
[a]
(a -> [b])
type LSystem' a =
LSystem a a
instance Functor (LSystem a) where
fmap k (LSystem a f) =
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
@tonymorris
tonymorris / c172.md
Last active July 24, 2025 21:28
Cessna 172 Documentation
import Data.Bool
filter' ::
(a -> Either b c)
-> [a]
-> ([b], [c])
filter' _ [] =
([], [])
filter' f (a:as) =
let (bs, cs) = filter' f as

VH-RMV W&B

Parameters

  • Fuel: 188L (full)
  • Baggage: 45.4kg (maximum)
  • Tony: 80kg
  • Juliana: 70kg

Limits

{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
-- ghci -package lens -package tagged LeftLike.hs
import Control.Lens
import Data.Maybe
;; Pure functional I/O using clojure
;; =================================
;;
;; Defines a grammar of three operations in `defrecord Operation` using the free monad technique
;; 1. read file
;; 2. write file
;; 3. print to standard output
;;
;; Defines I/O operations by combining the Operation grammar in `defrecord IO`
;;
@tonymorris
tonymorris / ReaderWriterStateT.scala
Created April 11, 2012 16:59
Reader/Writer/State transformer in Scala
case class ReaderWriterStateT[R, W, S, F[_], A](
run: (R, S) => F[(W, A, S)]
) {
def map[B](f: A => B)(implicit F: Functor[F])
: ReaderWriterStateT[R, W, S, F, B] =
ReaderWriterStateT {
case (r, s) => F.map(run(r, s)) {
case (w, a, s) => (w, f(a), s)
}
}