Skip to content

Instantly share code, notes, and snippets.

View pete-murphy's full-sized avatar

Pete Murphy pete-murphy

View GitHub Profile
@pete-murphy
pete-murphy / Main.purs
Created August 21, 2022 17:31
Render unicode in React text element
module HelloReactHooks.Main where
import Prelude
import Data.Maybe (Maybe(..))
import Effect (Effect)
import Effect.Exception (throw)
import React.Basic.DOM as R
import React.Basic.DOM.Client (createRoot, renderRoot)
import Web.DOM.NonElementParentNode (getElementById)
{ config, pkgs, lib, ... }:
let
zsh-plugins = {
nix-shell = (fetchGit {
url = "https://github.com/chisui/zsh-nix-shell.git";
rev = "69e90b9bccecd84734948fb03087c2454a8522f6";
});
nix-zsh-completions = (fetchGit {
import * as L from "fp-ts-foldl"
import Immutable from "immutable"
import { readonlyArray as RA, readonlyNonEmptyArray as RNEA } from "fp-ts"
import { pipe } from "fp-ts/function"
import * as t from "transducers-js"
const inc = (n: number) => n + 1
const isEven = (n: number) => n % 2 === 0
const sum = (a: number, b: number) => a + b
@pete-murphy
pete-murphy / Main.purs
Created July 15, 2022 17:21
Derive Functor for Cont-like type
module Main where
import Prelude
import Effect (Effect)
import Elmish.Dispatch (Dispatch)
import Control.Monad.Cont (Cont, runCont)
import Data.Newtype (class Newtype)
newtype Effect' a = Effect' (Cont (Effect Unit) a)
module Main where
import Prelude
import Effect.Console (log)
import TryPureScript
whenFalseAndTrue = when (false && true) do
log "whenFalseAndTrue"
whenTrue = when true do
@pete-murphy
pete-murphy / Main.purs
Created July 7, 2022 14:46
Double-logging repro attempt
module Main where
import Prelude
import Data.Foldable (traverse_)
import Effect.Console (log)
import TryPureScript (render, withConsole)
abc item = when (item.name == "NAME") $ do
log "Here"
@pete-murphy
pete-murphy / Main.purs
Created June 20, 2022 18:50
Snake recipe (updated to 0.15)
module Main where
import Prelude
import Color (Color, black, toHexString, white, rgb)
import Control.Monad.Rec.Loops (iterateWhile)
import Control.Alternative (guard)
import Data.Array.NonEmpty (NonEmptyArray, cons, cons', dropEnd, head, singleton)
import Data.Int (toNumber)
import Data.Maybe (maybe)
@pete-murphy
pete-murphy / README
Created June 7, 2022 21:35 — forked from jmatsushita/README
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.
# Inspired by https://github.com/malob/nixpkgs I highly recommend looking at malob's repo for a more thorough configuration
#
# Let's get started
#
# Let's install nix (at the time of writing this is version 2.5.1
curl -L https://nixos.org/nix/install | sh
# I might not have needed to, but I rebooted
@pete-murphy
pete-murphy / Main.purs
Last active April 24, 2022 15:41
Example of merging props with default values in wrapper component
module Main where
import Prelude
import Prim.Row (class Nub, class Union)
import React.Basic.DOM as DOM
import React.Basic.DOM.Generated (Props_video)
import React.Basic.Hooks (Component)
import React.Basic.Hooks as React
import Record (merge)
@pete-murphy
pete-murphy / Main.purs
Last active February 26, 2022 22:48
FingerTree usage
module Main where
import Prelude
import Data.Array as Array
import Data.FingerTree (FingerTree)
import Data.FingerTree as FingerTree
import Data.Lazy as Lazy
import Data.Monoid.Additive (Additive(..))
import Data.Newtype (class Newtype)