Skip to content

Instantly share code, notes, and snippets.

View mikesol's full-sized avatar
🎯
Focusing

Mike Solomon mikesol

🎯
Focusing
View GitHub Profile
@mikesol
mikesol / Main.purs
Last active September 21, 2021 17:06
The Blue Danube Waltz
module Main where
import Prelude
import Data.NonEmpty ((:|))
import Effect (Effect)
import Halogen.Storybook (Stories, runStorybook, proxy)
import Type.Proxy (Proxy(..))
import WAGS.Lib.Learn (buffers, component, using, usingc, play)
import WAGS.Lib.Learn.Duration (crochet, crochetRest, dottedMinim, minim, semibreve)
@mikesol
mikesol / Main.purs
Last active September 10, 2021 08:50
Generic to row
module Main where
import Prelude
import Data.Foldable (fold)
import Effect (Effect)
import TryPureScript (h1, h2, p, text, list, indent, link, render, code)
import Data.Generic.Rep (class Generic, Argument(..), Constructor(..), Product(..), from)
@mikesol
mikesol / Thunkable.purs
Created April 8, 2021 18:38
Thunkable monad
module WAGS.Control.Thunkable where
import Prelude
import Control.Alternative (class Alt, class Alternative, class Plus, alt, empty)
import Data.Traversable (class Foldable, class Traversable, foldMapDefaultR, sequence, traverseDefault)
import Data.Tuple (Tuple(..))
data Thunkable a
= Here a
@mikesol
mikesol / GenericFree.purs
Last active February 11, 2021 21:09
paluh's generic free with a few wildcards removed
module Test.RunCodegen where
import Prelude
import Control.Monad.Free (Free, liftF)
import Data.Functor.Variant (FProxy(..))
import Data.Generic.Rep (class Generic, Argument(..), Constructor(..), Product(..), Sum(..))
import Data.Generic.Rep (to) as Generics.Rep
import Data.Symbol (class IsSymbol)
import Prim.Row (class Cons, class Lacks) as Row
import Prim.Symbol (class Cons) as Symbol
@mikesol
mikesol / Bells.purs
Last active December 17, 2020 07:20
Bells on klank.dev
module Klank.Dev where
import Prelude
import Color (rgba)
import Control.Monad.Reader (Reader, ask, asks, runReader)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Int (toNumber)
import Data.List (List(..), catMaybes, fold, (:))
import Data.Maybe (Maybe(..), isJust)
@mikesol
mikesol / Forest.purs
Last active September 24, 2020 21:33
A forest sound with a drone underneath
module Klank.Dev where
-- new to purescript? check out https://www.purescript.org/ for learning resources!
import Prelude
import Data.List ((:), List(..))
import Data.NonEmpty ((:|))
import Data.Typelevel.Num (D1)
import FRP.Behavior (Behavior)
import FRP.Behavior.Audio (AudioUnit, gain', runInBrowser_, play, sinOsc, speaker)
import Math (pi, sin)
@mikesol
mikesol / Sine.purs
Last active September 24, 2020 21:25
PureScript Audio Behaviors Sine
module Klank.Dev where
-- new to purescript? check out https://www.purescript.org/ for learning resources!
import Prelude
import Data.Typelevel.Num (D1)
import FRP.Behavior (Behavior)
import FRP.Behavior.Audio (AudioUnit, gain', runInBrowser_, sinOsc, speaker')
scene :: Behavior Number -> Behavior (AudioUnit D1)
scene _ = pure (speaker' $ (gain' 0.5 $ sinOsc 440.0))
@mikesol
mikesol / audio-graph.js
Created September 16, 2020 04:51
Audio graph as linear program
{
binaries: [
"n@Add''_1_1",
"n@Gain''_2_2",
"n@Gain''_2_5",
"n@Gain''_6_2",
"n@Gain''_6_5",
"n@SinOsc''_3_3",
"n@SinOsc''_3_4",
"n@SinOsc''_3_6",
@mikesol
mikesol / sketch.dhall
Last active October 3, 2022 19:05
Yet another Dhall-API-protocol proposal
let fold = https://prelude.dhall-lang.org/List/fold
let filter = https://prelude.dhall-lang.org/List/filter
let equal = https://prelude.dhall-lang.org/Natural/equal
let Obj = <User | Pet | List>
let Key = <Id | Type | Name | Pets | Head | Tail>
let Entry = <Int_: Integer | Bool_: Bool | Double_: Double | Text_: Text | Id_: Natural | Type_: Obj | Nil>
let Row = { ptr: Natural, key: Key, val: Entry }
let Db = List Row
@mikesol
mikesol / Main.purs
Created August 16, 2020 16:05
Costar runtime error
module Main where
import Prelude
import Data.Lens (Iso, _1, _2, iso)
import Data.Profunctor (class Profunctor)
import Data.Profunctor.Costrong (class Costrong, unfirst, unsecond)
import Data.Profunctor.Strong (class Strong, first)
import Data.Tuple (Tuple(..), fst, snd)
import Effect (Effect)
import Effect.Console (log)