Skip to content

Instantly share code, notes, and snippets.

View enlambdment's full-sized avatar

jpiedra enlambdment

View GitHub Profile
@enlambdment
enlambdment / johnston.txt
Created May 4, 2025 20:10
Tuning file for use in MuseScore 3 with euwbah/musescore-xen-tuner plugin
// Johnston notation tuning file for just intonation
// Accidentals for the 3-, 5-, 7- and 11-limit commas included
// 1. Reference note
C4: 440 * 3/5
// 2. Nominals - in Johnston system these are tuned
// according to the Ptolemy tense diatonic scale
1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1
@enlambdment
enlambdment / UsingEuterpeaWithHaskellStack.md
Last active December 20, 2021 19:51
Using Euterpea with Haskell `stack`: workaround for Euterpea.cabal version bounds

Euterpea is a Haskell library for computer music (in terms of musical structures as well as lower-level audio signals.) The current instructions for the official project site specify how to carry out an installation using the build tool cabal, but you can also set up a stack project to work with Euterpea as an external dependency as well. Here's how I've been able to work with Euterpea in stack projects so far:

  1. Create a stack project directory (here, I'll call mine example and use the simple template):
$ stack new example simple
$ cd example
  1. I'd like to use Euterpea, so I'll add it to the build-depends section in my .cabal file:
@enlambdment
enlambdment / ipv4.hs
Created October 18, 2020 22:35
compare two different ways to parse the 8-bit fields in an IPv4 address
module IPv4 where
import Control.Applicative ((<|>))
import Control.Monad.Combinators (count')
-- count' :: MonadPlus m => Int -> Int -> m a -> m [a]
-- count' m n p parses from m to n occurrences of p.
-- If n is not positive or m > n, the parser equals to return [].
-- Returns a list of parsed values.
import Data.Word (Word8, Word32)
import Text.Trifecta
module Main where
import Text.Trifecta
import Control.Applicative ((<|>))
p1, p12, p123 :: Parser String
p1 = string "1"
p12 = string "12"
p123 = string "123"
@enlambdment
enlambdment / Lib.hs
Created July 9, 2020 19:04
'sequenceL . makeListIOVerts' is producing random walks with vertices not always accessible from their prior vertex
module Lib where
import Euterpea
import Data.Graph
import Data.Array
import System.Random
import System.IO.Unsafe (unsafeInterleaveIO, unsafePerformIO)
import Control.Monad (liftM2, join)
import Control.Applicative (liftA2)
@enlambdment
enlambdment / filtering.hs
Created June 16, 2020 16:33
'filtering' implementation for Applicative exercises in fp-course
-- | Filter a list with a predicate that produces an effect.
--
-- >>> filtering (ExactlyOne . even) (4 :. 5 :. 6 :. Nil)
-- ExactlyOne [4,6]
--
-- >>> filtering (\a -> if a > 13 then Empty else Full (a <= 7)) (4 :. 5 :. 6 :. Nil)
-- Full [4,5,6]
--
-- >>> filtering (\a -> if a > 13 then Empty else Full (a <= 7)) (4 :. 5 :. 6 :. 7 :. 8 :. 9 :. Nil)
-- Full [4,5,6,7]
@enlambdment
enlambdment / graphRandomWalkAttempt.hs
Last active April 28, 2020 18:36
attempting to implement a random walk through a Graph (~ Array Vertex [Vertex]) in Haskell
import Data.Graph
import Data.Array
import System.Random
import Control.Monad ( liftM2 )
-- Given a graph gr :: Graph ~ Array Vertex [Vertex]
-- and a vertex v :: Vertex
-- use System.Random, Data.Array functionality to specify
-- a random walk (possibly non-terminating) within the graph.