Skip to content

Instantly share code, notes, and snippets.

View chiroptical's full-sized avatar

Barry Moore chiroptical

View GitHub Profile
@chiroptical
chiroptical / abilities.md
Last active October 30, 2020 02:34
A proposal for improving the Unison abilities documentation
title description
Abilities in Unison
Unison's type system tracks which functions can do I/O, and the same language feature, called _abilities_ can be used for many other things, too. This is a tutorial on abilities.

Abilities in Unison

Here are two functions in Unison. One performs I/O (it writes to the console) and so it has an interesting type we'll be explaining much more in this tutorial:

all_commands=(
run
run.file
run.pipe
transcript
version
help
-codebase
transcript.fork
)
@chiroptical
chiroptical / scratch.u
Last active October 11, 2020 02:35
Stack Ability in Unison
-- These are watchers, they run every time we reload this file in Unison repl
> Stack.run Stack.one
> Stack.run Stack.two
> Stack.run Stack.three
Stack.three : '{Stack List Nat} [Nat]
Stack.three = 'let
Stack.put 1
match Stack.pop with
None -> []
@chiroptical
chiroptical / InstallationNotes.md
Created August 19, 2020 01:56
Installing neovim with coc.nvim on Ubuntu 20.10 w/ haskell-language-server
  • Update the machine
sudo apt update
sudo apt upgrade
# reboot machine
  • Install prerequisites
@chiroptical
chiroptical / scratch.u
Last active July 23, 2020 13:39
Implement the Monoid ability in Unison
ability Semigroup m where
assoc : m -> m -> m
-- Without unique, Monoid and Ask have the same hash
unique ability Monoid m where
identity : m
use Semigroup assoc
use Monoid identity
@chiroptical
chiroptical / scratch.u
Created June 26, 2020 20:15
Update code from https://github.com/unisonweb/unison/issues/822 to unison version: devel/M1l-171-g8b57038d
ability State s where
Get : s
Put : s -> ()
runState : s -> Request (State s) a -> (s, a)
runState s = cases
{State.Get -> k} ->
handle k s with runState s
{State.Put s -> k} ->
handle !k with runState s
@chiroptical
chiroptical / scratch.u
Created June 26, 2020 02:05
Stream in Unison
Stream.sum : '{Stream Nat} () -> Nat
Stream.sum = Stream.foldLeft (+) 0
> Stream.sum '(Stream.range 0 10)
ability Stream e where
emit : e ->{Stream e} ()
Stream.range : Nat -> Nat ->{Stream Nat} ()
Stream.range n m =
@chiroptical
chiroptical / gist:53e8be9f3726db7d1a704e0eb4b1da6c
Created June 15, 2020 22:03
Installing OpenSoundscape Ubuntu 18.04 on t2.medium AWS instance
sudo apt update
sudo apt upgrade
sudo apt install python3.7 python3.7-venv python3.7-distutils python3.7-dev gcc g++ libsndfile1
sudo snap install ffmpeg # Get ffmpeg 4
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2
sudo update-alternatives --config python3 # Make sure 3.7 is selected
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
~/.poetry/bin/poetry config virtualenvs.in-project true
~/.poetry/bin/poetry install # If this fails because of pytorch, goto 11 else goto 12
@chiroptical
chiroptical / Example.ipynb
Created June 9, 2020 13:11
Example Audio API
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chiroptical
chiroptical / FindJust.hs
Last active May 8, 2020 20:17
Find first `Just` embedded in `[m (Maybe a)]`
{-# LANGUAGE LambdaCase #-}
module FindJust ( findJust ) where
import Control.Monad ( foldM )
findJust :: Monad m => [m (Maybe a)] -> m (Maybe a)
findJust = foldM (\acc x -> maybe x (pure . Just) acc) Nothing