Skip to content

Instantly share code, notes, and snippets.

View MonoidMusician's full-sized avatar

Verity Scheel MonoidMusician

View GitHub Profile
module Test.RowListMaps where
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
import Data.Maybe (fromJust)
import Data.StrMap as SM
import Data.Tuple (Tuple(..))
import Data.Variant (Variant, inj, SProxy(..))
import Global.Unsafe (unsafeStringify)
import Partial.Unsafe (unsafePartial)
@MonoidMusician
MonoidMusician / Main.purs
Last active August 19, 2017 21:58
VisualDottedRhythm
module Main where
import Prelude
import Color (Color, white, rgba')
import Color.Scheme.MaterialDesign (blueGrey, grey, pink, red, purple)
import Control.Monad.Eff (Eff)
import Control.MonadZero (guard)
import Data.Newtype
import Data.Array (sortBy, (..), fromFoldable)
@MonoidMusician
MonoidMusician / Main.purs
Created August 23, 2017 21:09
Generic.Rep.Sum to list
module Main where
import Prelude
import Type.Proxy (Proxy(..))
import Data.Generic.Rep
foreign import kind List
foreign import data Cons :: Type -> List -> List
foreign import data Nil :: List
@MonoidMusician
MonoidMusician / Main.purs
Last active September 1, 2017 21:20
mixst
module Main where
import Type.Prelude
import Type.Row
import Type.Data.Boolean
import Type.Data.Symbol as Symbol
import Data.Newtype
data RProxy (r :: # Type) = RProxy
data RLProxy (rl :: RowList) = RLProxy
@MonoidMusician
MonoidMusician / Main.purs
Created September 8, 2017 18:47
Alternative find
module Main where
import Prelude
import Control.Monad.Eff.Console (logShow)
import TryPureScript (render, withConsole)
import Control.Alternative (class Alternative)
import Control.Plus (class Plus)
import Control.Alt (class Alt)
import Data.Foldable (class Foldable, foldMap)
@MonoidMusician
MonoidMusician / Main.purs
Last active September 14, 2017 22:14 — forked from chexxor/Main.purs
SQL query row types
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (logShow, CONSOLE)
import Data.Foldable (class Foldable, foldl, intercalate)
import Data.Maybe (Maybe(..), maybe)
import Data.Monoid (class Monoid, mempty)
import Data.StrMap (StrMap, lookup)
@MonoidMusician
MonoidMusician / Main.purs
Last active January 10, 2018 01:57
Impredicativity woes
module Main where
import Prelude
import Data.Maybe (Maybe(..), fromMaybe)
import Unsafe.Coerce (unsafeCoerce)
type Id = forall a. a -> a
newtype ID = ID Id
mkID :: Id -> ID
@MonoidMusician
MonoidMusician / ericatillus.md
Last active December 14, 2020 05:25
Cognates are transitive, right?

Questionable etymological reconstruction of Haskell into Latin via the great Wiktionary (Victiōnārium).

Haskell

  1. An English patronymic surname derived from the Old Norse given name Áskell.
  2. A Jewish surname derived from the equivalent of English Ezekiel.

Let’s go with #1, because #2 seems unlikely (even Ezekiel isn’t very common), and finding a cognate would most likely result in a boring Greek/Hebrew borrowing of Ezekiel (all the rage during post-classical periods especially – hellloo Ecclesiastical Latin).

Fun fact: Haskell was never a common given name and it died off in the 1930s: http://www.babynamewizard.com/voyager#prefix=haskell&sw=both&exact=true

@MonoidMusician
MonoidMusician / Merging.purs
Created February 28, 2018 16:48
The best merge functions around!
module Merging where
import Type.Row (class ListToRow, class RowListNub, class RowToList)
{-
exports.unsafeMerge = function(r1) {
return function(r2) {
var r = {};
for (var k1 in r2) {
if ({}.hasOwnProperty.call(r2, k1)) {
@MonoidMusician
MonoidMusician / MapChangeReverse.purs
Last active March 22, 2018 16:09
Reversing incremental map changes
-- | A change for a single key is an addition, removal, or update.
data MapChange v dv
= Add v
| Remove
| Update dv
-- | A change for each possible key.
newtype MapChanges k v dv = MapChanges (Map k (MapChange v dv))
prune :: forall k v. Array (Tuple k (Maybe v)) -> Array (Tuple k v)