Skip to content

Instantly share code, notes, and snippets.

Paul Chiusano pchiusano

Block or report user

Report or block pchiusano

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
pchiusano / monads.u
Created Aug 21, 2019
Converting between algebraic effects and monads
View monads.u
ability Monadic f where eval : f a -> a
type Monad f = Monad (forall a . a -> f a) (forall a b . f a -> (a -> f b) -> f b)
use Monad Monad
Monad.pure : Monad f -> a -> f a
Monad.pure m = case m of Monad pure _ -> pure
Monad.bind : Monad f -> f a -> (a -> f b) -> f b
pchiusano /
Last active Aug 19, 2019
Unison transcript files (RFC draft)

Unison transcript files

This is a Unison transcript file. It's used for creating typechecked documentation, test cases, and scripts.

It's just a markdown file that does some special interpretation of certain fenced code blocks. It can be passed to ucm as a command line argument. ucm will run through the file change events and commands in the file in order and output a new .md file with the responses to these inputs. It exits when it's done, so this can also be used for scripting.


pchiusano / list.u
Created Aug 5, 2019
Some list functions for Unison, scratch file log
View list.u
-- X filter
-- -- maybe some tests with List.all and List.any
-- intersperse
-- X head
-- X isEmpty
-- X tail
-- X init
-- X last
pchiusano / state.u
Created May 8, 2019
Abilities in Unison
View state.u
ability State s where
put : s ->{State s} ()
get : {State s} s
state : s -> Effect (State s) a -> a
state s eff = case eff of
{ State.get -> k } -> handle (state s) in k s
{ State.put snew -> k } -> handle (state snew) in k ()
{ a } -> a
pchiusano / .ctags
Last active Mar 24, 2018
The ultimate ctags regex for Scala
View .ctags
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*class[ \t]+([a-zA-Z0-9_]+)/\4/c,classes/
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*object[ \t]+([a-zA-Z0-9_]+)/\4/c,objects/
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*case class[ \t]+([a-zA-Z0-9_]+)/\4/c,case classes/
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*case object[ \t]+([a-zA-Z0-9_]+)/\4/c,case objects/
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*trait[ \t]+([a-zA-Z0-9_]+)/\4/t,traits/
--regex-scala=/^[ \t]*type[ \t]+([a-zA-Z0-9_]+)/\1/T,types/
--regex-scala=/^[ \t]*((@annotation.tailrec|@tailrec|@inline)[ \t]*)*((abstract|final|sealed|implicit|lazy|private|protected)[ \t]*)*def[ \t]+([a-zA-Z0-9_]+)/\5/m,methods/
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|la
pchiusano / Interpreters.scala
Created Sep 21, 2017
Code for Scala World 2017 talk on eliminating interpreter overhead via partial evaluation
View Interpreters.scala
package scalaworld.interpreters
This file shows a simple language, an interpreter, and two
partial evaluators for that language, along with a profiling suite.
trait Expr // denotes a Vector[Double] => Vector[Double]
object Expr {
pchiusano / QuickProfile.scala
Created Jun 13, 2017
Adaptive profiling for JVM, runs evaluation until runtime stabilizes
View QuickProfile.scala
object QuickProfile {
def timeit(label: String, threshold: Double = 0.05)(action: => Long): (String, Double) = {
var N = 16L
var i = 0
var startTime = System.nanoTime
var stopTime = System.nanoTime
var sample = 1e9
var K = 0L
var ok = true
pchiusano / Pull.hs
Last active May 23, 2017
Stream processing scoping primitives
View Pull.hs
data Free f r
= Pure r
| Fail Err
| Eval (f r)
| forall x . Bind (Free f x) (Either Err x -> Free f r)
type Pull f o r = Free (StreamF o) r
data StreamF o x where
pchiusano / fastcodec.scala
Created Apr 2, 2017
Fast binary encoding and decoding interfaces
View fastcodec.scala
package fastcodecs
import java.nio.{ByteBuffer, BufferUnderflowException}
abstract class Decoder[+A] {
* Read a value from the `ByteBuffer`, advancing the offset if successful.
* Result is stored in `result`, unboxed if possible.
* On failure, a `DecodingFailure` is thrown.
pchiusano / Streams.hs
Last active Feb 21, 2018
Another effectful stream representation
View Streams.hs
{-# Language ExistentialQuantification #-}
{-# Language GADTs #-}
{-# Language RankNTypes #-}
{-# Language ScopedTypeVariables #-}
import Control.Monad
import Control.Applicative
import Data.List hiding (uncons)
import Data.Time
You can’t perform that action at this time.